I am new to unity. I am using unity 2021.3.10f1 I made my own game and added advertising and other features. When trying to build, it shows the error "CommandInvokationFailure: Gradle build failed." Can you help? An error that is shown in unity:
CommandInvokationFailure: Gradle build failed.
D:\HappyWin\Unity and projects\2021.3.10f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "D:\HappyWin\gradle-6.1.1\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
Changed gradle to different versions. Did not help.
I have tried to solve it through different pre-answered questions on StackOverflow but they are not working, That is why asking here, Please help.
here is the problem:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\TME_Education\StudioProjects\jeda\android\app\build.gradle' line: 58
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method compile() for arguments [com.android.tools.build:gradle:7.1.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Here is my dependency
dependencies {
compile 'com.android.tools.build:gradle:7.1.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
I was runing the code but this gradle Dependency eror happened.
I updated gradle to 7.4 and got this issue:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/dani/Desktop/repos/dani/my_rents/android/app/build.gradle' line: 30
* What went wrong:
A problem occurred evaluating project ':app'.
> com/android/build/api/extension/AndroidComponentsExtension
It points to this line:
apply plugin: 'com.google.firebase.firebase-perf'
It throws me this error every mdk file i use
Description Resource Path Location Type
Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.8-bin.zip'.
Initialization script 'C:\Users####\eclipse-workspace.metadata.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle'
Could not compile initialization script 'C:\Users####\eclipse-workspace.metadata.plugins\org.eclipse.buildship.core\init.d\eclipsePlugin.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
the error appears without any changes that I do:
> * What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Path '/Users/mac/Documents/projects/build/sqflite/intermediates/compiled_local_resources/debug/out' is not a readable directory.
I managed to solve it by upgrading Gradle and kotlin
You can try to add the following line into your app/build.gradle file.
buildToolsVersion "29.0.2"
Look at the official document for more info.