- Home /
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.
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
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
}
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!
Thank you king. I was having this problem with Iron Source or one of its mediation plugins (Unity or Ad$$anonymous$$ob,) 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.
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
Thank you, this is a great solution, quickly solved the problem!
This should be accepted as the best answer. Other solution created another error about a launcher.aab file missing for me.
This solution work in my case, Thanks Dude! You're a life saver!
I don't have this file...baseProjectTemplate.gradle Or if someone can actually tell the location where this file could be found
You can enable it under Player Settings>Publishing Settings>Custom Base Gradle Template. It will then be created under Assets/Plugins/Android
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