talsec / Free-RASP-ReactNative

React Native plugin for improving app security and threat monitoring on Android and iOS mobile devices.
https://github.com/talsec/Free-RASP-Community
MIT License
84 stars 10 forks source link

Execution failed for task ':freerasp-react-native:minifyReleaseWithR8'. #60

Closed tusharsarkar closed 5 months ago

tusharsarkar commented 5 months ago

Bug Description on ./gradlew app:assembleRelease I am getting following error

Execution failed for task ':freerasp-react-native:minifyReleaseWithR8'.

A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable Compilation failed to complete, origin: /../node_modules/freerasp-react-native/android/build/tmp/kotlin-classes/release/com/freeraspreactnative/Threat.class

RASP Version Info

React native version info

tompsota commented 5 months ago

Hi @tusharsarkar,

I'll try to reproduce the bug and get back to you ASAP.

Thanks for reporting!

Tomas from Talsec

tusharsarkar commented 5 months ago

@tompsota any update on this issue

tompsota commented 5 months ago

Hi, @tusharsarkar,

I've been busy preparing new release, but hopefully tomorrow I'll take a look at this issue.

Thanks for your patience and stay tuned!

tusharsarkar commented 5 months ago

Hi @tompsota , any update on this issue? Our release blocked due to this issue.

tompsota commented 5 months ago

Hi @tusharsarkar,

I reproduced the problem. To resolve it, add following code on top of the settings.gradle or settings.gradle.kts file (inside android/ folder):

pluginManagement {
    buildscript {
        repositories {
            mavenCentral()
            maven {
                url = uri("https://storage.googleapis.com/r8-releases/raw")
            }
        }
        dependencies {
            classpath("com.android.tools:r8:8.2.24")
        }
    }
}

The issue is that RN 0.73.x uses AGP 8.1.x which does not support sealed classes. However, these are used in our project. The support is again added in AGP 8.2. By adding the code above, you specify that you want to use the use newer version of AGP. Source: https://issuetracker.google.com/issues/227160052#comment37

Hopefully this resolves your problem.

Let us know if this helped.

tusharsarkar commented 5 months ago

Thanks @tompsota . This resolve the issue.

tompsota commented 5 months ago

Great news! I also added this into the troubleshooting section in readme.

asharamseervi commented 5 months ago

Hey @tompsota, I'm using this package with Expo, as discussed previously, and requested support for Expo SDK. While building an app, this issue still exists for me as being an ExpoSDK user.

Screenshot 2024-04-22 at 1 41 49 AM

To debug further, I'm providing a few more details to try: "expo": "~50.0.15", "react-native": "0.73.6", "freerasp-react-native": "^3.7.1-1", And as suggested, I do not have an Android directory at all. How can I apply those settings in app.json or anywhere you recommend?

tompsota commented 5 months ago

Hi @asharamseervi ,

I'll update the config plugin for Expo. Thanks for pointing it out.

tompsota commented 5 months ago

Hello @asharamseervi,

just released v3.7.2, which fixes the issue for Expo.

you can use R8Version property in plugin config to increase the version of R8. Any version above 8.2 should work. 8.3.37 is the latest at the moment.

"plugins": [
      [
        "freerasp-react-native/app.plugin.js",
        {
          "android": {
            "R8Version": "8.3.37" 
          }
        }
      ]
    ],