I want to release my app but in proguard step I face a problem. it Generate some warning when I add lobmok ( or be more specific when I add samsung-multiscreen jar file) as follows :
Warning:com.google.android.exoplayer.MediaCodecAudioTrackRenderer:
can't find referenced class android.media.PlaybackParams
Warning:com.google.android.exoplayer.audio.AudioTrack: can't find
referenced class android.media.PlaybackParams
Warning:com.google.android.exoplayer.audio.AudioTrack$AudioTrackUtil:
can't find referenced class android.media.PlaybackParams
Warning:com.google.android.exoplayer.audio.AudioTrack$AudioTrackUtilV23:
can't find referenced class android.media.PlaybackParams
Warning:com.google.android.exoplayer.audio.AudioTrack$AudioTrackUtilV23:
can't find referenced method 'void
setPlaybackParams(android.media.PlaybackParams)' in library class
android.media.AudioTrack
Warning:com.google.android.exoplayer.audio.AudioTrack$AudioTrackUtilV23:
can't find referenced class android.media.PlaybackParams
Warning:com.google.android.exoplayer.chunk.VideoFormatSelectorUtil:
can't find referenced method 'android.view.Display$Mode getMode()' in
library class android.view.Display
Warning:com.google.android.exoplayer.chunk.VideoFormatSelectorUtil:
can't find referenced class android.view.Display$Mode
When I add following line to proguard-rules.pro some of the them disappeared but When I launch to the application it crash.
-dontwarn lombok.**
Also try this :
-keep class com.google.android.exoplayer.** { *; }
I think it raise due to conflict between annotation used in exoplayer and multiscreen (lombok)
does anyone knows how to fix this issue ?
Finally I fixed this issue with following proguard-rule:
-ignorewarnings
-dontoptimize
-dontobfuscate
-dontskipnonpubliclibraryclasses
-ignorewarnings
-keep class com.samsung.** { *; }
-dontwarn com.samsung.**
-dontwarn com.samsung.multiscreen.BuildConfig
-dontwarn lombok.**
Related
When I export a signed apk, the following error is shown:
Proguard returned with error code 1. See console
Warning: com.google.android.gms.internal.zzaj: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzak
Warning: com.google.android.gms.internal.zzak: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzak
Warning: com.google.android.gms.internal.zzar: can't find referenced class android.net.http.AndroidHttpClient
Is it safe to just add these Proguard rules:
-keep class android.net.http.AndroidHttpClient
-dontwarn android.net.http.AndroidHttpClient
Or do I also have to include org.apache.http.legacy.jar in the project?
Add this line to your proguard. It will not affect anything in your code
-dontwarn org.apache.http.**
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.*
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
gradle 1.10 on linux on CLI
./gradlew clean
./gradlew assembleRelease
ERROR in stdout...
Note: there were 2 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 5 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 106 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
:proguardRelease FAILED
:proguardRelease (Thread[main,5,main]) completed. Took 4.689 secs.
FAILURE: Build failed with an exception.
I extend an oss package bundled with gradle for release builds ( added jackson.json but not from maven central ).
For some reason, proguard is throwing hundreds of 'org.joda.time... class not found' errors despite the following snips:
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
} // in 'build.gradle'
-dontwarn android.support.**
-dontwarn org.joda.time.**
-dontwarn org.codehaus.jackson.**
-dontwarn ch.boye.httpclientandroidlib.**
-dontwarn org.apache.http.**
-dontwarn android.**
-dontwarn java.**
-dontwarn com.google.sample.castcompanionlibrary.**
-dontwarn org.w3c.dom.**
-dontwarn com.google.android.gms.maps.**
#rcr adds
-libraryjars /usr/local/src/android-sdk-linux/platforms/android-19/android.jar
-libraryjars <java.home>/lib/rt.jar
-libraryjars libs/jackson-core-lgpl-1.9.2.jar
-libraryjars libs/jackson-mapper-lgpl-1.9.2.jar
-libraryjars libs/Parse-1.1.3.jar
-libraryjars libs/httpclient-1.1.jar
stdout DETAIL from './gradlew assembleRelease' below:
Initializing...
Note: the configuration refers to the unknown class 'com.google.vending.licensing.ILicensingService'
Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService'
Note: the configuration refers to the unknown class 'Object'
Maybe you meant the fully qualified name 'java.lang.Object'?
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.DOMSerializer: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableDateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers: can't find referenced class org.joda.time.ReadableInstant
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateTime
Warning: org.codehaus.jackson.map.ext.JodaDeserializers$DateMidnightDeserializer: can't find referenced class org.joda.time.DateMidnight
Warn
... 100s more in 'org.joda.time.**'
Note: android.support.v4.text.ICUCompatIcs: can't find dynamically referenced class libcore.icu.ICU
Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImplGmm6
Note: com.google.android.gms.maps.internal.q: can't find dynamically referenced class com.google.android.gms.maps.internal.CreatorImpl
Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentNavigableMap
Note: org.codehaus.jackson.map.deser.BasicDeserializerFactory: can't find dynamically referenced class java.util.ConcurrentSkipListM
The -dontwarn proguard configs for 'org.joda.**' dont seem to work..
I have "-dontnote **ILicensingService" in config and that does not appear to work.
The -dontwarn config for com.google.android.gms.** not working
The -dontwarn for java.util.** not working
In what file is your "snippet" with the -dontwarn flags? It doesn't look like you're ever telling your build.gradle file about that proguard configuration.
You have:
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
But you should also have:
proguardFile 'your_proguard_config.cfg'
so that it will use both the default android configuration and your configuration.
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.