Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Gradle build fail after Google Mobile Ads

Discussion in 'Editor & General Support' started by Ebonicus, Jan 15, 2023.

  1. Ebonicus

    Ebonicus

    Joined:
    Oct 31, 2016
    Posts:
    158
    Hi All,

    I need assistance, stack overflow and unity forums do not have anything similar to this issue.

    I am running:
    Win 10, with Unity LTS 2019.4.31F
    App builds fine, for android or ios, and there are no 3rd party assets, very simple app.
    I am very familiar with GMADs implementation, and have never had issues with this system configuration.


    I'm at the point to add monetization, so per Google Mobile Ads Guide
    I imported:
    GoogleMobileAds-v7.3.1 (first time with this version)​
    External Dependency Manager, located here:

    For Unity External Tools Preferences, I have Android SDK Tool enabled, running Android 30 and build tools ver 30.0.2

    My min SDK is Android 6.0 API 23 and Target is highest installed.
    I have tired setting target to Android 30 and just produces different gradle errors and similar build fail.
    For Publishing Player Gradle options, nothing is selected, no custom gradle files. Minify is disabled.


    Here are the console errors I am getting:


    \AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.4.34f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

    > Configure project :unityLibrary
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    > Configure project :unityLibrary:GoogleMobileAdsPlugin.androidlib
    WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported.
    The current default is 'true'.


    > Task :launcher:preBuild UP-TO-DATE
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:preBuild UP-TO-DATE
    > Task :unityLibrary:preBuild UP-TO-DATE
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:checkReleaseManifest
    > Task :launcher:prepareLintJar
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:checkReleaseManifest
    > Task :unityLibrary:processReleaseManifest
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:processReleaseManifest
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:packageReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:generateReleaseResValues
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseResValues
    > Task :unityLibrary:generateReleaseResources
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseResources
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:packageReleaseResources
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:mergeReleaseShaders
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseShaders
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseAssets
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:packageReleaseAssets
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseAidl NO-SOURCE
    > Task :unityLibrary:packageReleaseResources
    > Task :unityLibrary:mergeReleaseShaders
    > Task :unityLibrary:compileReleaseShaders
    > Task :unityLibrary:generateReleaseAssets
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseRFile
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseBuildConfig
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:prepareLintJar
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:generateReleaseSources
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:javaPreCompileRelease
    > Task :unityLibrary:packageReleaseAssets
    > Task :unityLibrary:compileReleaseAidl NO-SOURCE
    > Task :unityLibrary:generateReleaseBuildConfig
    > Task :launcher:preReleaseBuild
    > Task :launcher:compileReleaseRenderscript NO-SOURCE
    > Task :launcher:generateReleaseResValues
    > Task :launcher:generateReleaseResources
    > Task :unityLibrary:generateReleaseRFile
    > Task :unityLibrary:prepareLintJar
    > Task :unityLibrary:generateReleaseSources
    > Task :unityLibrary:processReleaseJavaRes NO-SOURCE
    > Task :unityLibrary:mergeReleaseJniLibFolders
    > Task :unityLibrary:transformNativeLibsWithMergeJniLibsForRelease
    > Task :unityLibrary:transformNativeLibsWithStripDebugSymbolForRelease
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:compileReleaseJavaWithJavac
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:bundleLibCompileRelease
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:bundleLibRuntimeRelease
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:processReleaseJavaRes NO-SOURCE
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:bundleLibResRelease
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:mergeReleaseJniLibFolders
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:transformNativeLibsWithMergeJniLibsForRelease
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:transformNativeLibsWithStripDebugSymbolForRelease
    > Task :unityLibrary:GoogleMobileAdsPlugin.androidlib:transformNativeLibsWithIntermediateJniLibsForRelease
    > Task :unityLibrary:transformNativeLibsWithIntermediateJniLibsForRelease
    > Task :unityLibrary:javaPreCompileRelease

    > Task :unityLibrary:compileReleaseJavaWithJavac

    > Task :unityLibrary:bundleLibCompileRelease
    > Task :unityLibrary:bundleLibRuntimeRelease
    > Task :unityLibrary:bundleLibResRelease
    > Task :launcher:mergeReleaseResources
    > Task :launcher:checkReleaseManifest
    > Task :launcher:createReleaseCompatibleScreenManifests
    > Task :launcher:mainApkListPersistenceRelease
    > Task :launcher:processReleaseManifest
    > Task :launcher:bundleReleaseResources FAILED

    [B]Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.[/B]
    Use '--warning-mode all' to show the individual deprecation warnings.
    See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
    47 actionable tasks: 47 executed

    UnityEngine.GUIUtility:ProcessEvent (int,intptr)


    Notes:
    All the read only file errors, are not available after build, they dont exist.
    I am on 2019.4.31F Unity, not sure why Gradle is ver 6.
    In Android Studio, I only have build tools up to Android 30.
    But this is irrelevant, since I am using Unity Android SDK folder.


    [B]

    [/B]
    FAILURE: Build failed with an exception.

    * 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\mydocs\Unity 2019.4.12f1\myappmasked\Temp\gradleOut\launcher\build\intermediates\bundle_manifest\release\processReleaseManifest\bundle-manifest\AndroidManifest.xml:45: error: unexpected element <queries> found in <manifest>.

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 14s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

    UnityEngine.GUIUtility:ProcessEvent (int,intptr)


    Note:
    The queries block is being adding during manifest merge, not sure where it comes from or how to remove it, my apps' androidmanifest.xml has nothing similar.

    I think the gradle incompatibility may be an issue, but I have no idea why Gradle 6.0 is running, I thought Unity 2019.4.31F LTS uses an older version of Gradle, and the External Dependency Resolver is managing this by Unity. But I do know Google Play requires Android SDK 30 as the target build.

    Log file is attached, any help would be most appreciated.

    Kind Regards,

    -E
     

    Attached Files:

  2. Ebonicus

    Ebonicus

    Joined:
    Oct 31, 2016
    Posts:
    158
    Here are things I have tried:

    For read only error, I have tried multiple times to make the entire SDK folder and subfolders and contents no read only. They keep reverting to read only. Most of this files listed do not even exist, I have no idea where to get them, as I do not use any custom gradle file option.

    Changing build target to Highest Available - no change
    Changing build target to Android 30 - no change
    Changing preference to specify C:Android SDK folders from Android Studio installs - No change
    Changing build target to Highest Available with custom SDK folders- no change
    Changing build target to Android 30 with custom SDK folders- no change

    Removing Unity Adnroid build tools 30.0.1 and replace with build tools 29.0.3 from Android\SDK folder used by Android Studio. - No change.

    Removed My Ad Manager script, and deleted Google Mobiles Ads Asset and External Dependency Manager. - Builds Perfectly.

    Reinstalled, and back to the same build failures.

    The closest online I could find was this post on Stack:
    https://stackoverflow.com/questions/71458787/errors-in-unity-when-building-the-game

    He has ver 7 Gradle reporting Google Ads is using deprecated gradle files.
    There is no viable solution posted, as I already am targeting Android 30.

    Regards.
     
    Last edited: Jan 15, 2023
  3. Heurazio

    Heurazio

    Joined:
    Dec 24, 2021
    Posts:
    8
    @Ebonicus Did you find a solution? Having a similar problem.
     
  4. Ebonicus

    Ebonicus

    Joined:
    Oct 31, 2016
    Posts:
    158
    @Heurazio I upgraded to Unity 2020 LTS and that solved it.
     
  5. umarkhaleeq

    umarkhaleeq

    Joined:
    Dec 16, 2018
    Posts:
    13
    Open AndroidManifest.xml
    Assets/Plugins/Android/AndroidManifest.xml

    if document contains this line
     <property tools:node="removeAll" />

    remove this full line

    at the very end of file
    write this line
       <!-- AnalyticsFixPropertyRemover -->


    so now your full file should be like this
    at start
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">


    at end
       <!-- AnalyticsFixPropertyRemover -->


    and no
    <property tools:node="removeAll" />
    line .

    I figured this after failing for 8 days straight. build now successful, also everything working in game. ads, sign in with google , ads, ads ump,

    My Unity 2022.3.21f1
    Admob 8.6.0
    firebase latest
    external dependancy 1.2.177