Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Roboguice proguard warning

I can't seem to compile without warnings. This is the warning:

Warning:roboguice.activity.RoboMapActivity: can't find superclass or interface com.google.android.maps.MapActivity
Warning:roboguice.activity.RoboSherlockActivity: can't find superclass or interface com.actionbarsherlock.app.SherlockActivity
Warning:roboguice.activity.RoboSherlockFragmentActivity: can't find superclass or interface com.actionbarsherlock.app.SherlockFragmentActivity
Warning:roboguice.activity.RoboSherlockListActivity: can't find superclass or interface com.actionbarsherlock.app.SherlockListActivity
Warning:roboguice.activity.RoboSherlockPreferenceActivity: can't find superclass or interface com.actionbarsherlock.app.SherlockPreferenceActivity
Warning:roboguice.activity.SherlockAccountAuthenticatorActivity: can't find superclass or interface com.actionbarsherlock.app.SherlockActivity
Warning:roboguice.fragment.RoboSherlockDialogFragment: can't find superclass or interface com.actionbarsherlock.app.SherlockDialogFragment
Warning:roboguice.fragment.RoboSherlockFragment: can't find superclass or interface com.actionbarsherlock.app.SherlockFragment
Warning:roboguice.fragment.RoboSherlockListFragment: can't find superclass or interface com.actionbarsherlock.app.SherlockListFragment
Warning:org.roboguice.shaded.goole.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning:org.roboguice.shaded.goole.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning:org.roboguice.shaded.goole.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning:roboguice.activity.RoboMapActivity: can't find referenced class com.google.android.maps.MapActivity
Warning:roboguice.activity.RoboMapActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class roboguice.activity.RoboMapActivity
Warning:roboguice.activity.RoboMapActivity: can't find referenced class com.google.android.maps.MapActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onRestart()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onStart()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onResume()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onPause()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onNewIntent(android.content.Intent)' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onStop()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onDestroy()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class roboguice.activity.RoboSherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onConfigurationChanged(android.content.res.Configuration)' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onContentChanged()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'void onActivityResult(int,int,android.content.Intent)' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'android.view.View onCreateView(java.lang.String,android.content.Context,android.util.AttributeSet)' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockAccountAuthenticatorActivity: can't find referenced method 'android.view.View onCreateView(android.view.View,java.lang.String,android.content.Context,android.util.AttributeSet)' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.RoboSherlockActivity: can't find referenced class com.actionbarsherlock.app.SherlockActivity
Warning:roboguice.activity.RoboSherlockActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class roboguice.activity.RoboSherlockActivity
Warning:roboguice.activity.RoboSherlockActivity: can't find referenced class com.actionbarsherlock.app.SherlockActivity
Warning:roboguice.activity.RoboSherlockFragmentActivity: can't find referenced class com.actionbarsherlock.app.SherlockFragmentActivity
Warning:roboguice.activity.RoboSherlockFragmentActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class roboguice.activity.RoboSherlockFragmentActivity
Warning:roboguice.activity.RoboSherlockFragmentActivity: can't find referenced class com.actionbarsherlock.app.SherlockFragmentActivity
Warning:roboguice.activity.RoboSherlockListActivity: can't find referenced class com.actionbarsherlock.app.SherlockListActivity
Warning:roboguice.activity.RoboSherlockListActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class roboguice.activity.RoboSherlockListActivity
Warning:roboguice.activity.RoboSherlockListActivity: can't find referenced class com.actionbarsherlock.app.SherlockListActivity
Warning:roboguice.activity.RoboSherlockPreferenceActivity: can't find referenced class com.actionbarsherlock.app.SherlockPreferenceActivity
Warning:roboguice.activity.RoboSherlockPreferenceActivity: can't find referenced method 'android.content.res.Resources getResources()' in program class roboguice.activity.RoboSherlockPreferenceActivity
Warning:roboguice.activity.RoboSherlockPreferenceActivity: can't find referenced class com.actionbarsherlock.app.SherlockPreferenceActivity
Warning:roboguice.activity.SherlockAccountAuthenticatorActivity: can't find referenced class com.actionbarsherlock.app.SherlockActivity
Warning:roboguice.activity.SherlockAccountAuthenticatorActivity: can't find referenced method 'android.content.Intent getIntent()' in program class roboguice.activity.SherlockAccountAuthenticatorActivity
Warning:roboguice.activity.SherlockAccountAuthenticatorActivity: can't find referenced class com.actionbarsherlock.app.SherlockActivity
Warning:roboguice.fragment.RoboSherlockDialogFragment: can't find referenced class com.actionbarsherlock.app.SherlockDialogFragment
Warning:roboguice.fragment.RoboSherlockDialogFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in program class roboguice.fragment.RoboSherlockDialogFragment
Warning:roboguice.fragment.RoboSherlockDialogFragment: can't find referenced class com.actionbarsherlock.app.SherlockDialogFragment
Warning:roboguice.fragment.RoboSherlockFragment: can't find referenced class com.actionbarsherlock.app.SherlockFragment
Warning:roboguice.fragment.RoboSherlockFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in program class roboguice.fragment.RoboSherlockFragment
Warning:roboguice.fragment.RoboSherlockFragment: can't find referenced class com.actionbarsherlock.app.SherlockFragment
Warning:roboguice.fragment.RoboSherlockListFragment: can't find referenced class com.actionbarsherlock.app.SherlockListFragment
Warning:roboguice.fragment.RoboSherlockListFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in program class roboguice.fragment.RoboSherlockListFragment
Warning:roboguice.fragment.RoboSherlockListFragment: can't find referenced class com.actionbarsherlock.app.SherlockListFragment
Warning:there were 118 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)
Warning:there were 22 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
:app:proguardAgmobileRelease FAILED

I tried adding Proguard required by actionarSherlock but it did not help. Is it safe to use --dontwarn if the project runs well in debug mode?

This is my Proguard file:

-target 1.6
-dontobfuscate
-dontoptimize
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-dump ../bin/class_files.txt
-printseeds ../bin/seeds.txt
-printusage ../bin/unused.txt
-printmapping ../bin/mapping.txt

# The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle.
-optimizations !code/simplification/arithmetic

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep class com.google.inject.Binder
-keepclassmembers class * {
    @com.google.inject.Inject <init>(...);
}
# There's no way to keep all @Observes methods, so use the On*Event convention to identify event handlers
-keepclassmembers class * {
    void *(**On*Event);
}
-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keep class roboguice.**
-keep class org.roboguice.**
-keep public class AnnotationDatabaseImpl
like image 915
JY2k Avatar asked Mar 29 '15 16:03

JY2k


1 Answers

Using only those lines in my Proguard file, I can hide the warning and compile my app.

Perhaps those lines can help someone else:

-dontwarn roboguice.**
-dontwarn org.roboguice.**
-keep class roboguice.** { *; }
-keep class org.roboguice.** { *; }

-keepattributes *Annotation*,Signature  
-keep class com.google.inject.Binder    
-keep public class com.google.inject.Inject
 # keeps all fields and Constructors with @Inject
-keepclassmembers,allowobfuscation class * {
    @com.google.inject.Inject <fields>;
    @com.google.inject.Inject <init>(...);
}

source :

How to make Proguard ignore external libraries?

Injection with google guice does not work anymore after obfuscation with proguard

like image 162
Tobliug Avatar answered Oct 06 '22 04:10

Tobliug