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
91 stars 12 forks source link

Unable to run on Android 14 device #75

Closed gkasireddy202 closed 3 months ago

gkasireddy202 commented 4 months ago

Describe the bug Unable to run on Android device.

To Reproduce Open the project after installing the package:npm install freerasp-react-native. My project does not run and shows the below error. A problem occurred configuring project ':freerasp-react-native'.

Could not resolve all artifacts for configuration ':freerasp-react-native:classpath'. Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0. Required by: project :freerasp-react-native Cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:

  • gradle70JavadocElements
  • gradle70RuntimeElements
  • gradle70SourcesElements
  • javadocElements
  • runtimeElements
  • sourcesElements All of them match the consumer attributes:
  • Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
  • Unmatched attributes:
  • Found org.gradle.category 'documentation' but wasn't required.
  • Found org.gradle.docstype 'javadoc' but wasn't required.
  • Required org.gradle.jvm.version '11' but no value provided.
  • Required org.gradle.libraryelements 'jar' but no value provided.
  • Found org.gradle.plugin.api-version '7.0' but wasn't required.
  • Found org.gradle.status 'release' but wasn't required.
  • Compatible attributes:
  • Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
  • Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
  • Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
  • Unmatched attributes:
  • Found org.gradle.category 'library' but wasn't required.
  • Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
  • Found org.gradle.plugin.api-version '7.0' but wasn't required.
  • Found org.gradle.status 'release' but wasn't required.
  • Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
  • Compatible attributes:
  • Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
  • Required org.gradle.jvm.version '11' and found compatible value '8'.
  • Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
  • Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
  • Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
  • Unmatched attributes:
  • Found org.gradle.category 'documentation' but wasn't required.
  • Found org.gradle.docstype 'sources' but wasn't required.
  • Required org.gradle.jvm.version '11' but no value provided.
  • Required org.gradle.libraryelements 'jar' but no value provided.
  • Found org.gradle.plugin.api-version '7.0' but wasn't required.
  • Found org.gradle.status 'release' but wasn't required.
  • Compatible attributes:
  • Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
  • Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
  • Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
  • Unmatched attributes:
  • Found org.gradle.category 'documentation' but wasn't required.
  • Found org.gradle.docstype 'javadoc' but wasn't required.
  • Required org.gradle.jvm.version '11' but no value provided.
  • Required org.gradle.libraryelements 'jar' but no value provided.
  • Found org.gradle.status 'release' but wasn't required.
  • Compatible attributes:
  • Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
  • Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
  • Variant 'runtimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
  • Unmatched attributes:
  • Found org.gradle.category 'library' but wasn't required.
  • Found org.gradle.jvm.environment 'standard-jvm' but wasn't required.
  • Found org.gradle.status 'release' but wasn't required.
  • Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
  • Compatible attributes:
  • Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
  • Required org.gradle.jvm.version '11' and found compatible value '8'.
  • Required org.gradle.libraryelements 'jar' and found compatible value 'jar'.
  • Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.
  • Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0:
  • Unmatched attributes:
  • Found org.gradle.category 'documentation' but wasn't required.
  • Found org.gradle.docstype 'sources' but wasn't required.
  • Required org.gradle.jvm.version '11' but no value provided.
  • Required org.gradle.libraryelements 'jar' but no value provided.
  • Found org.gradle.status 'release' but wasn't required.
  • Compatible attributes:
  • Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
  • Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.

Expected behavior Run the app on an Android device

Screenshots If applicable, add screenshots to help explain your problem.

Screenshot 2024-07-29 at 4 20 32 PM

Please complete the following information:

Additional context Add any other context about the problem here.

gkasireddy202 commented 4 months ago

Hi Team,

Please look at the issue. I facing this issue on Android.

PaulHedrich commented 3 months ago

Hi Talsec Team, Is our error submission and request for assistance appropriate in this repository, or is there a more appropriate support request site? Thank you.

msikyna commented 3 months ago

Hello @gkasireddy202 , @PaulHedrich ,

we will look at the issue and get back to you soon. Thank you for reporting it!

Kind regards, Talsec team

tompsota commented 3 months ago

Hello @gkasireddy202, @PaulHedrich,

It seems like Android Studio is using some version of Kotlin that is not compatible with 1.7.0, which is the default for freerasp. You can modify the version of Kotlin for freerasp in top-level build.gradle file in buildscript.ext section. Try to set "kotlinVersion" property to the version you use in Android Studio.

Let us know if it helped.

Best, Tomas from Talsec

gkasireddy202 commented 3 months ago

@tompsota - Thanks for your reply. Can I set kotlinVersion property in my project level(MyProject>android>build.gradle) or node_modules>freersap-react-native>android>build.gradle?

If I add kotlinVersion in the project level could it affect other react-native components in my project?

gkasireddy202 commented 3 months ago

@tompsota - I installed the freerasp-react-native component in react-native:0.73.7. I am trying to generate the apk in release mode and getting the below errors.

Task :freerasp-react-native:minifyReleaseWithR8 FAILED AGPBI: {"kind":"error","text":"com.android.tools.r8.internal.Ub: Sealed classes are not supported as program classes when generating class files","sources":[{"file":"/MyProject/node_modules/freerasp-react-native/android/build/tmp/kotlin-classes/release/com/freeraspreactnative/Threat.class"}],"tool":"R8"}

com.android.tools.r8.internal.Ub: Sealed classes are not supported as program classes when generating class files.

ext { buildToolsVersion = "34.0.0" minSdkVersion = 26 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "25.1.8937393" kotlinVersion = "1.8.0" }

react-native:0.73.7 java:18.0.2.1

tompsota commented 3 months ago

Hi @gkasireddy202,

Can I set kotlinVersion property in my project level(MyProject>android>build.gradle) or node_modules>freersap-react-native>android>build.gradle?

You can set it in project level, but that could affect also other packages. You would have to try and see if the project compiles successfully. It is also possible to change the kotlin version just for freerasp:

com.android.tools.r8.internal.Ub: Sealed classes are not supported as program classes when generating class files.

This is unfortunately issue with AGP version used in react-native:0:73, see this part of troubleshooting for more info and fix: https://github.com/talsec/Free-RASP-ReactNative?tab=readme-ov-file#execution-failed-for-task-freerasp-react-nativeminifyreleasewithr8

gkasireddy202 commented 3 months ago

Hi @tompsota ,

I checked the Gradle version in my project:distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip As in the Google tracker, we do not have maven in android>build.gradle.We recently targeted my project to targetSdkVersion = 34.

Screenshot 2024-08-06 at 5 22 14 PM
tompsota commented 3 months ago

Hi @gkasireddy202,

you can place following dependency into android/build.gradle like so:

buildscript {
    dependencies {
        classpath("com.android.tools:r8:8.3.37")
    }
}

Screenshot 2024-08-06 at 15 39 04

After that, the project should compile in release build.

Or alternatively, place the code from the Google issue tracker into android/settings.gradle

Best, Tomas from Talsec

msikyna commented 3 months ago

Hello @gkasireddy202,

did the proposed solution worked? Thank you!

Kind regards, Talsec team

gkasireddy202 commented 3 months ago

@msikyna - Yes. It is working fine now.