Proguard broke react native android - android

After enabling proguard in my react native project, I've been getting countless notes and errors from all the packages, com.facebook.react, okhttp3, okio, and every other 3rd party library that I'm using including org.reactnative.camera, com.lwansbrough.RCTCamera, com.horcrux.svg and more. Shouldn't the default proguard rules already take care of some of the default packages?
After countless hours looking for solution that includes the obvious -dontnote and -dontwarn, as well as attempting to -keep all the classes mentioned, each time I manage to get rid of a couple of the warnings there is always more warnings.
Do I really have to manually go through every single reference to use proguard? Sometimes I don't even know which class to keep and ignore when using other libraries. Please help.
Note: there were 4 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 1 references to unknown class members.
You should check your configuration for typos.
Note: there were 835 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 70 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 1620 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 1 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)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
Thread(Tasks limiter_14): destruction

Related

Cant debug build app on android 4.4.2 but it works on android 6.0.1

The error I get is:(this is a large project)
Note: there were 10 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 239 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 27 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 2292 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 241 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)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForDebug FAILED
FAILURE: Build failed with an exception.
ThereĀ“s a big log output from Gradle and I know I must clean up the proguard-rules.pro eventually but why does it work on android 6.0.1 and not on android 4.4.2. The log end with "Build failed with an exception" and I try to "Run with --stacktrace " but cant see the exception
I solved it.
The reason was in app build gradle I was using play-services 11.4.0 and firebase 11.4.2.
Somehow I missed syncing them to use the same version..

Proguard failed after support library updated to 26.0.1

I have updated my support lib to 26.0.1, but release build is failed.
logs
Note: there were 3 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 63 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 29 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 1 class casts of dynamically created class instances.
You might consider explicitly keeping the mentioned classes and/or
their implementations (using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclasscast)
Warning: there were 30 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 1 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
:purplleAndroid:transformClassesAndResourcesWithProguardForRelease FAILED
Not understanding due to which library proguard is failing.
proguard file
app level build.gradle
Error log
It's not support library issue,
I using library called branch.io ,i am added it's dependency end with "+".So it's updated and that has some progaurd rules.

How to find out which classes cannot be resolved by ProGuard Android

After adding ProGuard rules for all libraries I am using, I still get this warning:
Warning: there were 14 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)
I know that I can probably use the -dontwarn option to get rid of this warning, but therefore I need to know which packages/classes/interfaces cannot be resolved. Android does not support a global "-dontwarn".
In the log file I find so many Notes and Warnings, but none of them seem to relate the above message.
If you receive a Warning: there were X unresolved references to classes or interfaces then look for lines in your build log that contain the word Warning, such as this:
Warning: com.package.Class1: can't find referenced class org.library.Class2
Lines like this will tell which classes ProGuard is trying to work on and which classes can't be found in the input jars. In the example above, class Class1 would reference Class2 of a library but Class2 was not found in the build path.
As you mentioned, you can simply add -dontwarn <class regex> to ignore those warnings but ideally you should check them one-by-one to make sure that your configuration is correct and all required dependencies are being imported correctly.

How do I know the problematic classes Proguard is referring to

I get the following message from Proguard and I suspect the reason my app is not working has to do with them. But I am not sure what to do with the message:
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 7 classes trying to access enclosing classes using reflection.
You should consider keeping the inner classes attributes
(using '-keepattributes InnerClasses').
(http://proguard.sourceforge.net/manual/troubleshooting.html#attributes)
Note: there were 233 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 13 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 10 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)
Warning: there were 35 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)

Dispatch library on Android

Trying to build an Android app via SBT, I find that I can android:package just fine unless I add "net.databinder.dispatch" %% "dispatch-core" % "0.11.2" in to libraryDependencies. If I add it, then I get the following (extremely long) Proguard error (full text):
Note: org.jboss.netty.util.internal.ByteBufferUtil: can't find dynamically referenced class java.nio.DirectByteBuffer
Note: org.jboss.netty.util.internal.ByteBufferUtil: can't find dynamically referenced class sun.misc.Cleaner
Note: there were 2 unresolved dynamic references to classes or interfaces.
Warning: there were 1828 unresolved references to classes or interfaces.
You should check if you need to specify additional program jars.
You may need to add missing library jars or update their versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
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 7 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)
Warning: there were 8 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
preceded by a few thousand lines. android:compile works fine with or without Dispatch added.
Looking at the dispatch-classic docs suggests that Dispatch does not work well with Android, but mentions that the "future move to a different backend" (presumably implemented in the latest versions of dispatch) will rectify this.
I can't find any information about Dispatch and Android other than what's available for dispatch-classic.
Does the issue still exist? Should I just use a different library? Is it possible to modify my proguard-sbt.txt to make sure android:package can run?
It seems that Dispatch now plays nicely with Android. My issue previously was that, unknown to me, my proguard settings were being re-generated by sbt for every compile. Adding in -donwarn ** to my proguardOptions in my .sbt file fixes the above errors (although I should probably track down the more specific packages that need to be -dontwarn'd in the future).
With that being said, it seems that Dispatch's heavy-duty dependencies do pose a problem with the Android development pipeline: running android:package maxes out all 6 of my CPUs and uses > 1 GB of memory. I'm way over the 65k dex limit. I think I'll go in a different direction.

Categories

Resources