Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Can't build android

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

  1. makcimbx

    makcimbx

    Joined:
    Aug 29, 2017
    Posts:
    12
    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:
    123
    Did you fix the errors? I have the same error ... I can't find any solution...
     
    RSH1 likes this.
  3. makcimbx

    makcimbx

    Joined:
    Aug 29, 2017
    Posts:
    12
    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,916
    You'll need to remake gradle properties template, since Android Gradle Plugin was updated and enableR8 property is no longer available.
     
    AndreaMar and codxr like this.
  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:
    90
    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:
    90
    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:
    5
    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
  9. ohhno28

    ohhno28

    Joined:
    Jun 10, 2023
    Posts:
    1
    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.
     
  10. JulienPlayrion

    JulienPlayrion

    Joined:
    Oct 21, 2021
    Posts:
    5
    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+"
     
  11. EyeDev44

    EyeDev44

    Joined:
    Apr 8, 2017
    Posts:
    149
    Fixed in 2022 LTS by replacing
    android.enableR8=**MINIFY_WITH_R_EIGHT**
    to
    android.enableR8=true
    in gradleTemplate.
     
  12. TheReturnedAB

    TheReturnedAB

    Joined:
    Aug 5, 2022
    Posts:
    1
    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
    Code (CSharp):
    1. org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
    2. org.gradle.parallel=true
    3. unityStreamingAssets=**STREAMING_ASSETS**
    4. **ADDITIONAL_PROPERTIES**
    5. android.enableR8=false
    6. android.useAndroidX=true
    7. android.enableJetifier=true
    8.  
     
  13. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    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?
     
  14. arossini-rortos

    arossini-rortos

    Joined:
    Oct 29, 2021
    Posts:
    19

    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).
     
    ZWLSOFTWARE likes this.
  15. knight-games

    knight-games

    Joined:
    Jul 7, 2023
    Posts:
    5
    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
     
  16. vijayola

    vijayola

    Joined:
    Jan 29, 2021
    Posts:
    1
    worked for me, Thanks !
     
  17. pushok_leha

    pushok_leha

    Joined:
    Nov 17, 2017
    Posts:
    6
    Thank you. It works for me.