Search Unity

Question Exception when trying to build for android (OpenJDK compiler exception)

Discussion in 'Editor & General Support' started by Daenni_, Dec 22, 2021.

  1. Daenni_

    Daenni_

    Joined:
    Nov 25, 2019
    Posts:
    1
    Hello,
    I am using Unity 2019.4.20f1. Last time I updated my game was a few months ago and now I wanted to update it again. When compiling for iOS everything worked fine. After switching the platform to Android "Resolving Android Dependencies" started running.

    When trying to build an App Bundle (Google Play) I got this error:

    * What went wrong:
    Execution failed for task ':launcher:bundleReleaseResources'.
    > 1 exception was raised by workers:
    com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
    C:\Users\danie\Documents\Unity\****App Name****\Temp\gradleOut\launcher\build\intermediates\bundle_manifest\release\processReleaseManifest\bundle-manifest\AndroidManifest.xml:41: error: unexpected element <queries> found in <manifest>.


    I traced this error down to the release of Android 11. I follow this Google Guide to fix this problem. https://developers.google.com/ar/develop/unity/android-11-build
    Like in the guide I am also using gradle-5.6.4. I have also tried using other versions (including the latest).

    After following the guide I got this error:

    * What went wrong:
    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.


    I fixed this by also including checking "Custom Gradle Properties Template":
    upload_2021-12-22_17-17-16.png

    After that I am getting the following error with which I am stuck on for 2 days right now.

    CommandInvokationFailure: Gradle build failed. 
    C:/Program Files/Unity/Hub/Editor/2019.4.20f1/Editor/Data/PlaybackEngines/AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Users\danie\Documents\gradle-5.6.4\lib\gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease"

    stderr[
    An exception has occurred in the compiler (1.8.0-adoptopenjdk). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.



    I have tried using a newer OpenJDK version but I cannot change the version as Unity says it requires JDK 8 (1.8).
     
  2. Peecha

    Peecha

    Joined:
    Dec 2, 2013
    Posts:
    23
    Hey, did you manage to figure out the problem? Having the same setup as you (slightly newer minor Unity version 40f1), I am getting the same output, unable to build.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    Android build not building:

    Recently (circa July 2022) there have been reports of Unity's installer failing to install the Android Tools.

    https://forum.unity.com/threads/cant-build-for-android.1306098/

    If it's not that, then here's how to troubleshoot:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If it does NOT build, then go fix your Unity installation, or your other tools, such as Android SDK, NDK, JDK, etc.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for that subsystem.
     
  4. Peecha

    Peecha

    Joined:
    Dec 2, 2013
    Posts:
    23
    GameTiles, Ripley123 and Kurt-Dekker like this.