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?

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.

Its a known bug in admob unitypackage.

https://groups.google.com/forum/#!topic/google-admob-ads-sdk/JVArJV5aDqg

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 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.

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.