Skip to content
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

0.41.0-rc.0 - Update Android Proguard Rules #11891

Closed
jpshelley opened this issue Jan 13, 2017 · 13 comments
Closed

0.41.0-rc.0 - Update Android Proguard Rules #11891

jpshelley opened this issue Jan 13, 2017 · 13 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@jpshelley
Copy link
Contributor

jpshelley commented Jan 13, 2017

Description

Recently I updated to 0.41.0-rc.0 and there has been a regression in regards to Proguard for Android. The following happens on a release build:

Warning: com.facebook.fbui.textlayoutbuilder.proxy.StaticLayoutProxy:
can't find referenced method 'StaticLayout(java.lang.CharSequence,int,int,android.text.TextPaint,int,android.text.Layout$Alignment,android.text.TextDirectionHeuristic,float,float,boolean,android.text.TextUtils$TruncateAt,int,int)'
in library class android.text.StaticLayout

Reproduction

  1. Create a new project: react-native init TestProguardProject
  2. Setup release as documented and run it: Must use --configuration flag rather then variant for some reason based on Improve the Android release documentation #11443
  3. Upgrade it to v41: react-native-git-upgrade 0.41.0-rc.0
  4. Try running the release build again: react-native run-android --variant=release
  5. Experience a build failure based on the above

Solution

Additional Information

  • React Native version: 0.41.0-rc.0
  • Platform: Android
  • Operating System: MacOS
@jpshelley jpshelley changed the title Update Android Proguard Rules 0.41.0-rc.0 - Update Android Proguard Rules Jan 13, 2017
@nihgwu
Copy link
Contributor

nihgwu commented Jan 14, 2017

I have to turn off proguard to build a release version after upgrade to RN0.41, do you have any workaround?

@jpshelley
Copy link
Contributor Author

One solution is to ignore the warning by using:
-dontwarn com.facebook.fbui.textlayoutbuilder.proxy.StaticLayoutProxy
If that is the preferred route, we can add it to the React Native default proguard setup, however I'd like to get confirmation from some of the maintainers on whether it should be a dontwarn or a keep command.

@evollu
Copy link

evollu commented Feb 3, 2017

RN 0.41 using proguard is failing for me too

@goodhyun
Copy link

goodhyun commented Feb 8, 2017

We also had the same failure with a bunch of warnings from 0.41, but @jpshelley 's workaround was good enough.

@AndrewJack
Copy link
Contributor

AndrewJack commented Feb 14, 2017

The TextLayoutBuilder library has this in it's proguard rules (Fixed it for me):

# This library uses a non-public Android constructor within StaticLayout.
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
-dontwarn android.text.StaticLayout

https://github.com/facebookincubator/TextLayoutBuilder/blob/master/proguard-android.txt

@dbof10
Copy link

dbof10 commented Feb 22, 2017

it's helpful. Thanks

@henrikra
Copy link

@AndrewJack Thank for the solution! It worked for me too. How did you find about this? Because proguard is not showing in the output what class it tried to find. I spent so much time on this issue :)

@AndrewJack
Copy link
Contributor

@henrikra I read in the proguard output that TextLayoutBuilder was the source of the issue (Admittedly a very hard to read output). I then found the TextLayoutBuilder repo on github. I saw it is built as a Jar and not an AAR, therefore the proguard files aren't supplied with it.

JonatanSalas pushed a commit to BlackBoxVision/react-native-redux-todo that referenced this issue Apr 8, 2017
Fix issue in proguard config related to this bug -> facebook/react-native#11891
@guysegal
Copy link

Why is this issue closed? If I create a project with react-native init and try to assembleReleaseit with proguard flag set to true, then the apk is not created successfully.

adding -dontwarn android.text.StaticLayout solves the problem, shouldn't it be added to the default proguard rules file

@AndrewJack
Copy link
Contributor

@guysegal the fix is in 0.44.0-rc, it'll work after that is stable 3504698

@guysegal
Copy link

greate thanks!

@StevenTB
Copy link

@AndrewJack This workaround works well. You saved my day !

iegik added a commit to iegik/react-native that referenced this issue Aug 23, 2017
@kelset
Copy link
Contributor

kelset commented Dec 15, 2017

As weird as it may sound, just tried to build a release version with RN 0.51 and the warning showed up again.

Adding that -dontwarn android.text.StaticLayout in the proguard rules solved it - but yeah weird, never had this issue before.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.