GoogleAnalyticsV2 and Proguard - android

I use Google Analytics V2 library in my project.
When I export signed application package from Eclipse I get following output in Console:
Proguard returned with error code 1. See console
Warning: com.google.analytics.tracking.android.FutureApis: can't find referenced method 'boolean setReadable(boolean,boolean)' in class java.io.File
Warning: com.google.analytics.tracking.android.FutureApis: can't find referenced method 'boolean setWritable(boolean,boolean)' in class java.io.File
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
Here's my proguard.cfg
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontwarn android.support.**
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-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 public class com.android.vending.licensing.ILicensingService
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
If I add -dontwarn com.google.analytics.tracking.android.FutureApis to config then I get
at proguard.ProGuard.main(ProGuard.java:492)
Proguard returned with error code 1. See console
You should check if you need to specify additional program jars.
Unexpected error while evaluating instruction:
Class = [android/support/v4/view/AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl]
Method = [newAccessiblityDelegateBridge(Landroid/support/v4/view/AccessibilityDelegateCompat;)Ljava/lang/Object;]
Instruction = [18] areturn
Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate]))
Unexpected error while performing partial evaluation:
Class = [android/support/v4/view/AccessibilityDelegateCompat$AccessibilityDelegateJellyBeanImpl]
Method = [newAccessiblityDelegateBridge(Landroid/support/v4/view/AccessibilityDelegateCompat;)Ljava/lang/Object;]
Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate]))
java.lang.IllegalArgumentException: Can't find any super classes of [android/support/v4/view/AccessibilityDelegateCompatIcs$1] (not even immediate super class [android/view/View$AccessibilityDelegate])
at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:287)
at proguard.evaluation.value.IdentifiedReferenceValue.generalize(IdentifiedReferenceValue.java:65)
at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:481)
at proguard.optimize.info.MethodOptimizationInfo.generalizeReturnValue(MethodOptimizationInfo.java:247)
at proguard.optimize.evaluation.StoringInvocationUnit.generalizeMethodReturnValue(StoringInvocationUnit.java:195)
at proguard.optimize.evaluation.StoringInvocationUnit.setMethodReturnValue(StoringInvocationUnit.java:126)
at proguard.evaluation.BasicInvocationUnit.exitMethod(BasicInvocationUnit.java:134)
at proguard.evaluation.Processor.visitSimpleInstruction(Processor.java:514)
at proguard.classfile.instruction.SimpleInstruction.accept(SimpleInstruction.java:218)
at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:753)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:587)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:560)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:264)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:181)
at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101)
at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:79)
at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95)
at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:91)
at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:71)
at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:504)
at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:346)
at proguard.classfile.ClassPool.classesAccept(ClassPool.java:116)
at proguard.optimize.Optimizer.execute(Optimizer.java:372)
at proguard.ProGuard.optimize(ProGuard.java:306)
at proguard.ProGuard.execute(ProGuard.java:115)
at proguard.ProGuard.main(ProGuard.java:492)
Any hints?

I've also faced this problem. As there's no official solution in the GA documentation yet, I made up this set of rules:
-keep class com.google.android.gms.analytics.**
-keep class com.google.analytics.tracking.**
-dontwarn com.google.android.gms.analytics.**
-dontwarn com.google.analytics.tracking.**
This skips obfuscation as well, but that should not be a problem for an external libary..

The initial warning indicates that FutureApis invokes File#setReadable(boolean,boolean), which doesn't exist on the target platform that you have specified for your build (apparently android-8 or older). ProGuard can ignore it, but it will be a problem if that code is ever executed on those older platforms. The documentation of Google Analytics specifies that android-7 is sufficient, so presumably ignoring it is fine.
The unexpected error indicates that V4 support class AccessibilityDelegateCompatIcs$1 extends Android class View$AccessibilityDelegate, which doesn't exist on the target platform that you have specified for your build (android-13 or older). In this case, ProGuard really needs that class to properly process the code. With an incomplete class hierarchy, the output would be a mess.
You can solve both problems by specifying a more recent build target in project.properties when compiling your release version. The missing classes and methods will be present in the corresponding android.jar, so ProGuard will have all the information it needs. Since these classes are just runtime library classes, used for compilation/optimization/obfuscation, they won't affect the output.

I ran into the same problem - I was able to suppress errors when creating ank for release - but when the application it falls, in those places where the classes to which swearing obfuscator. At the moment I have not solved this problem. What is interesting is that in debage mode when running the application through Eclipse - and it works perfectly.

Related

proguard issue in Gradle

I am trying build my APP I am getting the following error: All this time App used to generate the build properly.
After I upgraded my compileSdkVersion and build to 23, GMS to 8.1, AsyncHttpclient to 1.4.9. I am getting the following error.
Not sure what to do:
Warning:com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.google.android.gms.internal.zzw: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzw$zza
Warning:com.google.android.gms.internal.zzw$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzw$zza
Warning:there were 2 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 2 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:proguardRelease FAILED
Error:Execution failed for task ':app:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.
What could be wrong here?
If you havent added command in progruard yet then add.
-keep class com.google.android.gms.maps.** { *; }
-keep interface com.google.android.gms.maps.** { *; }
If you are using map you should check developer site. There is proguard in it already.
For map you may need to add below code. if you havent added.
# The Maps API uses custom Parcelables.
# Use this rule (which is slightly broader than the standard recommended one)
# to avoid obfuscating them.
-keepclassmembers class * implements android.os.Parcelable {
static *** CREATOR;
}
# The Maps API uses serialization.
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-dontwarn com.google.android.maps.GeoPoint
-dontwarn com.google.android.maps.MapActivity
-dontwarn com.google.android.maps.MapView
-dontwarn com.google.android.maps.MapController
-dontwarn com.google.android.maps.Overlay
-dontwarn com.google.android.gms.maps.model.*

Google Play Services v23 Proguard configuration

After upgrading to Google Play services v23, I see this message when trying to export signed application in Eclipse:
Proguard returned with error code 1. See console
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller$SessionInfo
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller$SessionInfo
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'android.content.pm.PackageInstaller getPackageInstaller()' in class android.content.pm.PackageManager
Warning: com.google.android.gms.internal.zzif: can't find referenced method 'void setMixedContentMode(int)' in class android.webkit.WebSettings
You should check if you need to specify additional program jars.
Warning: there were 4 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
I added this, as specified in documentation
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
-keepnames #com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
#com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
and tried adding
-keep class android.content.pm.PackageInstaller.**
to proguard-project.txt, but this didnt help.
What am I missing?
hey i had the exact same error i fixed it by adding :
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
to my proguard.cfg
I have the same problem, but using Android Studio. Based on Lary Ciminera's solution, I added
-dontwarn com.google.android.gms.**
to proguard-project.txt.
I fixed it by adding this to proguard-project.txt:
-keep class android.content.pm.PackageInstaller
-keep class android.content.pm.PackageInstaller$SessionInfo
-keep class android.content.pm.PackageManager
-dontwarn android.content.pm.PackageInstaller
-dontwarn android.content.pm.PackageInstaller$SessionInfo
-dontwarn android.content.pm.PackageManager
-keep class android.webkit.WebSettings
-dontwarn android.webkit.WebSettings
Upgrading your target SDK version to at least 21 should fix this problem. PackageInstaller and the associated classes were added in API version 21: https://developer.android.com/reference/android/content/pm/PackageInstaller.html

Exclude Java SE library from Android proguard

In Android, I have proguard with the following settings.
-dontpreverify
# Hold onto the mapping.text file, it can be used to unobfuscate stack traces in the developer console using the retrace tool
-printmapping mapping.txt
# Keep line numbers so they appear in the stack trace of the develeper console
-keepattributes SourceFile,LineNumberTable
# The -optimizations option disables some arithmetic simplifications that Dalvik 1.0 and 1.5 can't handle.
-optimizations !code/simplification/arithmetic
# Activities, services and broadcast receivers are specified in the manifest file so they won't be automatically included
-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
# Custom view components might be accessed from your layout files
-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*(...);
}
# event handlers can be specified in the layout files e.g. android:onClick="nextButton_onClick", I borrowed this method name notation from .NET
-keepclassmembers class * extends android.app.Activity {
public void *_*(android.view.View);
}
# Parcelable implementations are accessed by introspection
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
# You might want to keep your annotations
-keepattributes *Annotation*
# I use Google Guava in my app
# see http://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava
-libraryjars libs/google/jsr305-1.3.9.jar;libs/pinyin4j/pinyin4j-2.5.0.jar
-dontwarn sun.misc.Unsafe
-keepclasseswithmembers class com.google.common.base.internal.Finalizer{
<methods>;
}
Some of my library, are directly imported from Java SE (Contains JApplet for example)
How I can exclude them from proguard? Note, I have pinyin4j-2.5.0.jar library in -libraryjars. I thought that's the way to tell proguard, "Hey, this is a library. Don't do anything on it, OK?" But, seems like proguard still trying to process pinyin4j-2.5.0.jar
I'm getting the following errors.
Note: there were 125 duplicate class definitions.
Warning: demo.Pinyin4jAppletDemo: can't find superclass or interface javax.swing.JApplet
Warning: demo.Pinyin4jAppletDemo$1: can't find superclass or interface java.awt.event.WindowAdapter
Warning: demo.Pinyin4jAppletDemo$2: can't find superclass or interface java.awt.event.ActionListener
Warning: demo.Pinyin4jAppletDemo$3: can't find superclass or interface java.awt.event.ActionListener
Warning: org.jasypt.encryption.pbe.PBEBigDecimalCleanablePasswordEncryptor: can't find superclass or interface org.jasypt.encryption.pbe.PBEBigDecimalEncryptor
Warning: org.jasypt.encryption.pbe.PBEBigIntegerCleanablePasswordEncryptor: can't find superclass or interface org.jasypt.encryption.pbe.PBEBigIntegerEncryptor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyDescriptor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyDescriptor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditorManager
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyDescriptor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.IntrospectionException
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyEditor
Warning: au.com.bytecode.opencsv.bean.CsvToBean: can't find referenced class java.beans.PropertyDescriptor
...
...
Warning: org.jasypt.normalization.Normalizer: can't find referenced class com.ibm.icu.text.Normalizer$Mode
You should check if you need to specify additional program jars.
Warning: there were 333 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Warning: there were 6 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
Error: Please correct the above warnings first.
Some of you may comment that for library jars which contain Java SE only methods (like Applet, Swing, ...) cannot be used in Android. Nope. In fact, they run perfectly fine, as long as you consume their non-Java SE-only methods.
The full error log can be downloaded from here : https://www.dropbox.com/s/dns62f7gp6unusg/error-log.txt
If you are sure that these Java SE classes are not used, you can indeed ignore the warnings (as you have found in your own answer). An easier way to specify this:
-dontwarn java.beans.**
-dontwarn java.awt.**
-dontwarn javax.swing.**
See ProGuard manual > Troubleshooting > Warning: can't find referenced class
Similar questions with always the same answer:
Using Proguard to Obfuscate Android App with Dropbox.com Libraries
Mobclix and Proguard
Using ProGuard with Android
Proguard tells me 'Please correct the above warnings first.
proguard hell - can't find referenced class
ProGuard with maven-android-plugin
...
Example to keep java runtime (rt.jar)
<libraryjar file="${java.home}/lib/rt.jar" />
It seems that your line
-libraryjars libs/google/jsr305-1.3.9.jar;libs/pinyin4j/pinyin4j-2.5.0.jar
is not complete.
Update
But since the needed classes do not exist on android, you have to ignore these warnings.
But do not generally ignore obfuscation warnings, we had a serious bug (using an obfuscation.map in file), because we ignored all warnings.
I merely avoid the error by
-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue
-dontwarn javax.swing.**
-dontwarn java.awt.**
-dontwarn org.jasypt.encryption.pbe.**
-dontwarn java.beans.**
-dontwarn org.joda.time.**
-dontwarn com.google.android.gms.**
-dontwarn org.w3c.dom.bootstrap.**
-dontwarn com.ibm.icu.text.**
-dontwarn demo.**
Here's the complete proguard configuration
-optimizationpasses 1
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
#-dontobfuscate
-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue
-dontwarn javax.swing.**
-dontwarn java.awt.**
-dontwarn org.jasypt.encryption.pbe.**
-dontwarn java.beans.**
-dontwarn org.joda.time.**
-dontwarn com.google.android.gms.**
-dontwarn org.w3c.dom.bootstrap.**
-dontwarn com.ibm.icu.text.**
-dontwarn demo.**
# Hold onto the mapping.text file, it can be used to unobfuscate stack traces in the developer console using the retrace tool
-printmapping mapping.txt
# Keep line numbers so they appear in the stack trace of the develeper console
-keepattributes *Annotation*,SourceFile,LineNumberTable
-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 public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
# https://sourceforge.net/p/proguard/discussion/182456/thread/e4d73acf
-keep class org.codehaus.** { *; }
-assumenosideeffects class android.util.Log {
public static int d(...);
public static int i(...);
public static int e(...);
public static int v(...);
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}
# I use Google Guava in my app
# see http://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava
-libraryjars libs/google/jsr305-1.3.9.jar
-keepclasseswithmembers class com.google.common.base.internal.Finalizer{
<methods>;
}
It doesn't work completely out of box yet as I still experience crash in "after proguard generated" APK.
Is pretty hard for me to find out why it crashes, as the code is obfuscate.
If I specific dontobfuscate, I will get another set of problem during generation. A message "Conversion to Dalvik format failed with error 1" pop up without additional information. But, that's another set of different problem.

Proguard runtime error with external Admob jar

signed app gives error!
my app uses an external Admob jar, however proguard is touching the jar:
the jar file is located at /libs/GoogleAdMobAdsSdk-6.2.1.jar
Thank you
LogCat error:
Proguard returned with error code 1. See console
Warning: com.google.ads.m: can't find referenced class
com.google.ads.internal.state.AdState
Warning: com.google.ads.m: can't find referenced class com.google.ads.internal.state.AdState
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
which is inside the jar-file
Config proguard-project.txt:
-libraryjars /libs/GoogleAdMobAdsSdk-6.2.1.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-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 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*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
after adding
-keep public class com.google.ads.**
to the file, the eclipse console gives still the following error:
Proguard returned with error code 1. See console
Note: there were 160 duplicate class definitions.
Warning: com.google.ads.m: can't find referenced class
com.google.ads.internal.state.AdState
Warning: com.google.ads.m: can't find referenced class
com.google.ads.internal.state.AdState
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
I just added the
-dontwarn com.google.ads.**
to the proguard-project.txt file and the signed apk works fine!
this is recommended (like Eric said before) here: Proguard can't find referenced class com.google.ads.internal.state.AdState
This worked for me on It seems that you need to add these 2 items to the proguard config :
-dontwarn com.google.ads.**
-keep class com.google.ads.** {*;}
-dontwarn com.google.ads.**
here secure the ads class
if you want to secure your class then add com.pkgname.**

Obfuscating Android app with CORBA

It so fell out that I use jacorb.jar and CORBA interfaces in my android app. And when I try obfuscate code using Proguard I get a lot of warnings like this one:
[proguard] Warning: org.jacorb.orb.standardInterceptors.SASComponentInterceptor: can't find referenced
class org.ietf.jgss.Oid
And as the result:
[proguard] Warning: there were 1223 unresolved references to classes or interfaces.
[proguard] You may need to specify additional library jars (using '-libraryjars'),
[proguard] or perhaps the '-dontskipnonpubliclibraryclasses' option.
[proguard] Warning: there were 33 unresolved references to program class member
s.
[proguard] Your input classes appear to be inconsistent.
[proguard] You may need to recompile them and try again.
[proguard] Alternatively, you may have to specify the options
[proguard] '-dontskipnonpubliclibraryclasses' and/or
[proguard] '-dontskipnonpubliclibraryclassmembers'.
My proguard.cfg :
-injars bin/classes
-outjars bin/classes-processed.jar
-libraryjars C:/android-sdk-windows/platforms/android-7/android.jar
-libraryjars libs
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontnote
-keep class com.android.vending.billing.**
-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 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*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
How to correct these warnings and build working apk file?
Cfr. ProGuard manual > Troubleshooting > Warning: can't find superclass or interface.
Jacorb appears to depend on JGSS, which is not part of the Android runtime. In theory, JGSS should be specified as a library package. However, since your app already runs fine without JGSS, it's fair to assume that this part of the code is never used. You can then switch off the warnings:
-dontwarn org.ietf.jgss.**
ProGuard will no longer complain about these missing classes and proceed with processing the code. The summary in your console output suggests that there are many classes that are probably similar.

Categories

Resources