- Home /
Android Gradle Build Error
Trying to build with Gradle, and I get this error:
CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_91\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-2.14.jar" org.gradle.launcher.GradleMain "assembleRelease"
stderr[
C:\Users\Josh\Desktop\AdApp\AdApp - Test this next\Temp\StagingArea\gradleOut\src\main\AndroidManifest.xml:4: Error: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode]
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:name="io.fabric.unity.android.FabricApplication" android:theme="@style/UnityThemeSelector" android:debuggable="false" android:isGame="true" android:banner="@drawable/app_banner">
Yes I am aware what it means. However I have removed 'android:debuggable' from all my Manifests. Unity is inputting it somewhere along the buildchain.
How can I get passed this?
Answer by OleSviper · Jan 24, 2017 at 11:43 AM
I just removed 'android:debuggable' from all my AndroidManifest.xml files too but you are right, the message is still there. So it seems like the Unity Android build process adds it.
HOWEVER I think this is just the last message that was written to stderr before another exception occurred, that failed the build. Check the Editor.log file and look for
FAILURE: Build failed with an exception.
What went wrong:
You should see the real exception here.
Indeed! In my case I was seeing this:
* What went wrong:
Execution failed for task ':transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Strange that DexIndexOverflowException is the 64$$anonymous$$ problem that makes us switch to Gradle. I had this problem on Internal built, switch to Gradle, worked for some time and now one plugin later it started in Gradle too. Here's what I did:
Build, but check "Export Project"
Add this to build.gradle on the exported project
android {
...
defaultConfig {
...
multiDexEnabled true
}
dexOptions {
java$$anonymous$$axHeapSize "2g"
}
...
}
Copy build,gradle to Assets/Plugins/Android/mainTemplate.gradle
Build AP$$anonymous$$
Remember to repeat this if you install any other android plugin
There's an issue I think may be related to that... https://issuetracker.unity3d.com/issues/gradle-building-fails-giving-misleading-hardcodeddebugmode-error
EDIT: We need to change the manifest too or the game will hit the multidex limit while loading the libraries. Add this to Android$$anonymous$$anifest.xml, inside the application tag:
<application ...
android:name="android.support.multidex.$$anonymous$$ultiDexApplication" >
$$anonymous$$ore about this issue here.
Answer by GMonks-Entertainment · Jan 27, 2017 at 06:26 PM
Its a known bug in admob unitypackage.
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/JVArJV5aDqg
Great. It works for me.
package="com.google.unity" -> package="com.google.unity.ads"
Answer by Claudioteles85 · Feb 14, 2018 at 04:35 PM
I spent several hours stuck on this, no one had the solution for the problem I was having, Finely under Player > Publisher Settings, under Build, I checked off the box that says "Custom Graddle Template" and it worked. If you're having the same issue it might work for you too.
I checked On the "Custom Gradle Template" and it worked for me. So thanks you saved me.
Answer by a96andrei · May 17, 2017 at 01:09 PM
I managed to find a workaround to this problem. After removing all 'android:debuggable' from your manifests, export your project to Android Studio (using Gradle build) and build it from there. This way, you will have more control over your final AndroidManifest.xml. Tested with Unity 5.6.1f1.
Answer by MaxKarpinsky · Sep 24, 2017 at 07:35 PM
https://docs.unity3d.com/Manual/android-manifest.html
Read the docs. It says that Unity generates it, thus it's in Temp folder. Unity ads debug mode and set it to false if it's a release build.
You have to create or generate your own AndroidManifest.xml that will override the creation it in Temp.
Overriding the Android Manifest
Although Unity generates a correct Manifest for you, in some cases you might want direct control over its contents.
""" To use an Android Manifest that you have created outside of Unity, import your Android Manifest file to the following location: Assets/Plugins/Android/AndroidManifest.xml. This overrides the default Unity-created Manifest.
In this situation, Android Libraries’ Manifests are later merged into your main Manifest, and the resulting Manifest is still tweaked by Unity to make sure the configuration is correct. For full control of the Manifest, including permissions, you need to export the Project and modify the final Manifest in Android Studio. Please note that we only support launchMode - singleTask. """
Though, it doesn't really help right now, it adds debuggable anyway.
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Cross compilation job Assembly-CSharp.dll failed. When building iOS. 2 Answers
【LuminSDK Unity】Deploy to Magic Leap One and MLDB error: API level requested does not support 1 Answer