Can't build android

Unity 2022.2.0b13
Mono or Il2cpp does not matter.

Firstly, i have a gradleTemplate.properties file with “android.enableR8=MINIFY_WITH_R_EIGHT” in it. When i try to build android, i get an error: Cannot parse project property android.enableR8=" of type ‘class java.lang.String’ as boolean. Expected ‘true’ or ‘false’.

Secondly, if i remove or hard set true this property, i have another error with all firebase packages:
Could not find com.google firebase:firebase-analytics-unity:10.0.1.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/google/firebase/firebase-analytics-unity/10.0.1/firebase-analytics-unity-10.0.1.pom

Android build is working well on last Unity 2022.1.

Did you fix the errors? I have the same error … I can’t find any solution…

1 Like

No, I just rolled back to previous versions of 2021.3. I’ll wait for stable 2022.2, maybe something will be changed.

1 Like

You’ll need to remake gradle properties template, since Android Gradle Plugin was updated and enableR8 property is no longer available.

2 Likes

Unity 2022.2.0f1
Build Android failed with Firebase Unity SDK.
Build was successful in Unity 2022.1.24f1.

The following part of ‘mainTemplate.gradle’ does not work.
Could not find ‘com.google.firebase:firebase-analytics-unity’ etc.

([rootProject] + (rootProject.subprojects as List)).each { project ->
project.repositories {
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
maven {
url "https://maven.google.com"
}
maven {
url (unityProjectPath + "/Assets/GeneratedLocalRepo/Firebase/m2repository")
}
maven {
url "https://maven.google.com/"
}
mavenLocal()
mavenCentral()
}
}

Faced the same issue here. Cannot use Crashlytics with Unity 2022.2.8f1 if I build for Android, meanwhile iOS builds are fine.

Is there any known information on what exactly has to be changed? The documentation states that “templates have been changed” without any particular information on that topic.

I seem to have found a solution to “Android Resolver Repos Start” block not working at all. It’s related to settings.gradle file having PREFER_SETTINGS over PREFER_PROJECT by default in Unity 2022.2. Custom-patching settings.gradle fixed the issues. Add this to a script inside any Editor folder:

public class AndroidSettingsGradleModifier : IPostGenerateGradleAndroidProject
{
    public int callbackOrder => 0;

    public void OnPostGenerateGradleAndroidProject(string path)
    {
        path = path.Substring(0, path.Length - 12);
        var settingsGradle = System.IO.File.ReadAllText(path + "/settings.gradle");
        settingsGradle = settingsGradle.Replace("repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)", "repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)");
        System.IO.File.WriteAllText(path + "/settings.gradle", settingsGradle);
    }
}
2 Likes

Thanks a lot, this is working! Well, apk building is still not working but at least I can move forward thanks to you.

Edit: a cleaner way to do that is to tick “Custom Gradle Settings template” in the player settings, then to proceed with the same modification (RepositoriesMode.PREFER_PROJECT) directly within the newly created file (which is at Assets/Plugins/Android/settingsTemplate.gradle)

hey i dont understand what exactly i need to do please can you explain it more clearly. Please will be a big help for me.

This is because Gradle 7.2 (I think) changes a lot of things and this changes are destructive.

For anyone struggling more than necessary on this, updating Firebase to the last version (11.0.0 currently) fixes the issue.
I guess that the fix is contained in the last version of the EDM, that is included within this Firebase version (1.2.176).
From the changelog: “Android Resolver - Inject Maven Repo to settingTemplate.gradle from Unity 2022.2+”

Fixed in 2022 LTS by replacing android.enableR8=**MINIFY_WITH_R_EIGHT** to android.enableR8=true in gradleTemplate.

6 Likes

I’m still getting “Cannot parse project property android.enableR8=‘MINIFY_WITH_R_EIGHT’ of type ‘class java.lang.String’ as boolean. Expected ‘true’ or ‘false’.” while my gradleTemplate.properties file looks like this

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

I deleted 'Cannot parse project property android.enableR8=‘MINIFY_WITH_R_EIGHT’ and it exports too. I add ‘android.enableR8=true’ and works too.

Now which one is the correct one to do?

WARNING:The option ‘android.enableR8’ is deprecated.
It was removed in version 7.0 of the Android Gradle plugin.
Please remove it from gradle.properties.

Keeping it I have this warning, so I guess the right solution is just to delete the “enableR8” entry (at least using Unity 2022.3.10f1 - built-in gradle 7.1.2).

1 Like

in my case,
‘android.enableR8=MINIFY_WITH_R_EIGHT
was written as 'android.enableR8=MINIFY_WITH_R_EIGHT ’ , with 2 empty spaces at the end.
deleted them and problem solved

worked for me, Thanks !

Thank you. It works for me.