Purchasely / Purchasely-ReactNative

Other
13 stars 2 forks source link

Can't `assemble` with React Native 0.73 (only `bundle` works) #85

Closed denis-rift closed 8 months ago

denis-rift commented 8 months ago

Getting the error

ERROR: R8: Missing class java.lang.invoke.StringConcatFactory (referenced from: java.lang.Object com.reactnativepurchasely.PurchaselyModule$isEligibleForIntroOffer$1.invokeSuspend(java.lang.Object) and 3 other contexts)

when trying to assemble an android build.

But creating a bundle works fine...

Tried with:

kherembourg commented 8 months ago

Hello @denis-rift

Thank you for the report, it seems to be an issue with Android R8 plugin from Google There is nothing we can do directly but we have made some changes with version 4.2.2 that I hope prevent this issue

Can you try this new version an let me know please? Thank you!

denis-rift commented 8 months ago

Hello @kherembourg ,

Still the same error after updated to 4.2.2 with yarn add react-native-purchasely... :(

Thanks

kherembourg commented 8 months ago

Arf :(

It is an issue from Google AGP so there is nothing much I can do really I think

I did however added freeCompilerArgs = listOf("-Xstring-concat=inline") to the build.gradle file Maybe you need to do it too @denis-rift ?

Can you try to set this in your app/build.gradle file ?

kotlinOptions {
        jvmTarget = "11"
        freeCompilerArgs = ["-Xstring-concat=inline"]
}

If I understand correctly, you are not able to compile with R8 enabled so for a release build right? But with a development build (debug) it works?

denis-rift commented 8 months ago

kherembourg Doesn't work either with kotlinOptions...

In fact, R8 is still disabled with enableProguardInReleaseBuilds = false. What is strange, is that building a release bundle version works fine (.aab) but not building a release .apk. We need to build an .apk for our e2e tests from our CI with Maestro.

kherembourg commented 8 months ago

@denis-rift Ok thanks, I have been able to replicate the issue with our example project on this repository

Indeed, when I use the command ./gradlew clean :app:assemble I have this exact error But when it use ./gradlew clean :app:bundle it works perfectly fine Also, compiling and running the application with react native command line (either yarn or npx) works perfectly fine too

Unfortunately, I have no idea how to fix it. It is entirely related to Android and not the SDK I have tried changing the jdk target to 8 and 11 and other things, but nothing makes a difference I have also tried to update the Android SDK to the last version of Kotlin Serialization (which seems to be the origin of the issue), unfortunately still the same error

I will continue to investigate but I don't understand why the solution confirmed in the issue tracker is not working here

denis-rift commented 8 months ago

Ok thanks @kherembourg

Please, keep me uptodate if you find something :)

denis-rift commented 8 months ago

For following, bugnsag has a similar (but a bit different) issue with AGP 8: https://github.com/bugsnag/bugsnag-js/issues/2060

RRaideRR commented 8 months ago

I cannot add anything to the discussion beside saying that I also have this problem. I don't understand any of Android code. That being said: purchasely is the only of over 50 libraries in my project that has this problem :-(.

kherembourg commented 8 months ago

Hello @denis-rift Thank you very much for that link, I was able to find the issue :)

Indeed, with Android Gradle Plugin 8.+, ReactNative is obfuscating the native modules... and Purchasely Module had obfuscation enabled I removed this rule and added some proguard configuration just in case

On my side, everything works fine now I will release the version tomorrow afternoon, I am waiting for an update of the iOS SDK before

@RRaideRR thank you for the report, the fix will be available tomorrow around 4pm CET with version 4.2.3

RRaideRR commented 8 months ago

I can confirm it is working now :-). Thanks for the quick fix Kevin!

denis-rift commented 8 months ago

Indeed, works fine. Thanks @kherembourg !