• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by djexstas9 · Oct 28, 2020 at 07:36 AM · androidbuild-erroradsbuild error

AppLovinMax InMobi Adapter failes the build with gradle error about "queries" keywords in Unity 2019.4

The problem:

  • You add the InMobi adapter in AppLovin Integration manager, resolve dependencies and try to build and it fails with a lot of exceptions, one of them says "AAPT: error: unexpected element <queries> found in <mainfest>."


Actually I've solve it after 8hrs of pain but want to share the answer with the internet because I've found no info, I'll provide the solution in the answer below. Hope this will help someone in the future, maybe not exactly with AppLovin or InMobi.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by djexstas9 · Oct 28, 2020 at 08:00 AM

The Solution:

  • Download version of Gradle 5.6.4+ (I used 6.7)

  • Set it in Preferences -> ExternalTools as gradle to use

  • Open Player Settings -> Publishing Settings and enable "Custom Base Gradle Template", It will create a file Assets/Plugins/Android/baseProjectTemplate.gradle

  • Open it with any text editor and find "classpath 'com.android.tools.build:gradle:3.4.0'" row. It's located in "allprojects/buildscript/dependencies" object

  • Replace 3.4.0 with 3.6.0 or higher, I used 4.0.1

  • Save the file and try to build, It should work


Why does this happen?

  • Some third party library (in my case InMobi) adds keyword <queries> to gradle build manifest which is supported from Android Gradle Plugin 3.6.0 or higher. Android gradle plugin version 3.6.0 is supported from gradle version 5.6.4 or higher (yeah there are 2 different types of gradle version you should have to build. Source here:

https://developer.android.com/studio/releases/gradle-plugin#updating-gradle)

  • Unity by default provides gradle 5.1.1 or lower with editor (if I understood correctly), so it doesn't support gradle plugin 3.6.0 and <queries> keyword and builds with gradle plugin 3.4.0 by default:

https://docs.unity3d.com/Manual/android-gradle-overview.html

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image djexstas9 · Oct 28, 2020 at 08:12 AM 0
Share

There is my base gradle template (sorry I couldn't upload a file, it stucked on uploading):

 // GENERATED BY UNITY. RE$$anonymous$$OVE THIS CO$$anonymous$$$$anonymous$$ENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
 
 allprojects {
     buildscript {
         repositories {**ARTIFACTORYREPOSITORY**
             google()
             jcenter()
         }
 
         dependencies {
             // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
             // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/$$anonymous$$anual/android-gradle-overview.html
             // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
             // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
             classpath 'com.android.tools.build:gradle:4.1.0'
             **BUILD_SCRIPT_DEPS**
         }
     }
 
     repositories {**ARTIFACTORYREPOSITORY**
         google()
         jcenter()
         flatDir {
             dirs "${project(':unityLibrary').projectDir}/libs"
         }
     }
 }
 
 task clean(type: Delete) {
     delete rootProject.buildDir
 }
 
avatar image msnz · Dec 14, 2020 at 03:49 PM 0
Share

Spent the whole day stressing over this issue! It's night time now, I've already clocked more than 10 hours! And just as I'm about to give up, I find this post! Thank you!

avatar image nox_pp · Dec 16, 2020 at 06:13 PM 0
Share

Thank you king. I was having this problem with Iron Source or one of its mediation plugins (Unity or AdMob,) and don't know anything about the mess that is Gradle. This tip was much needed. Here's a direct link to the Gradle binaries for others that end up here: https://gradle.org/releases/

After much trial and error I used 5.6.4 and plugin version 3.6.4--whatever that means. The distributors of the third party libraries should be notified of this so that they can include it in their integration documentation, but who has time for that?

Lastly, I'm on 2018.4, and the build actually fails with the error "FileNotFoundException: Temp/gradleOut/build/outputs/bundle/release/gradleOut.aab does not exist" however, I was able to get around this issue by manually grabbing the file "gradleOut-release.aab" from "Temp/gradleOut/build/outputs/bundle/release/". The reason it fails is due to 2018.4 hardcoding gradleOut.aab as the filename, which is no longer what the output file is named in newer versions of Gradle, I assume.

avatar image
4

Answer by AppLovin_MaxB · Dec 30, 2020 at 12:07 AM

Hey everyone,

Just a heads up, the best fix is to skip updating Gradle as it might lead to further issues and use Android Gradle Plugin version 3.4.3 (at least for most versions of Unity). So you should change this line

 classpath 'com.android.tools.build:gradle:3.4.0'

to

 classpath 'com.android.tools.build:gradle:3.4.3'

in the baseProjectTemplate.gradle file.

This issue and a fix for it is actually described in the AppLovin MAX documentation here: https://dash.applovin.com/documentation/mediation/unity/mediation-adapters?network=INMOBI_NETWORK

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image udubaso · Jan 01 at 11:56 AM 0
Share

Thank you, this is a great solution, quickly solved the problem!

avatar image ckeskin · Jan 13 at 07:49 PM 0
Share

This should be accepted as the best answer. Other solution created another error about a launcher.aab file missing for me.

avatar image
1

Answer by hammadzahidfinz · Dec 22, 2020 at 08:40 AM

I did the steps but the error remains the same. My path for ExternalTools is /opt/gradle/gradle-6.7.1

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

309 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[ERROR ][Android Build] [5.3.4] Not able to build 1 Answer

Android - Error building player: Failed to repackage resources? 1 Answer

Android build error when using Unity Ads 2 Answers

Build error android with 2 ad networks 1 Answer

[SOLVED] Unable to merge android manifests error while trying to build a Gear VR project 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges