-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build error and runtime error after proguard enabled. #5146
Conversation
By analyzing the blame information on this pull request, we identified @mkonicek to be a potential reviewer. |
Thanks for the fix! |
@@ -40,10 +40,13 @@ | |||
|
|||
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } | |||
-keep class * extends com.facebook.react.bridge.NativeModule { *; } | |||
-keep class * { native <methods>; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try changing this to?
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
keep class
gives 7.1MB APK, keepclasseswithmembernames
6.8MB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but it didn't work. There's still errors:
E/dalvikvm( 1032): ERROR: couldn't find native method
E/dalvikvm( 1032): Requested: Lcom/facebook/react/bridge/ReadableNativeArray;.getType:(I)Lcom/facebook/react/bridge/ReadableType;
Maybe there's another problem. I'll take a look and give a update for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the code decompiled from classes-proguard. All other methods is fine but getType is missing. I don't know why...
this work for me. We should not only keep their names, but also keep native methods self, otherwise it may be stripped if not used. |
Does this work as noted in the docs (http://proguard.sourceforge.net/manual/examples.html#native)?
|
@tdzl2003 updated the pull request. |
Nope. I think getType is stripped but other methods are kept because getType wasn't used in modules provided by MainReactPackage |
includedescriptorclasses has no effect now because all the classes used by native method have annotation |
@tdzl2003 updated the pull request. |
ok ok thanks for looking! |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1678391639113596/int_phab to review. |
5f3d08d
Summary: Fix: 1. :app:packageRelease FAILED caused by proguard exception: `java.io.IOException: Please correct the above warnings first.` 2. Fix runtime exception ``` java.lang.ExceptionInInitializerError at com.facebook.react.ReactInstanceManagerImpl.recreateReactContextInBackgroundFromBundleFile(ReactInstanceManagerImpl.java:308) ``` Closes facebook#5146 Reviewed By: svcscm Differential Revision: D2807252 Pulled By: mkonicek fb-gh-sync-id: 03d004405c7cca14a71230086b95351cfacbc055
Summary: Fix: 1. :app:packageRelease FAILED caused by proguard exception: `java.io.IOException: Please correct the above warnings first.` 2. Fix runtime exception ``` java.lang.ExceptionInInitializerError at com.facebook.react.ReactInstanceManagerImpl.recreateReactContextInBackgroundFromBundleFile(ReactInstanceManagerImpl.java:308) ``` Closes #5146 Reviewed By: svcscm Differential Revision: D2807252 Pulled By: mkonicek fb-gh-sync-id: 03d004405c7cca14a71230086b95351cfacbc055
Summary: Fix: 1. :app:packageRelease FAILED caused by proguard exception: `java.io.IOException: Please correct the above warnings first.` 2. Fix runtime exception ``` java.lang.ExceptionInInitializerError at com.facebook.react.ReactInstanceManagerImpl.recreateReactContextInBackgroundFromBundleFile(ReactInstanceManagerImpl.java:308) ``` Closes facebook/react-native#5146 Reviewed By: svcscm Differential Revision: D2807252 Pulled By: mkonicek fb-gh-sync-id: 03d004405c7cca14a71230086b95351cfacbc055
Fix:
java.io.IOException: Please correct the above warnings first.