1

I'm making a mobile game using Unity for Android. My problem is, every time I try to build the project I get this error :

CommandInvokationFailure: Gradle build failed. C:\Program Files\Unity\Hub\Editor\2022.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2022.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease" stderr[ FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':launcher:lintVitalRelease'.

This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry. The following AndroidX dependencies are detected: androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.versionedparcelable:versionedparcelable:1.1.0, androidx.core:core:1.2.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.2.0, androidx.startup:startup-runtime:1.0.0, androidx.tracing:tracing:1.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0

  • 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

    • BUILD FAILED in 18s Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 ] stdout[ Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

Configure project :launcher WARNING: The option setting 'android.enableR8=false' is deprecated. It will be removed in version 5.0 of the Android Gradle plugin. You will no longer be able to disable R8 Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only Exception while marshalling C:\Program Files\Unity\Hub\Editor\2022.1.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only etc...

So then I tried adding the property "android.useAndroidX=true" in the gradleTemplate.properties file. Here is the code :

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
unityStreamingAssets=**STREAMING_ASSETS**
**ADDITIONAL_PROPERTIES**
android.useAndroidX=true

But it resulted in a new error :

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':launcher:checkReleaseDuplicateClasses'.

1 exception was raised by workers: java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.ResultReceiver found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.ResultReceiver$1 found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.ResultReceiver$MyResultReceiver found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.2.0-runtime.jar (androidx.core:core:1.2.0) and support-compat-26.1.0-runtime.jar (com.android.support:support-compat:26.1.0) Go to the documentation to learn how to Fix dependency resolution errors.

I think the core error might come from the unity mediation package, as the build started failing when I added it. Another clue is that whenever I try to resolve android dependencies using the mobile dependencies resolver, I get a warning log saying that there is a dependencies conflict involving this package. I created a topic about it at How to solve this dependencies conflict warning using Unity Mediation? Thanks in advance for your answers.

  • What you think is error is actually a **WARNING**. – shingo Nov 09 '22 at 13:00
  • It think it is an error : I can't build the project anymore – Louis Leblond Nov 09 '22 at 13:02
  • You can't build because there is an error, but the first one isn't. So you need add it back, build your project again, when it fails search first occurence of "error" in the editor log. And you've also mentioned you have custom gradleTemplate, so you'd better add generated gradle files in the question. (You can find them in Temp/StagingArea folder) – shingo Nov 09 '22 at 14:12
  • Got it ! I edited the topic so it could be more accurate, thanks a lot ! – Louis Leblond Nov 09 '22 at 17:43
  • The error says your project depends on both androidX and support libraries, I guess the Mediation package requires androidX, so some other plugins use support libraray. OK if you know which plugin is, try to remove support library from it. If you don't know, you need export the project first, open it with Android Studio, then you can find and execute a task called **androidDependencies** that will help you to find the plugin. https://developer.android.com/studio/build/dependencies.html#view-dependency-tree – shingo Nov 10 '22 at 04:23
  • And don't forget add `android.enableJetifier=true` in gradleTemplate.properties – shingo Nov 10 '22 at 04:29

0 Answers0