'Problem gradle react-native for run android
I have ejected Expo from my project to run it on react-native. the problem is run-android doesn't work and it has gradle problem.
here is my terminal result :
> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 12 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'lasttry'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find gradle-4.2.2.jar (com.android.tools.build:gradle:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.jar
> Could not find builder-4.2.2.jar (com.android.tools.build:builder:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.2.2/builder-4.2.2.jar
> Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
> Could not find aapt2-proto-4.2.2-7147631.jar (com.android.tools.build:aapt2-proto:4.2.2-7147631).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-proto/4.2.2-7147631/aapt2-proto-4.2.2-7147631.jar
> Could not find databinding-compiler-common-4.2.2.jar (androidx.databinding:databinding-compiler-common:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/4.2.2/databinding-compiler-common-4.2.2.jar
> Could not find sdklib-27.2.2.jar (com.android.tools:sdklib:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/27.2.2/sdklib-27.2.2.jar
> Could not find protos-27.2.2.jar (com.android.tools.analytics-library:protos:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/27.2.2/protos-27.2.2.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'lasttry'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find gradle-4.2.2.jar (com.android.tools.build:gradle:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.jar
> Could not find builder-4.2.2.jar (com.android.tools.build:builder:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.2.2/builder-4.2.2.jar
> Could not find bundletool-1.1.0.jar (com.android.tools.build:bundletool:1.1.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/1.1.0/bundletool-1.1.0.jar
> Could not find aapt2-proto-4.2.2-7147631.jar (com.android.tools.build:aapt2-proto:4.2.2-7147631).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-proto/4.2.2-7147631/aapt2-proto-4.2.2-7147631.jar
> Could not find databinding-compiler-common-4.2.2.jar (androidx.databinding:databinding-compiler-common:4.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/databinding/databinding-compiler-common/4.2.2/databinding-compiler-common-4.2.2.jar
> Could not find sdklib-27.2.2.jar (com.android.tools:sdklib:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/sdklib/27.2.2/sdklib-27.2.2.jar
> Could not find protos-27.2.2.jar (com.android.tools.analytics-library:protos:27.2.2).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/analytics-library/protos/27.2.2/protos-27.2.2.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
at makeError (D:\project\last\lasttry\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at D:\project\last\lasttry\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (D:\project\last\lasttry\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (D:\project\last\lasttry\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
before this i was building app on my own device connected to PC. so i never tried simulator. here is more data which might u need to see :
gradle-wrapper.properties :
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
and here is what i have tried : ./gradlew clean , running on different port, installing new project
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
