user1159819
user1159819

Reputation: 1679

Troubleshooting Android R8 Build

I need help figuring out the issue when building my app with R8. I have a service that performs a job and then terminates. However when I use R8 instead of Proguard, the service never terminates. The only way to make the R8 build work is to leave in the android.util.Log class, specifically comment out the bit:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** d(...);
    public static *** i(...);
    public static *** w(...);
    public static *** e(...);
}

Can anyone shed some light on what it is R8 is doing that is causing this behavior or to steer me in the right direction? Or is the issue with the assumenosideeffects snippet?

Upvotes: 1

Views: 1731

Answers (1)

Jaimil Patel
Jaimil Patel

Reputation: 1347

It seems like some important code has been removed by R8 when you build your project. Please add -printusage {output-dir}/usage.txt to your proguard-rules.pro file then build the project and after that check the file usage.txt - it contains a report about removed code. Now you can try with some more custom keep rules to resolve this issue.

Please reffer this blog for R8 https://medium.com/better-programming/shrink-your-android-app-with-r8-afe17c4d393

Upvotes: 1

Related Questions