no line numbers (e.g. for Log.getStackTraceString) with Jack compiler

225 Views Asked by At

We've switched over to the Jack compiler for our Android app to take advantage of Java8 features. However when we enabled minification (minifyEnabled true) we saw our app crashing in seemingly random places (it was all working fine with old javac+proguard+dex).

To save time for now we decided to disable minification but now the problem we run into now is that our error reporting library reports all callstacks as unknown line numbers. I've also confirmed that we get the same broken stack trace with Log.getStackTraceString

E.g.

com.foo.android.bar: XXX
 at com.foo.android.bar.quax(Unknown Source)

The only thing that seems to give us our callstack back is to enable debug (debuggable true) but we can't submit our app like that into the store.

Any ideas?

1

There are 1 best solutions below

0
On

It turns out that the Gradle plugin drives Jack as follows:

if debug build keep source+line information
if non-debug strip all source+line information

to work around this you can explicitly ask Jack to keep source/line info like so (in your gradle file):

jackOptions {
    enabled true
    additionalParameters(
        "jack.dex.debug.lines": "true",
        "jack.dex.debug.source": "true")
}

Note: that the value of the argument MUST be a string!

You can get all valid parameters Jack supports like this:

java -jar <SDK>/build-tools/<build-tools-version>/jack.jar --help-properties

some more info (https://code.google.com/p/android/issues/detail?id=228093)