Hello everyone,
I am unable to export my Unity project to Android due to several Gradle errors and dependency conflicts. Below are the details of the issues I’m facing:
Main Errors:
- Error 1: compileSdkVersion is not specified
- During the build process, I get this error:
A problem occurred configuring project ':unityLibrary'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle
- Error 2: Incorrect dependency configuration
- Another error states that Gradle cannot recognize the following dependency:
Could not find method androidx.lifecycle:lifecycle-common-java8:2.4.1() for arguments ...
- However, I’ve added the dependency in
mainTemplate.gradle
like this:
implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1'
- Warnings about repositories
- Gradle warns me about repositories being added in
unityLibrary/build.gradle
improperly:
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added ...
What I’ve Already Tried:
- Setting
compileSdkVersion
inmainTemplate.gradle
:
gradle
android {
compileSdkVersion 33
buildToolsVersion "33.0.0"
}
- Forcing dependency versions to resolve conflicts:
gradle
allprojects {
configurations.all {
resolutionStrategy {
force 'androidx.lifecycle:lifecycle-common-java8:2.4.1'
force 'androidx.annotation:annotation:1.3.0'
}
}
}
- Cleaning the project:
- Deleted the
Library
andTemp
folders and rebuilt the project in Unity.
My Environment:
- Unity version: 2023.2.20f1
- Gradle version: 7.6 (provided by Unity)
- Android Gradle Plugin: 7.3.1
- Android SDK: API 33
- NDK: Default version provided by Unity
What I Need Help With:
I’m stuck and unable to export my project. If anyone has encountered these issues before or has a solution, I’d greatly appreciate any advice or guidance.
Thank you so much for your time and help!