2

I want to run the debugger in Android but my issue is in debug build I have proguard on. The reason for this is the stupid 65K method limit. I turned on proguard to help with reducing the methods. This gets me back to 43K methods but now in the IDE I cannot debug stepping through code as all the breakpoints in the IDE turn into red X's with error saying unreachable code. If I close the debugger the breakpoint turns back to normal. Is there something I need to do in the build gradle proguard to get this to work or am I just hosed?

buildTypes {
    debug {
        debuggable true
        minifyEnabled  true
        shrinkResources false
        zipAlignEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        signingConfig signingConfigs.debug
    }
    release {
        minifyEnabled  true
        shrinkResources true
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-samsung.txt'
    }
}
JPM
  • 9,077
  • 13
  • 78
  • 137
  • do you have any unused libraries? what are your dependencies? can you strip some of your unused parts of your libraries? want to help you reduce your size! – apollosoftware.org Apr 08 '16 at 19:14
  • Lots of third party stuff with useless stuff, we've reduced as much for as long as we could now we are up against a wall. – JPM Apr 08 '16 at 19:44
  • we had the same issue. our culprit that sent the method count above 65K was google play. we actually had to use an older version of google play build (with less fluff) and it brought us down below the threshold. you may have to break your APK into a few separate modular components. – apollosoftware.org Apr 08 '16 at 19:46
  • @ApolloSoftware so what do you mean break down into modules? Could you expand on that? – JPM Apr 08 '16 at 21:03
  • Well our product was very compartmentalized. We had 3 separate apks. One that did the registration portion, one that handled security strictly, being a service (no visible activity) then finally an apk that did strictly presentation and tied the other two apks together. A more popular example is what facebook did with Messenger, and the main Facebook app. The information between one another is passed through intents, essentially. Also if you want you can set the sharedUserLabel and sharedUserId in the AndroidManifest.xml file to the same value. You essentially use the same linux user account. – apollosoftware.org Apr 08 '16 at 23:55
  • Same linux account means you can share files across the two apks. – apollosoftware.org Apr 08 '16 at 23:57

1 Answers1

4

Your ProGuard config probably misses some clauses.

I guess you need this:

-keepattributes SourceFile,LineNumberTable

It will keep (as the name suggests) name of the source files and line number table. Actually, this clause should be used also for release because you can't unambiguously deobfuscate stacktraces without it.

And for debugging it's good to have this extra clause:

-keepattributes LocalVariableTable,LocalVariableTypeTable

That will keep local variable names.

Alternatively, you can consider using these clauses (instead or besides the previous clauses) for debug:

-dontoptimize
-dontobfuscate
Tomik
  • 23,857
  • 8
  • 121
  • 100