Android-Studio-1.2.RC Proguard warnings on Square's Okio library reference
Asked Answered
F

2

8

WIth Android Studio: 1.2.RC

I enabled proguard in .gradle: ```

minifyEnabled=true

and added these rules to my proguard-rules.pro:

-dontwarn com.squareup.**
-dontwarn okio.**

and added these lint rules to my .gradle file:

warningsAsErrors false
abortOnError false
disable 'InvalidPackage'

```

But I still get these warning when I try to run the app in debug mode:

```
Warning: okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Files
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class java.nio.file.Path
Warning: okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning: okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning: there were 14 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
:app:proguardDebug FAILED

```

It's so weird since I also added these rules/options to all my library modules that depend on OkHttp/Picasso, I don't know where went wrong, perhaps this is a Android Studio bug ? Does anyone have any clues to this problem ?

I have opened an issue on github.

Forethoughtful answered 27/4, 2015 at 3:51 Comment(1)
You can ignore these warnings. github.com/square/okio/issues/60Appulse
F
2

Oh Christ, I forgot to specify the proguard file for my debug build, adding the 'proguardFiles' rule would solve the problem:

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationIdSuffix ".debug"
        }
    }

One of those moments you searched hard for your keys and it's right in your pocket.

Forethoughtful answered 28/4, 2015 at 2:10 Comment(1)
same thing happened with me. my default proguard file name was 'proguard-android.txt' and I was writing rules in 'proguard-rules.pro'.Drastic
M
20

You've disable warnings for

-dontwarn com.squareup.**
-dontwarn okio.**

But what about for packages (as seen in your posted log)

-dontwarn org.codehaus
-dontwarn java.nio

Either way, ignoring warnings is not a good approach.

Try keeping these classes from being minified like so:

-keep public class org.codehaus.**
-keep public class java.nio.**
Mephitis answered 27/4, 2015 at 3:55 Comment(0)
F
2

Oh Christ, I forgot to specify the proguard file for my debug build, adding the 'proguardFiles' rule would solve the problem:

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationIdSuffix ".debug"
        }
    }

One of those moments you searched hard for your keys and it's right in your pocket.

Forethoughtful answered 28/4, 2015 at 2:10 Comment(1)
same thing happened with me. my default proguard file name was 'proguard-android.txt' and I was writing rules in 'proguard-rules.pro'.Drastic

© 2022 - 2024 — McMap. All rights reserved.