2019.3 -> You uploaded a debuggable APK

EDIT:

Fixed, look at the Next post.

Hi all,

I'm a bit baffled, and I'm hoping some Android genius can help me out!

I've got a game on the Google play store. It's all fine and good.
Now I've been trying to make a new build and upload that one. But every time I get the following error:

"Upload failed You uploaded a debuggable APK or Android App Bundle. For security reasons you need to disable debugging before it can be published in Google Play."

I don't have Development build checked. I got a keystore file and password added correctly. I even tried a new Keystore file, and signed it with that, with the same result.
5041970--494510--buildSettings.png

When I inspect the final APK Manifest in Android studio it has the following line:
"android:debuggable="true""
5041970--494513--buidManifest.png

I'm guessing it's something I am overlooking. But I have no clue what.

I tried the build on 2 PC with 2019.3.0b6 and on one with 2019.3.0b4
Any help would be super appreciated!

4 Likes

Got it!

For anyone else having this issue. If you are using FacebookSDK which comes with Google Play services, it can be that in injects a Debuggable=true key in the Manifest, for whatever reason.

I could fix it by going to Assets>Android>AndroidManifest.xml
In there find 'android:debuggable="true"' and set it to false.

Easy to overlook when 10 things are on 1 line.

86 Likes

Thank you VERY MUCH for this advice! Worked for me as well.

2 Likes


THIS IS IT! ABSOLUTE LEGEND!

2 Likes

Thank you! That was it!

Thanks for the solution mate. This is exemplary behaviour everyone.

2 Likes

Same here!

as if they did it just to troll us

1 Like

Worked perfect, thanks!

Thank you !

Thanks, this still is happening and this solved it for me.

Thanks, I installed the Facebook SDK and this solution solved the problem.

It worked. Thanks

Thanks!!


thanks


Thanks :)

got same issue with fb sdk v11, and now manifest located in

./Assets/Plugins/Android/AndroidManifest.xml

anyway this resolved my issue

1 Like

Here is a solution we use in our plugins to patch final manifest automatically (Modified here for easy integration).
Do let us know if you see any issues.

Usage: Place the below script under Editor folder.

#if UNITY_EDITOR && UNITY_ANDROID
using System.IO;
using System.Text;
using System.Xml;
using UnityEditor.Android;

namespace VoxelBusters.EssentialKit.Editor.Android
{
    public class AndroidManifestPostProcessor : IPostGenerateGradleAndroidProject
    {
        public void OnPostGenerateGradleAndroidProject(string basePath)
        {
            EssentialKitSettings settings;
            if (!EssentialKitSettingsEditorUtility.SettingsExists)
            {
                return;
            }


            AndroidManifest androidManifest = new AndroidManifest(GetManifestPath(basePath));

            //For forcing android hardwareAccelerated flag : Comment below if you don't need to force hardware acceleration flag
            androidManifest.SetApplicationAttribute("hardwareAccelerated", "true");
            androidManifest.SetStartingActivityAttribute("hardwareAccelerated", "true");

            //For forcing debuggable flag to respect EditorUserBuildSettings value
            androidManifest.SetApplicationAttribute("debuggable", UnityEditor.EditorUserBuildSettings.development ? "true" : "false");

            androidManifest.Save();
        }

        public int callbackOrder { get { return 1; } }

        private string _manifestFilePath;

        private string GetManifestPath(string basePath)
        {
            if (string.IsNullOrEmpty(_manifestFilePath))
            {
                StringBuilder pathBuilder = new StringBuilder(basePath);
                pathBuilder.Append(Path.DirectorySeparatorChar).Append("src");
                pathBuilder.Append(Path.DirectorySeparatorChar).Append("main");
                pathBuilder.Append(Path.DirectorySeparatorChar).Append("AndroidManifest.xml");
                _manifestFilePath = pathBuilder.ToString();
            }
            return _manifestFilePath;
        }
    }

    //Reference Used : https://github.com/Over17/UnityAndroidManifestCallback
    internal class AndroidXmlDocument : XmlDocument
    {
        private string m_Path;
        protected XmlNamespaceManager nsMgr;
        public readonly string AndroidXmlNamespace = "http://schemas.android.com/apk/res/android";
        public AndroidXmlDocument(string path)
        {
            m_Path = path;
            using (var reader = new XmlTextReader(m_Path))
            {
                reader.Read();
                Load(reader);
            }
            nsMgr = new XmlNamespaceManager(NameTable);
            nsMgr.AddNamespace("android", AndroidXmlNamespace);
        }

        public string Save()
        {
            return SaveAs(m_Path);
        }

        public string SaveAs(string path)
        {
            using (var writer = new XmlTextWriter(path, new UTF8Encoding(false)))
            {
                writer.Formatting = Formatting.Indented;
                Save(writer);
            }
            return path;
        }
    }


    internal class AndroidManifest : AndroidXmlDocument
    {
        private readonly XmlElement ApplicationElement;

        public AndroidManifest(string path) : base(path)
        {
            ApplicationElement = SelectSingleNode("/manifest/application") as XmlElement;
        }

        private XmlAttribute CreateAndroidAttribute(string key, string value)
        {
            XmlAttribute attr = CreateAttribute("android", key, AndroidXmlNamespace);
            attr.Value = value;
            return attr;
        }

        internal XmlNode GetActivityWithLaunchIntent()
        {
            return SelectSingleNode("/manifest/application/activity[intent-filter/action/@android:name='android.intent.action.MAIN' and " +
                    "intent-filter/category/@android:name='android.intent.category.LAUNCHER']", nsMgr);
        }

        internal void SetApplicationTheme(string appTheme)
        {
            ApplicationElement.Attributes.Append(CreateAndroidAttribute("theme", appTheme));
        }

        internal void SetStartingActivityName(string activityName)
        {
            GetActivityWithLaunchIntent().Attributes.Append(CreateAndroidAttribute("name", activityName));
        }

        internal void SetApplicationAttribute(string key, string value)
        {
            ApplicationElement.Attributes.Append(CreateAndroidAttribute(key, value));
        }

        internal void SetStartingActivityAttribute(string key, string value)
        {
            XmlNode node = GetActivityWithLaunchIntent();
            if(node != null)
            {
                XmlAttributeCollection  attributes = node.Attributes;
                attributes.Append(CreateAndroidAttribute(key, value));
            }
        }
    }
}
#endif

Thanks,
VB Team

2 Likes

Nice one! Many thanks for sharing.

1 Like

thank you!