简体   繁体   中英

Proguard line number issue

I got a wried issue with the proguard. In my proguard-rules.pro , I already setup keep line number:

# Keep line numbers
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

And in my build.gradle , I open the minifyEnable both debug and release :

buildTypes {
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'google-api-client.pro'

            signingConfig signingConfigs.debug

            ndk {
                abiFilters "armeabi-v7a", "arm64-v8a"
            }
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'google-api-client.pro'

            signingConfig signingConfigs.release

            ndk {
                abiFilters "armeabi-v7a", "arm64-v8a"
            }
        }
    }

But when I get a crash, the Debug output line number is correct, but the release line number is error. Here is the logs of debug with minifyEnable , the line number is correct:

java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference
        at com.frontrow.vlog.ui.personalpage.PersonalPageFragment.musicClicked(SourceFile:952) // The line number is the right position at my source code.
        at com.frontrow.vlog.ui.personalpage.PersonalPageFragment_ViewBinding$e.a(SourceFile:244)
        at butterknife.internal.b.onClick(SourceFile:18)

But it's error that the line number is not correct at the release with the minifyEnable :

java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference
        at com.frontrow.vlog.ui.personalpage.PersonalPageFragment.musicClicked(SourceFile:1) // The line number is error.
        at com.frontrow.vlog.ui.personalpage.PersonalPageFragment_ViewBinding$e.a(SourceFile:1)
        at butterknife.internal.b.onClick(SourceFile:4)

How can I fix this that the release output can take the right line number?

Well, I figure out that is R8 issue. I setup android.enableR8=false in the gradle.properties and the line number is correct. It seems the gradle version large than 3.4.0 it will open the r8 by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM