proyecto26 / react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
https://www.npmjs.com/package/react-native-inappbrowser-reborn
MIT License
1.33k stars 227 forks source link

android properties being removed by proguard #470

Open williamheelis opened 4 weeks ago

williamheelis commented 4 weeks ago

A heads up. We have found that in it's current instantiation if you are publishing anything that uses react-native-inappbrowser in your a react native app with the following rules (below) in your app build.gradle, then the browser Options relating to colour on the customtab do not get parsed. i.e. the colour of the browser customtab stays default.

EG: if you have this block in your release

minifyEnabled = true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/dedox/proguard-rules-app.pro"

then the colour options such as

import {InAppBrowser } from 'react-native-inappbrowser';

await InappBrowser.open(url, {
   toolbarColor: '#00FF00',
   navigationBarColor: '#00FF00',
   navigationBarDividerColor:  '#00FF00',
});

the colour '#00FF00' will work in dev, but be ignored when you release the app as proguard will whittle it

the solution is to alter the proguard-rules.pro file to state the following

-keepclassmembers class androidx.browser.customtabs** {
  *;
}

Which platform(s) does your issue occur on?

AlehBarushka commented 6 days ago

@williamheelis thank you very much!