How to debug apk signed for release?

前端 未结 6 1031
走了就别回头了
走了就别回头了 2020-11-27 12:17

I have an apk which I\'ve signed and uploaded to Android Market, and installed on my phone. I would like to debug this release apk (by means of Eclipse) whilst it is running

相关标签:
6条回答
  • 2020-11-27 12:37

    In case of you decided the debug your apk which is already in market but not assigned to be debuggable and you do not want to publish it again. So follow the below steps;

    1. Decompile the Apk with ApkTool(eg. apktool d <APK_PATH>)
    2. Open the AndroidManifest.xml from decompiled files
    3. Set android:debuggable="true" in application tag
    4. Compile the modified source with ApkTool (eg. apktool b <MODIFIED_PATH>)
    5. Debuggable apk ready(which unsigned means cannot publish store). You can debug as you wish.
    0 讨论(0)
  • 2020-11-27 12:38

    I tried with the following and it's worked:

    release {
                debuggable true
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
    
    0 讨论(0)
  • 2020-11-27 12:43

    Add the following to your app build.gradle and select the specified release build variant and run

    signingConfigs {
            config {
                keyAlias 'keyalias'
                keyPassword 'keypwd'
                storeFile file('<<KEYSTORE-PATH>>.keystore')
                storePassword 'pwd'
            }
        }
        buildTypes {
          release {
              debuggable true
              signingConfig signingConfigs.config
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    
    0 讨论(0)
  • 2020-11-27 12:45

    Besides Manuel's way, you can still use the Manifest.

    In Android Studio stable, you have to add the following 2 lines to application in the AndroidManifest file:

        android:debuggable="true"
        tools:ignore="HardcodedDebugMode"
    

    The first one will enable debugging of signed APK, and the second one will prevent compile-time error.

    After this, you can attach to the process via "Attach debugger to Android process" button.

    0 讨论(0)
  • 2020-11-27 12:59

    I know this is old question, but future references. In Android Studio with Gradle:

    buildTypes {
        release {
            debuggable true
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    

    The line debuggable true was the trick for me.

    Update:

    Since gradle 1.0 it's minifyEnabled instead of runProguard. Look at here

    0 讨论(0)
  • 2020-11-27 13:01

    Be sure that android:debuggable="true" is set in the application tag of your manifest file, and then:

    1. Plug your phone into your computer and enable USB debugging on the phone
    2. Open eclipse and a workspace containing the code for your app
    3. In Eclipse, go to Window->Show View->Devices
    4. Look at the Devices view which should now be visible, you should see your device listed
    5. If your device isn't listed, you'll have to track down the ADB drivers for your phone before continuing
    6. If you want to step through code, set a breakpoint somewhere in your app
    7. Open the app on your phone
    8. In the Devices view, expand the entry for your phone if it isn't already expanded, and look for your app's package name.
    9. Click on the package name, and in the top right of the Devices view you should see a green bug along with a number of other small buttons. Click the green bug.
    10. You should now be attached/debugging your app.
    0 讨论(0)
提交回复
热议问题