Android: How to disable debugging to upload the apk-ThrowExceptions

Exception or error:

When I try to upload my app in Google Play I get this error.

Upload failed

You uploaded a debuggable APK. For security reasons you
need to disable debugging before it can be published in Google Play.
Learn more about debuggable APKs.

I compile my app with Android Studio 0.4.0

I tried to set this in my Manifest.xml – Android:debuggable="false" , but nothing happened.
When I tried to set this <option name="SOURCE_GEN_TASK_NAME" value="generateReleaseSources" /> in .iml file, and again nothing.

I tried and with this in build.gradle,and again nothing.

android {
    signingConfigs {
        debug {
            storeFile file("horoskopSms.jks")
            storePassword "1q2w3e"
            keyAlias "horoskopSms"
            keyPassword "1q2w3e"
        }
    }
}

My.iml file

<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE"    type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
  <configuration>
    <option name="SELECTED_BUILD_VARIANT" value="debug" />
    <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
    <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
    <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
    <option name="SOURCE_GEN_TASK_NAME" value="generateReleaseSources" />
    <option name="ALLOW_USER_CONFIGURATION" value="false" />
    <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
    <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
    <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
    <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
    <option name="APK_PATH" value="/build/apk/HoroskopSms-debug-unaligned.apk" />
  </configuration>
</facet>
     <facet type="android-gradle" name="Android-Gradle">
     <configuration>
     <option name="GRADLE_PROJECT_PATH" value=":HoroskopSms" />
  </configuration>
</facet>
  </component>
           <component name="NewModuleRootManager" inherit-compiler-output="false">
        <output url="file://$MODULE_DIR$/build/classes/debug" />
      <exclude-output />
     <content url="file://$MODULE_DIR$">
   <sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" />

<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug"         isTestSource="false" />
 <sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" />
     <sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/aidl" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/assets" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/java" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/jni" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/rs" isTestSource="true" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/res" type="java-test-resource" />
  <sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/resources" type="java-test-resource" />
  <excludeFolder url="file://$MODULE_DIR$/build/apk" />
  <excludeFolder url="file://$MODULE_DIR$/build/assets" />
  <excludeFolder url="file://$MODULE_DIR$/build/bundles" />
  <excludeFolder url="file://$MODULE_DIR$/build/classes" />
  <excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" />
  <excludeFolder url="file://$MODULE_DIR$/build/incremental" />
  <excludeFolder url="file://$MODULE_DIR$/build/libs" />
  <excludeFolder url="file://$MODULE_DIR$/build/manifests" />
  <excludeFolder url="file://$MODULE_DIR$/build/res" />
  <excludeFolder url="file://$MODULE_DIR$/build/symbols" />
  <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v4-19.0.0" level="project" />
<orderEntry type="library" exported="" name="ComAndroidSupportAppcompatV71900.aar" level="project" />
<orderEntry type="library" exported="" name="FortumoInApp-android-9.1.0" level="project" />
</component>
       </module>
How to solve:

I found a solution in Android Studio, I go to “Build variants” and change it from debbug to release.

###

There’s a debuggable property you can set in a build type in your build.gradle file; that will supersede any setting in your manifest. You haven’t done anything there, have you? The debuggable property of your release build should already be false.

Which build are you trying to upload to Google Play? If you’re uploading the debug build, then that’s your problem — upload the release build instead.

###

You should not use the debug as BuildVariant to sign and export your apk in Google Play.

You should use the Release BuildVariant.
Gradle has some default values, as debuggable that you have to override in your build.gradle (these values override the properties in AndroidManifest).

Change your build.gradle, switch to Release as BuildVariant(on the left edge) and export your apk.

android {
    signingConfigs {
        release {
            storeFile file("horoskopSms.jks")
            storePassword "1q2w3e"
            keyAlias "horoskopSms"
            keyPassword "1q2w3e"
        }
   }
}

###

This is because you did not configure your gradle correctly. Please check this link please
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations

###

this code worked for me

change debuggable false and minifyEnabled false insted of true like below code in your app level build.gradle file

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        debuggable false
        signingConfig signingConfigs.firstapp
    }
}

###

On Android studio just Click build then choose Generate Signed Apk…enter your credentials and other info related to your app & then its done.

Leave a Reply

Your email address will not be published. Required fields are marked *