This question already have been asked many times, but I am not able to resolve it. I am trying to export my app using eclipse for final release, but I am getting the below error.
I already added
-keep class com.afollestad.materialdialogs.*{ *; }
-dontwarn com.afollestad.materialdialogs.**
-dontshrink
Error resolved, but after running my app crashed.
please help me
this is the error:
Proguard returned with error code 1. See console
Warning: com.afollestad.materialdialogs.util.DialogUtils: can't find referenced method 'android.content.res.ColorStateList getColorStateList(int)' in class android.content.Context
Warning: com.afollestad.materialdialogs.util.DialogUtils: can't find referenced method 'int getColor(int)' in class android.content.Context
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)
Related
Can't build an Android demo with Bazel when proguard_specs is enable.
Error log:
...
Warning: kotlinx.coroutines.flow.internal.ChannelFlowMerge$collectTo$$inlined$collect$1$lambda$1: can't find enclosing method 'java.lang.Object emit$$forInline(java.lang.Object,kotlin.coroutines.Continuation)' in program class kotlinx.coroutines.flow.internal.ChannelFlowMerge$collectTo$$inlined$collect$1
Warning: kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1$1: can't find enclosing method 'java.lang.Object emit$$forInline(java.lang.Object,kotlin.coroutines.Continuation)' in program class kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1
Warning: kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1$lambda$1: can't find enclosing method 'java.lang.Object emit$$forInline(java.lang.Object,kotlin.coroutines.Continuation)' in program class kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$invokeSuspend$$inlined$collect$1
Warning: kotlinx.coroutines.flow.internal.CombineKt$zipImpl$$inlined$unsafeFlow$1$lambda$1: can't find enclosing method 'java.lang.Object collect$$forInline(kotlinx.coroutines.flow.FlowCollector,kotlin.coroutines.Continuation)' in program class kotlinx.coroutines.flow.internal.CombineKt$zipImpl$$inlined$unsafeFlow$1
Warning: kotlinx.coroutines.flow.internal.FlowCoroutineKt$scopedFlow$$inlined$unsafeFlow$1$lambda$1: can't find enclosing method 'java.lang.Object collect$$forInline(kotlinx.coroutines.flow.FlowCollector,kotlin.coroutines.Continuation)' in program class kotlinx.coroutines.flow.internal.FlowCoroutineKt$scopedFlow$$inlined$unsafeFlow$1
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 51 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)
Error: Please correct the above warnings first.
ProGuard, version 5.3.3
...
Note: kotlinx.coroutines.CommonPool accesses a method 'getPoolSize()' dynamically
Maybe this is library method 'java.util.concurrent.ForkJoinPool { int getPoolSize(); }'
Maybe this is library method 'java.util.concurrent.ThreadPoolExecutor { int getPoolSize(); }'
Note: there were 5 classes trying to access annotations using reflection.
You should consider keeping the annotation attributes
(using '-keepattributes *Annotation*').
(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 4 classes trying to access generic signatures using reflection.
You should consider keeping the signature attributes
(using '-keepattributes Signature').
(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 2 classes trying to access enclosing methods using reflection.
You should consider keeping the enclosing method attributes
(using '-keepattributes InnerClasses,EnclosingMethod').
(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 15 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)
Note: there were 29 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
Target //app/src/main:app failed to build
INFO: Elapsed time: 3.238s, Critical Path: 3.10s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
Bazel config:
android_binary(
name = "app",
manifest = "AndroidManifest.xml",
custom_package = "felix.duan.androidnavisample",
manifest_values = {
"minSdkVersion": "21",
"versionCode" : "2",
"versionName" : "2.0",
"targetSdkVersion" : "29",
},
proguard_generate_mapping = True,
proguard_specs = ["proguard-rules.pro"],
deps = [
":lib",
]
)
proguard-rules.pro:
-keep class org.jetbrains.annotations.** { *; }
-dontwarn org.jetbrains.annotations.**
Build tools:
bazel: v3.7.0-homebrew
rules_kotlin_version: legacy-1.4.0-rc4
android sdk: v30.0.2
Question A: How to solve this problem?
addition questions I found related to this:
Question B: Does Bazel consume transitive dependency proguard? If not, this could be the cause?
Question C: Does Bazel support R8? I found no direct info to this.
Since it's only a warning, maybe you can disable it in the proguard config:
-dontwarn kotlinx.coroutines.**
And then error which is Error: Please correct the above warnings first. might go away.
Trying to make archive for publishing and has this error
Java heap size is set to 1G.PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.client.HttpClient
PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
PROGUARD : warning : com.google.android.gms.tagmanager.zzcx: can't find referenced class org.apache.http.HttpEntityEnclosingRequest
PROGUARD : warning : there were 148 unresolved references to classes or interfaces.
PROGUARD : warning : there were 2 unresolved references to program class members.
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1833,3): error MSB6006: "java.exe" exited with code 1.
I made archive for publishing at Friday and everything was ok. Yesterday I have updates and installed them, but this didn't solve the problem
What's wrong?
Problem is solved
create file named proguard.cfg inside Android project in the solution. Right click and set Build Action to ProguardConfig.
I add this to proguard file
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
Make sure you save file as UTF-8 and NOT UTF-8 BOM
I have a pretty big project with an elaborate proguard.cfg .
This project builds OK under eclipse, proguard runs without errors, and the app works perfectly, it's been my normal workflow for months.
I am trying to build it from command line using ant.
I have updated build.xml, etc.. on the projects and its library project using
android update project -p .
android update project -s --target android-17 -p .
The debug version, ant debug, gets built successfully
However, ant release fails proguard, complaining about missing classes.
From what I could decipher (a lot of non-faltal warnings pop up) the problems are related to a missing inner class in one of my (thousand) classes, and to missing R (resources) of a dependent library project. This is strange, both things do exist, the library projects gets built OK from eclipse & ant, and that inner class i don't know, the parent class is pretty trivial.
Why does it build under eclipse and not using command line? Shouldn't the updated build scripts produce the same result?
Proguard: Errors Related to LIbrary Project Resources
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.CustomViewBehind: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R$id
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.CustomViewBehind: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R$id
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.CustomViewBehind: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.SlidingMenu: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R$styleable
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.SlidingMenu: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R$styleable
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.SlidingMenu: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R$layout
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R$layout
[proguard] Warning: com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityHelper: can't find referenced class com.jeremyfeinstein.slidingmenu.lib.R
Proguard: Related to inner class not found
[proguard] Warning: com.regaliz.gui.layouts.FunqRootLayout$2: can't find referenced class com.regaliz.gui.layouts.FunqRootLayout$1
[proguard] Warning: com.regaliz.gui.layouts.FunqRootLayout$3: can't find referenced class com.regaliz.gui.layouts.FunqRootLayout$1
[proguard] Warning: com.regaliz.gui.layouts.FunqRootLayout$SimpleAnimationListener: can't find referenced class com.regaliz.gui.layouts.FunqRootLayout$1
[proguard] Warning: com.regaliz.gui.layouts.FunqRootLayout$SimpleAnimationListener: can't find referenced class com.regaliz.gui.layouts.FunqRootLayout$1
[proguard] Warning: com.regaliz.gui.layouts.FunqRootLayout$SimpleAnimationListener: can't find referenced class com.regaliz.gui.layouts.FunqRootLayout$1
That's strange, I found the problem by trial and error.
The inner class not found was an innocent private anonymous runnable like:
private Runnable mBlinkRunner=new Runnable() {
public void run() {
.
. couple simple lines
.
}
};
I changed it to ...
protected Runnable mBlinkRunner=new Runnable() {
public void run() {
.
. couple simple lines
.
}
};
and it worked... I wonder why this happens, there should be like hundreds of runnables like these through the project.
I am trying to use Proguard to obfuscate my Android app which makes use of the library jsch-1.50.jar for uploading files to an SFTP server.
When I do an export from Eclipse, I get warnings "can't reference class" and nothing is produced. I have tried all manner of options to tell Proguard to ignore the jsch classes, but it's not making any difference and therefore I wonder if I am misunderstanding how this works. I am not too worried about the optimisation, but I would like the code obfuscated.
I have setup the proguard-properties as follows:
-keep class com.jcraft.jsch.jce.*
-keep class * extends com.jcraft.jsch.KeyExchange
-keep class com.jcraft.jsch.**
-keep class com.jcraft.jzlib.ZStream
-keep class com.jcraft.jsch.Compression
-keep class org.ietf.jgss.*
-libraryjars /libs/jsch-0.1.50.jar
The project-properties file contains an entry for "proguard.config=proguard-project.txt".
The output from the export with duplicates removed:-
Warning: com.jcraft.jsch.jcraft.Compression: can't find referenced class com.jcraft.jzlib.ZStream
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.Oid
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.GSSManager
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.GSSException
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.GSSContext
Warning: com.jcraft.jsch.jgss.GSSContextKrb5: can't find referenced class org.ietf.jgss.MessageProp
Warning: there were 44 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Error: Please correct the above warnings first.
Would very much appreciate any pointers.
Thanks
Mike
After a bit more investigation, I found the following...
I had forgotten to include jzlib-1.1.1.jar in the project with the corresponding
-libraryjars /libs/jzlib-1.1.1.jar
entry in the proguard-properties.txt.
Also to ignore the warning regards references to "class org.ietf.jgss", I tried the suggested method of excluding the referencing class
-libraryjars /libs/jsch-0.1.50.jar(!com.jcraft.jsch.jgss/GSSContextKrb5.class)
but that didn't help. In the end, I went with :-
-dontwarn org.ietf.jgss.**
When I try to export an .apk file it gives me this error:
[2013-06-10 13:46:47 -] Proguard returned with error code 1. See console
[2013-06-10 13:46:47 -] Warning: com.facebook.widget.FacebookFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in class com.facebook.widget.FacebookFragment
What could be the reason for it? I dont understand what dontskipnonpubliclibraryclassmembers means?
Thanks