if I try with react-native (npx react-native run-android) I have:
How to fix it??
Asked
Active
Viewed 1,190 times
1
-
[Images](//meta.stackoverflow.com/q/285551/90527) should not be used for textual data, such as code or error messages. Please look over the [help], especially the "[ask]" article. – outis Nov 07 '22 at 09:46
1 Answers
4
Add the following lines in android/build.gradle
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
}

Shivam
- 2,147
- 1
- 11
- 28
-
thanks this is solve but after I run I got this error execution failed for task ':app:checkDevDebugAarMetadata failed' – Anjali Deshmukh Nov 07 '22 at 10:18
-
-
buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 kotlinVersion = '1.6.10' kotlinCoroutinesVersion = '1.6.0' } repositories { google() mavenCentral() jcenter() } dependencies { classpath 'com.google.gms:google-services:4.3.3' classpath("com.android.tools.build:gradle:4.1.0") } } – Anjali Deshmukh Nov 07 '22 at 10:37
-
have you integrated the above code inside your `android/build.gradle` code? – Shivam Nov 07 '22 at 10:39
-
-
Yes, I add this code in build file, I think sdk version problem... – Anjali Deshmukh Nov 07 '22 at 10:42
-
the code you shared does not include def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) allprojects { configurations.all { resolutionStrategy { force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION } } } – Shivam Nov 07 '22 at 10:42
-
Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/249389/discussion-between-anjali-deshmukh-and-shivam). – Anjali Deshmukh Nov 07 '22 at 10:43