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

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

Closed
denis-rift opened this issue Jan 8, 2024 · 11 comments · Fixed by #89
Closed

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

denis-rift opened this issue Jan 8, 2024 · 11 comments · Fixed by #89

Comments

@denis-rift
Copy link

denis-rift commented Jan 8, 2024

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:

  • Java 17
  • Java 18
@kherembourg
Copy link
Contributor

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
Copy link
Author

Hello @kherembourg ,

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

Thanks

@kherembourg
Copy link
Contributor

kherembourg commented Jan 11, 2024

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
Copy link
Author

denis-rift commented Jan 11, 2024

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
Copy link
Contributor

@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
Copy link
Author

Ok thanks @kherembourg

Please, keep me uptodate if you find something :)

@denis-rift
Copy link
Author

For following, bugnsag has a similar (but a bit different) issue with AGP 8:
bugsnag/bugsnag-js#2060

@RRaideRR
Copy link

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 kherembourg linked a pull request Jan 16, 2024 that will close this issue
@kherembourg
Copy link
Contributor

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
Copy link

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

@denis-rift
Copy link
Author

Indeed, works fine. Thanks @kherembourg !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants