tslocum
tslocum

Reputation: 3422

Why is ProGuard suddenly unable to compile my application?

I've been using Android Studio since the initial release without any ProGuard issues. Suddenly today it has stopped working. As far as I know any files which would interfere with Proguard have not changed. For instance my ProGuard config file remains untouched, and ActionBarSherlock (one of the modules now experiencing errors) was not changed in any way since the last successful build.

The error log recommended using -dontskipnonpubliclibraryclassmembers however that does not resolve the issue. Running ProGuard with the included default configuration rather than my own still results in the same errors.

From what I can make of it, when Android Studio is building my app, the modules are now being stripped from the app. I'm not sure if it's just not passing the appropriate flags to ProGuard or if Proguard is removing them on its own.

Some relevant logs:

ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.content.Context mContext' in class com.actionbarsherlock.widget.SuggestionsAdapter
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced method 'android.database.Cursor getCursor()' in class com.actionbarsherlock.widget.SuggestionsAdapter
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.database.Cursor mCursor' in class com.actionbarsherlock.widget.SuggestionsAdapter
--snip--
ProGuard: [Meditation Assistant]       You should check if you need to specify additional program jars.
ProGuard: [Meditation Assistant] Warning: there were 10 unresolved references to classes or interfaces.
ProGuard: [Meditation Assistant]          You may need to specify additional library jars (using '-libraryjars').
ProGuard: [Meditation Assistant] Warning: there were 191 unresolved references to program class members.

Upvotes: 1

Views: 1410

Answers (2)

Eric Lafortune
Eric Lafortune

Reputation: 45686

The message

Warning: there were 10 unresolved references to classes or interfaces.

suggests that ProGuard can't find some classes that are required. These classes are listed in ProGuard's earlier console output. You should check that all the necessary jars are in the directory 'libs'. In this case, android-support-v4.jar might be missing.

Upvotes: 1

Ruben
Ruben

Reputation: 1

I solved it adding the following line to proguard-project.txt:

-libraryjars libs/android-support-v4.jar

In case of using Eclipse do not forget to clean the project before exporting the APK.

Upvotes: 0

Related Questions