我正在使用Cordova,当我运行cordova build android
时,它会抛出错误。就像几个月前一样,制造APK也不是什么问题。我认为Java自动更新,导致一个问题?
我想这可能与com.google.gms:google-service
和gradle有关?我不知道。
这是完整的终端输出:
% cordova build android
[Gradle Properties] Detected Gradle property "android.useAndroidX" with the value of "true", Cordova's recommended value is "false"
[Gradle Properties] Detected Gradle property "android.enableJetifier" with the value of "true", Cordova's recommended value is "false"
cordova-plugin-firebasex: Preparing Firebase on Android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: /Users/<user>/Library/Android/sdk
Subproject Path: CordovaLib
Subproject Path: app
> Configure project :app
Adding classpath: com.google.gms:google-services:4.2.0
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
> Task :app:processDebugGoogleServices
Parsing json file: /Users/<user>/Sites/cordova/<projectname>/platforms/android/app/google-services.json
> Task :CordovaLib:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
> java.lang.NullPointerException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
21 actionable tasks: 5 executed, 16 up-to-date
Command failed with exit code 1: /Users/<user>/Sites/cordova/<project>/platforms/android/gradlew cdvBuildDebug -b /Users/<user>/Sites/cordova/<project>/platforms/android/build.gradle
javac -version
javac 1.8.0_292
------------------------------------------------------------
Gradle 6.9.1
------------------------------------------------------------
Build time: 2021-08-20 11:15:18 UTC
Revision: f0ddb54aaae0e44f0a7209c3c0274d506ea742a0
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.12 (Homebrew 11.0.12+0)
OS: Mac OS X 11.3.1 x86_64
谢谢你的建议!
好的…所以我解决了这一部分,但想把这篇文章留在这里,为其他人可能会遇到同样的问题。
Gradle
brew uninstall gradle@6
(因为我手动安装了这个版本)
brew install gradle
(目前正在安装7.1.1版本)
科尔多瓦
cordova platform remove android
(I was on 9)
cordova platform add android@10.1.0