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

Required RN >= 0.58 is not true #181

Closed
lukefanning opened this issue Oct 14, 2020 · 7 comments
Closed

Required RN >= 0.58 is not true #181

lukefanning opened this issue Oct 14, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@lukefanning
Copy link

lukefanning commented Oct 14, 2020

I integrated the latest version of react-native-purchases alongside RN 0.59.10. Got the iOS side working and then started on the Android side. It failed to build due to conflict between the old support libraries and AndroidX. I thought it was odd as i use jetify on npm postinstall. Looking into your library more carefully I can see it depends on "com.revenuecat.purchases:purchases". That's when I did some digging into that library only to find it depends on an androidx lib explicity and has done since 2.0.0. This meant the only version I could use of this library is in fact 1.5.4 which uses Android lib 1.4.0. Unless I'm mistaken (which would be good) then you need to update your doc here

@lukefanning lukefanning added the bug Something isn't working label Oct 14, 2020
@lukefanning lukefanning changed the title RN >= 0.58 is not true Required RN >= 0.58 is not true Oct 14, 2020
@vegaro
Copy link
Contributor

vegaro commented Oct 14, 2020

Thanks for opening @ssg-luke . I am not sure I understand the issue though... RN 0.59.10 uses support libraries, but our library uses androidx. Wouldn't jetify work and convert the support dependencies from RN 0.59.10 to androidx?

Just to give an example, we were using react native < 0.60 until release https://github.com/RevenueCat/react-native-purchases/releases/tag/3.4.1 in our sample app just fine without errors.

I might be missing something here 🤔

@lukefanning
Copy link
Author

As far as i understand it, jetify only converts java files in the module, it does not effect dependencies pulled in by the module during build time. Hm I'll have a look at your sample app to see if i can find out why it worked for you

@vegaro
Copy link
Contributor

vegaro commented Oct 14, 2020

I will make a sample project with that version and see if it compiles too

@lukefanning
Copy link
Author

lukefanning commented Oct 15, 2020

@vegaro Ok got around to doing this just now. Just to run through the steps I took:

  • Initialised a fresh RN 0.59.10 project
  • npm i -S [email protected]
  • npm i -D jetifier
  • react-native link react-native-purchases
  • npx jetify -r
  • npx react-native run-android
info JS server already running.
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...

> Task :react-native-purchases:compileDebugKotlin
w: /Users/luke/Projects/purchases-test/PurchasesTest/node_modules/react-native-purchases/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesConverters.kt: (65, 85): Unchecked cast: Any? to Map<String, *>
w: /Users/luke/Projects/purchases-test/PurchasesTest/node_modules/react-native-purchases/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesConverters.kt: (66, 89): Unchecked cast: Any? to Array<Any?>
w: /Users/luke/Projects/purchases-test/PurchasesTest/node_modules/react-native-purchases/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesConverters.kt: (83, 88): Unchecked cast: Any? to Map<String, *>
w: /Users/luke/Projects/purchases-test/PurchasesTest/node_modules/react-native-purchases/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesConverters.kt: (84, 92): Unchecked cast: Any? to Array<Any?>

> Task :react-native-purchases:compileDebugJavaWithJavac
Note: /Users/luke/Projects/purchases-test/PurchasesTest/node_modules/react-native-purchases/android/src/main/java/com/revenuecat/purchases/react/RNPurchasesModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :app:processDebugManifest FAILED
/Users/luke/Projects/purchases-test/PurchasesTest/android/app/src/debug/AndroidManifest.xml:22:18-91 Error:
        Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.3.1] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
        is also present at [androidx.core:core:1.3.1] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
21 actionable tasks: 19 executed, 2 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

@lukefanning
Copy link
Author

I believe the only way to support < RN 0.60 for this module would be to package the com.revenuecat.purchases:purchases lib as an aar inside the module (i.e. like Clip-sub/react-native-bottomsheet#23) and then < RN 0.60 users can use jetifier-standalone to de-Jetify it

@vegaro
Copy link
Contributor

vegaro commented Oct 15, 2020

Hey I just tested all this. Is there any reason why you are running a reverse jetifier by passing -r to jetifier

I just did the following and it works:

  • Initialised a fresh RN 0.59.10 project
  • npm i -S [email protected]
  • react-native link react-native-purchases
  • Added to gradle.properties:
android.useAndroidX=true
android.enableJetifier=true

That way all dependencies are changed to androidx, including React Native's

Doing the reverse jetifier (transforming all androidx to support) gives me your crash. Doing a forward jetifier (support to androidx) doesn't hurt, and adding those properties to gradle.properties should make it work and replace dependencies

@lukefanning
Copy link
Author

@vegaro Yep you are right, a forward jetify does allow it to compile no problem. Of course ran into an issue with another severely outdated module after doing that but that's not your problem ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants