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
Related
Bug Report
I've started learning React Native Navigation and I failed to launch the app with the implementation of basic navigation code.
Steps to reproduce
Run : npm install --save react-native-navigation.
Write the code of basic navigation.
Run : npx react-native start.
Run : npx react-native run-android.
Expected Behaviour
Current Behaviour
alaeddine#Ala-Dev:~/Apps/GitaApp$ npx react-native run-android
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Starting JS server...
info Installing the app...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 up-to-date
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/alaeddine/Apps/GitaApp/node_modules/react-native-navigation/lib/android/app/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Plugin with id 'kotlin-android' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 10s
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 app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file '/home/alaeddine/Apps/GitaApp/node_modules/react-native-navigation/lib/android/app/build.gradle' line: 5
* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Plugin with id 'kotlin-android' not found.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified. Please add it to build.gradle
* 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 10s
at makeError (/home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/alaeddine/Apps/GitaApp/node_modules/#react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
if (System.properties['os.arch'] == "aarch64") {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = "24.0.8215888"
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = "21.4.7075529"
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// 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' }
}
}
I got the same error, and this is how i solved my problem,
step-1) npm install --save react-native-navigation
step-2) npx rnn-link
if step-2 still throws erros, then follow the Manual installation to make changes in your project manually provided by the documentation:
->iOS. https://wix.github.io/react-native-navigation/docs/installing#ios
->Android. https://wix.github.io/react-native-navigation/docs/installing#android
step-3) write the code of basic navigation
step-4) Run: npm start
step-5) Run: npm run android (for androids)
1: Task failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.irozon.sneaker:sneaker:2.0.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/irozon/sneaker/sneaker/2.0.0/sneaker-2.0.0.pom
- https://repo.maven.apache.org/maven2/com/irozon/sneaker/sneaker/2.0.0/sneaker-2.0.0.pom
Required by:
project :app
Could not find com.kaopiz:kprogresshud:1.2.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/kaopiz/kprogresshud/1.2.0/kprogresshud-1.2.0.pom
- https://repo.maven.apache.org/maven2/com/kaopiz/kprogresshud/1.2.0/kprogresshud-1.2.0.pom
Required by:
project :app
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.
==============================================================================
It's not blame of Android Studio, it's just Gradle can't find your declared dependency in your maven repositories.
That library stores in jitpack repository you not declared, just declare it in repositories block in your build.gradle in app module.
maven { url 'https://jitpack.io' }
or if you use Gradle kotlin DSL
maven(url = "https://jitpack.io")
I'm trying to build and execute my cordova project, but i'm facing the error:
BUILD FAILED
Total time: 5.696 secs FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not find common.jar (android.arch.core:common:1.1.0). Searched in the following locations:
https://jcenter.bintray.com/android/arch/core/common/1.1.0/common-1.1.0.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not find common.jar (android.arch.core:common:1.1.0).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/core/common/1.1.0/common-1.1.0.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
The point is that the same project was able to build/run last week, and today dont work anymore.
Anyone had this problem and found some solution?
Open platforms/android/ then build.gradle
Add maven { url 'https://maven.google.com' } before jcenter()
allprojects
{
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
}
google() and maven { url 'https://maven.google.com' } are pointing to the same repo, google() is a Google's Maven repo shortcut. You can add google() instead of maven { url 'https://maven.google.com' } IF you are using :
Gradle >= v.4.x+
It seems the order matters,
this works for me
When I hit ionic cordova run android the following is happening:
D:\Leraning\myApp>ionic cordova build android
> cordova build android
Android Studio project detected
Running command: "C:\Program Files\nodejs\node.exe" D:\Leraning\myApp\hooks\after_prepare\010_add_platform_class.js D:\Leraning\myApp
ANDROID_HOME=C:\Users\nagasatya.mandalapu\AppData\Local\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 busy and 1 incompatible Daemons could not be reused, use --status for details
I have gradle installed and I tried by killing and restarting, but seems the same error.
update
D:\Leraning\myApp\platforms\android>gradle clean
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Connect to repo.jfrog.org:443 [repo.jfrog.org/34.233.3.28, repo.jfrog.org/52.86.234.14] failed: Read timed out
* 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 1m 23s
D:\Leraning\myApp\platforms\android>
In the below part of the code from build.gradle
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
Replace
maven {
url 'https://maven.google.com'
}
with
google()
Final part would be
repositories {
jcenter()
google()
}
I have a project that uses com.android.support.test:runner:1.0.1 which I can run and unit test using AndroidStudio but when I try to run the project using the command line I get the following errors:
$ sh gradlew :myproject:clean
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':myproject'.
> Could not resolve all dependencies for configuration ':myproject:_normalDebugAndroidTestApkCopy'.
> Could not find com.android.support:support-annotations:25.0.2.
Searched in the following locations:
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.2/support-annotations-25.0.2.pom
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/support-annotations/25.0.2/support-annotations-25.0.2.jar
file:/Users/Joan/Development/myproject/git/android-tag/src/myproject/sdk-manager/com/android/support/support-annotations/25.0.2/support-annotations-25.0.2.jar
Required by:
project :myproject
> Could not find com.android.support.test:runner:1.0.1.
Searched in the following locations:
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/runner/1.0.1/runner-1.0.1.pom
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/runner/1.0.1/runner-1.0.1.jar
file:/Users/Joan/Development/myproject/git/android-tag/src/myproject/sdk-manager/com/android/support/test/runner/1.0.1/runner-1.0.1.jar
Required by:
project :myproject
> Could not find com.android.support.test:rules:1.0.1.
Searched in the following locations:
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/rules/1.0.1/rules-1.0.1.pom
file:/Users/Joan/SDKs/android-sdk/extras/android/m2repository/com/android/support/test/rules/1.0.1/rules-1.0.1.jar
file:/Users/Joan/Development/myproject/git/android-tag/src/myproject/sdk-manager/com/android/support/test/rules/1.0.1/rules-1.0.1.jar
Required by:
project :myproject
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.437 secs
I'm using gradle 2.3.3 and for now I can not update to the latest one because of some backward compatibility issues.
how can I fix this issue?
Thanks,
It looks like that you missed the maven { url 'https://maven.google.com' } in your build.gradle. That is why it only searched the maven cache.
Ensure you have something like this in your project's build.gradle:
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
Also, you can run the Gradle task as ./gradlew :myproject:clean instead of sh gradlew :myproject:clean.