Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Can't build android

Discussion in '2022.2 Beta' started by makcimbx, Oct 28, 2022.

  1. makcimbx

    makcimbx

    Joined:
    Aug 29, 2017
    Posts:
    10
    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/ma...ty/10.0.1/firebase-analytics-unity-10.0.1.pom
    - https://repo.maven.apache.org/maven...ty/10.0.1/firebase-analytics-unity-10.0.1.pom
    file:/Users/makcimbx/Tw-stages/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-analytics-unity-10.0.1.jar
    file:/Users/makcimbx/Tw-stages/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/firebase-analytics-unity.jar

    Android build is working well on last Unity 2022.1.
     
  2. magsoftware

    magsoftware

    Joined:
    Feb 7, 2019
    Posts:
    105
    Did you fix the errors? I have the same error ... I can't find any solution...
     
  3. makcimbx

    makcimbx

    Joined:
    Aug 29, 2017
    Posts:
    10
    No, I just rolled back to previous versions of 2021.3. I'll wait for stable 2022.2, maybe something will be changed.
     
    magsoftware likes this.
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,525
    You'll need to remake gradle properties template, since Android Gradle Plugin was updated and enableR8 property is no longer available.
     
  5. cat_muzzle

    cat_muzzle

    Joined:
    Jan 30, 2016
    Posts:
    2
    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.

    // Android Resolver Repos Start
    ([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()
    }
    }
     
  6. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    81
    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.
     
  7. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    81
    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:

    Code (CSharp):
    1. public class AndroidSettingsGradleModifier : IPostGenerateGradleAndroidProject
    2. {
    3.     public int callbackOrder => 0;
    4.  
    5.     public void OnPostGenerateGradleAndroidProject(string path)
    6.     {
    7.         path = path.Substring(0, path.Length - 12);
    8.         var settingsGradle = System.IO.File.ReadAllText(path + "/settings.gradle");
    9.         settingsGradle = settingsGradle.Replace("repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)", "repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)");
    10.         System.IO.File.WriteAllText(path + "/settings.gradle", settingsGradle);
    11.     }
    12. }
     
    jihun3 likes this.
  8. JulienPlayrion

    JulienPlayrion

    Joined:
    Oct 21, 2021
    Posts:
    1
    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)
     
    Last edited: Jun 9, 2023 at 9:50 AM