Skip to content

Required RN >= 0.58 is not true #181

Closed

Description

@lukefanning

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

Activity

  1. changed the title [-]RN >= 0.58 is not true[/-] [+]Required RN >= 0.58 is not true[/+] on Oct 14, 2020
  2. vegaro commented on Oct 14, 2020

    @vegaro
    Member

    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 🤔

  3. lukefanning commented on Oct 14, 2020

    @lukefanning
    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

  4. vegaro commented on Oct 14, 2020

    @vegaro
    Member

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

  5. lukefanning commented on Oct 15, 2020

    @lukefanning
    Author

    @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 react-native-purchases@3.4.0
    • 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.
    
  6. lukefanning commented on Oct 15, 2020

    @lukefanning
    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

  7. vegaro commented on Oct 15, 2020

    @vegaro
    Member

    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 react-native-purchases@3.4.0
    • 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

  8. lukefanning commented on Oct 19, 2020

    @lukefanning
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions