And probably a dozen other variants, but I am not willing to waste my time any
further by enumerating all possible embarrasing crashes of cursed tools. The
oldest Android Gradle plugin version that worked with Gradle 6.6.1 and NDK r19
was 3.6.0, and to change it update the following entry in your `build.gradle`:
@code{.gradle}
buildscript {
// ...
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
@endcode
@subsection platform-android-troubleshooting-no-repositories-defined Gradle fails because no repositories are defined
Android Gradle plugin 3.6 and newer may *greet* you with the following when
doing a fresh build:
@code{.shell-session}
@code{.shell-session}
$ gradle build
$ gradle build
> Task :mergeDebugResources FAILED
FAILURE: Build failed with an exception.
FAILURE: Build failed with an exception.
* What went wrong:
* What went wrong:
Could not open terminal for stdout: could not get termcap entry
Execution failed for task ':mergeDebugResources'.
> Could not resolve all files for configuration ':_internal_aapt2_binary'.
> Cannot resolve external dependency com.android.tools.build:aapt2:4.0.0-6051327 because no repositories are defined.
Required by:
project :
@endcode
@endcode
Solution is to set @cb{.sh} TERM=xterm @ce. See
Solution is to add the following to your `build.gradle`:
[gradle/gradle#4440](https://github.com/gradle/gradle/issues/4440) for more
information.
@code{.sh}
@code{.gradle}
TERM=xterm gradle build
allprojects {
repositories {
google()
}
}
@endcode
* *in addition* to the existing repositories defined inside `buildscript`:
@code{.gradle}
buildscript {
repositories {
jcenter()
google()
}
// ...
@endcode
@endcode
Both the two existing repositories inside `buildscript` are still needed, it
will fail with different but no less cryptic errors if you attempt to remove
either of them. When you add the `allprojects` entry, the problem may seemingly
look like it disappeared, since removing `allprojects` again will still work.
This is only true until you recreate the build directory from scratch so better
keep it there.
@subsection platforms-android-troubleshooting-licenses Accepting SDK licenses for Gradle
@subsection platforms-android-troubleshooting-licenses Accepting SDK licenses for Gradle
Gradle might refuse to build a project if SDK licenses are not accepted, with
Gradle might refuse to build a project if SDK licenses are not accepted, with
@ -1034,10 +1163,14 @@ following (assuming you have SDK version 26 at least):
sdkmanager --licenses # and then manually accept all of them
sdkmanager --licenses # and then manually accept all of them
@endcode
@endcode
The tool doesn't provide any diagnostic output if the accepting failed, so be
@m_class{m-note m-danger}
sure to verify that everything went well by executing @cb{.sh} sdkmanager --licenses @ce
again. If it offers the same licenses again, you might want to force it with
@par
@cb{.sh} sudo @ce.
The tool says @cb{.shell-session} All SDK package licenses accepted @ce and
* **returns with a success error code even if the accepting failed**, so be
sure to verify that everything went well by executing @cb{.sh} sdkmanager --licenses @ce again. If it offers the same licenses again, it didn't succeed
before. In that case you may want to force it with @cb{.sh} sudo @ce (and
then verify once again).
If the tool blows up with the following error, it's again because the Java
If the tool blows up with the following error, it's again because the Java
version is too new, see @ref platforms-android-troubleshooting-java8 "above"
version is too new, see @ref platforms-android-troubleshooting-java8 "above"
@ -1049,6 +1182,39 @@ Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annota
…
…
@endcode
@endcode
@subsection platforms-android-troubleshooting-licenses Gradle complains about an exception while marshalling some XML file that doesn't exist
@code{.shell-session}
$ gradle build
> Configure project :
Exception while marshalling /opt/android-sdk/build-tools/29.0.3/package.xml. Probably the SDK is read-only
…
@endcode
This message doesn't seem to result in a build error, however it might be
annoying. The files it complains about don't exist on the filesystem and it's
related to the @ref platforms-android-troubleshooting-licenses problem --- the
`package.xml` files get created during the (`sudo`ed) run of `sdkmanager`, even
if there are no licenses left to sign.
@subsection platforms-android-troubleshooting-no-signature-applicable Gradle fails because no signature of method is applicable for argument types
@code{.shell-session}
$ gradle build
* Where:
Build file '…/build.gradle' line: …
* What went wrong:
…
> No signature of method: build_3w19jaw3zqx2h2gvdj91syekc.android() is applicable for argument types: (build_3w19jaw3zqx2h2gvdj91syekc$_run_closure1) values: [build_3w19jaw3zqx2h2gvdj91syekc$_run_closure1@393eb206]
@endcode
The particular cryptic value may differ, but this means you have some error in
your Gradle file. Of course it won't tell you what the error is, so good luck
commenting out parts of the file until it works or you reach a different error.