Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard Note for unknown class 'Object' with Android Studio and Gradle

I've created a new project in Android Studio and am using Gradle to build it.

I've added my Proguard integration for release builds, and I am seeing this Note every time I run my assembleRelease step:

Note: the configuration refers to the unknown class 'Object'
      Maybe you meant the fully qualified name 'java.lang.Object'?

None of my Proguard configuration files, or the ones in the Android SDK folder include an unqualified name Object.

My build.gradle includes:

buildTypes {
    release {
        runProguard true
        proguardFile 'proguard-project.txt'
        proguardFile getDefaultProguardFile('proguard-android-optimize.txt')

        signingConfig signingConfigs.release
    }
}

I even see the same Note when I remove both the proguardFile lines above, and also if I delete my custom Proguard rules (each time doing a clean before rebuilding).

I'm guessing this is a benign issue with the Proguard plugin for Gradle?

like image 423
Dan J Avatar asked Nov 22 '13 01:11

Dan J


2 Answers

Thanks for the suggestion Eric Lafortune! Adding -printconfiguration to my proguard.txt revealed that the problem was in the google-play-services_lib (r13).

The guilty Proguard rule is (it should be java.lang.Object[][]):

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

You can see this on a Mac by right clicking on Android Studio, do Show Package Contents, then browse to sdk/extras/google/google_play_services/libproject/google-play-services_lib/proguard.txt.

The quickest workaround is to add the correct Proguard rule into your own Proguard configuration and just ignore the Proguard Note.

-keep class * extends java.util.ListResourceBundle {
    protected java.lang.Object[][] getContents();
}

I raised this bug with Google as Android Issue #63095.

like image 66
Dan J Avatar answered Oct 16 '22 18:10

Dan J


I'm not aware of any unqualified references to Object in the Android SDK, but you could specify the option -printconfiguration config.txt to write out the complete configuration and look for the reference. It could be a method argument or a return value, which is easy to overlook.

like image 33
Eric Lafortune Avatar answered Oct 16 '22 18:10

Eric Lafortune