gradle error in android build react native - android

[x] submitting bug
[x] Android platform react-native
[x] ubuntu 16.04 LTS
I am having issue in creating build by command react-native run-android
Here i am pasted error:
$ react-native run-android Scanning folders for symlinks in
/home/pct3/webroot/Hello/node_modules (39ms) JS server already
running. Building and installing the app on the device (cd android &&
./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'Hello'.
Could not resolve all files for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.0.1.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.0.1.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
sun.security.validator.ValidatorException: No trusted certificate found
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 12s Could not install the app on the device, read the
error above for details. Make sure you have an Android emulator
running or a device connected and have set up your Android development
environment:
https://facebook.github.io/react-native/docs/getting-started.html
Your help will save my day, if you need any extra information let me know.
Github link: Issue

a fast and easy solution to this issue is as following
1- open android/build.gradle
2-replace the gradle version with an older one for example 3.0.1
example of how it should look
classpath("com.android.tools.build:gradle:3.0.1")
and boom no more issues

Delete or rename the android folder and run react-native upgrade command.

Run npm install
Change your build.gradle so it follows this format:
You can see all available artifacts at Google's Maven repository index (see below for programmatic access).
To add one of these libraries to your build, include Google's Maven repository in your top-level build.gradle file:
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must instead use:
// maven {
// url 'https://maven.google.com'
// }
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}
More info here https://developer.android.com/studio/build/dependencies

Related

Facing an error when running my android app on an emulator

Hi I'm just starting to learn how to code on android studio.
After running npm run android on my terminal, I've faced some errors which I could not solve.
The error message is as follows :
XXXX-MacBook-Pro:first-app XXXX$ npm run android
first-app#0.1.0 android /Users/XXXX/Desktop/React Native/first-app
react-native run-android
Scanning folders for symlinks in /Users/XXXX/Desktop/React
Native/first-app/node_modules (8ms) Starting JS server... Building and
installing the app on the device (cd android && ./gradlew
installDebug)...
FAILURE: Build failed with an exception.
What went wrong: Could not resolve all files for configuration
':app:_internal_aapt2_binary'. Could not find
com.android.tools.build:aapt2:3.2.0-4818971. Searched in the
following locations:
file:/Users/XXXX/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/.m2/repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/.m2/repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
file:/Users/XXXX/Desktop/React Native/first-app/node_modules/react-native/android/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/Users/XXXX/Desktop/React Native/first-app/node_modules/react-native/android/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-osx.jar
Required by:
project :app
BUILD FAILED in 3s 11 actionable tasks: 1 executed, 10 up-to-date
Could not install the app on the device, read the error above for
details.
I hope you guys can help me with it.
I managed to fix this issue by adding a line google() to ~/my-app/android/build.gradle in the following section:
allprojects {
respositories{
google() //right here
}
}
Just a guess, but I believe it is a regression to do with the new Android Studio 3.2.0 release.
This is in react native which in fact i never used, this isn't an answer but i cant comment as my reputation is too low for that(pardon me). Have you installed android build tools? The ':app:_internal_aapt2_binary' is a configuration file that the system needs to compile the application which is a part of build tools.
If you are using android studio 3.0, then in gradle , change the dependency from
compile files('xyz')
to
implementation files('xyz')

react-native run-android => Could not resolve all dependencies for configuration ':classpath'

I insert java_home in environment correctly and test it in cmd. I am connecting to the internet with the proxy and can download react-native packages. adb devices run correctly on cmd, but when running "react-native run-android" command I give below error:
D:\amoz\react-native\1\pro\test>react-native run-android
Scanning folders for symlinks in D:\amoz\react-
native\1\pro\test\node_modules (8
7ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat
install
Debug)...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.gradle.internal.reflect.JavaMethod (fi
le:/C:/Users/01/.gradle/wrapper/dists/gradle-3.5.1-
all/42vjebfdws9pjts3l4bouoq0p
/gradle-3.5.1/lib/gradle-base-services-3.5.1.jar) to method
java.lang.ClassLoade
r.getPackages()
WARNING: Please consider reporting this to the maintainers of
org.gradle.interna
l.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflect
ive access operations
WARNING: All illegal access operations will be denied in a future
release
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.3.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:2.3.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/2.3.3/gradle-2.3.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build
/gradle/2.3.3/gradle-2.3.3.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168
.243.150] failed: Connection timed out: connect
* 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: 26.739 secs
Could not install the app on the device, read the error above for
details.
Make sure you have an Android emulator running or a device connected and
have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Even I add Google() to build.gradle in allprojects{} It doesn't work again. and still giving that error.
By the way, I am using JDK version 9 and gradle version 2.3.3
Unfortunately, Jcenter blocks requests from Iran due to US sanctions. You can use Hotspot Shield to connect to Jcenter, other VPN's providers may not work correctly.
and i suggest you to update your gradle by this changes:
1- change gradle version to classpath 'com.android.tools.build:gradle:3.1.1' in android/build.gradle
2- change distributionUrl from android/gradle/wrapper/gradle-wrapper.properties to distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
3- add repository to android/build.gradle like this:
repositories {
mavenLocal()
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
}
4- start Hotspot Shield and build project.
I hope this may help you.

Could not resolve all dependencies for configuration ':androidRuntimeNoRetrolambdaCopy'. Could not find com.android.support:multidex:1.0.1

After Run /gradle Android to deploy the Gluon app in my Android Phone. I have this error:
org/controlsfx/control/spreadsheet/SpreadsheetColumn$$Lambda$1
Saving lambda class: org/controlsfx/control/textfield/TextFields$$Lambda$1
:mergeClassesIntoJar
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture snapshot of input files for task 'mergeClassesIntoJar' during up-to-date check.
> java.io.FileNotFoundException: /Users/yotti/Library/Android/sdk/extras/android/support/multidex/library/libs/android-support-multidex.jar (No such file or directory)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
After update the JFXPlugin like in the Image ,i have this error
A problem occurred configuring root project 'SingleViewProject'.
Could not resolve all dependencies for configuration ':androidRuntimeNoRetrolambdaCopy'.
Could not find com.android.support:multidex:1.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/multidex/1.0.1/multidex-1.0.1.pom
https://jcenter.bintray.com/com/android/support/multidex/1.0.1/multidex-1.0.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/support/multidex/1.0.1/multidex-1.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/support/multidex/1.0.1/multidex-1.0.1.jar
Required by:
:SingleViewProject:unspecified
It was already mentioned in this question, Android obsolete library Android Support Library is no longer available.
Using jfxmobile plugin version 1.3.1 solves the issue, as it uses the multidex library that should be found here: ANDROID_HOME/extras/android/m2repository/com/android/support/multidex/1.0.1/multidex-1.0.1.aar.
Note you need to install with the Android SDK Manager both Extras/Google Repository and Extras/Android Support Repository.
Also is advisable to create a properties file with the ANDROID_HOME variable, under /Users/<user>/.gradle/gradle.properties:
ANDROID_HOME=/Users/yotti/Library/Android/sdk
and remove the line in the build.gradle -> jfxmobile -> android -> androidSdk.
As for the Charm dependencies you are using the wrong repository, you need:
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
Finally, you don't show a ControlsFX dependency, so it is not possible to have the exception posted in the first place.

React Native: Could not resolve all dependencies for configuration

I just started with React native.
I've follow this article: https://facebook.github.io/react-native/docs/getting-started.html
I run my application with command: react-native run-android but it show an exception:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project
Could not resolve all dependencies for co
Could not resolve com.android.tools.bu
Required by:
:abcdefgg:unspecified
Could not resolve com.android.tools
Could not get resource 'https:// /build/gradle/1.3.1/gradle-1.3.1.pom'.
Could not GET 'https://jcente /gradle/1.3.1/gradle-1.3.1.pom'.
Connection to https://jcen
Try: Run with --stacktrace option to get the sta option to get more log output.
BUILD FAILED
How can i resolve this problem? I've read many articles here, Local Maven repository for Support Library has been installed in my computer.
Thanks very much!
I just solve this problem this morning.
If you noticed there is a list of dependencies map defined in settings.gradle inside android folder.
Here is what I did:
Go to android folder
Run this command ./gradlew installDebug --info
And then it will show a list of dependencies that android need. It also show which dependencies are not resolved.
In my case I'm lack of 'react-native-network-info' so all I need to do is npm install that package.
Maybe your situation will difference but I think this can help you.
In react-native this problem is due to flipper dependencies, it is solved by increasing its version to 0.105.0. (file: gradle.properties)

Could not resolve all dependencies for configuration ':_armv7DebugCompile'

The following error occurs when trying to build an android app with cordova and the cordova-crosswalk plugin:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugCompile'.
> Could not find any version that matches com.android.support:support-v4:+.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
https://repo1.maven.org/maven2/com/android/support/support-v4/
https://download.01.org/crosswalk/releases/crosswalk/android/maven2/com/android/support/support-v4/maven-metadata.xml
https://download.01.org/crosswalk/releases/crosswalk/android/maven2/com/android/support/support-v4/
Required by:
:android:unspecified
* 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: 2.918 secs
/home/remi/dev/git/gitlab/sirap-sas/tereo-mobile/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /home/remi/dev/git/gitlab/sirap-sas/tereo-mobile/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/remi/dev/git/gitlab/sirap-sas/tereo-mobile/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true
ERROR running one or more of the platforms: Error: /home/remi/dev/git/gitlab/sirap-sas/tereo-mobile/platforms/android/cordova/run: Command failed with exit code 1
You may not have the required environment or OS to run this project
Please notice that section:
Could not resolve all dependencies for configuration ':_armv7DebugCompile'.
It can happen because building an android project with the crosswalk plugin try to build two apks : one for ARM, the other for x86.
The solution is to install Android Support Repository :
Open the SDK manager (from command line, type android).
Under Extras, Make sure you have Android Support Repository and Google Repository downloaded.
Update answer
Seems starting from crosswalk 16, Android Support Repository and Google Repository is not enough.
You need to install Local Maven repository for Support Libraries from Extras as well.
for me Solution was:
i updated crosswalk to #15.44.384.13
ionic browser add crosswalk#15.44.384.13
then i changed config.xml:
<preference name="xwalkVersion" value="15+" />
cuz versions "16+" - "18+" not work for me
It may be the problem when you did not include google support respository and android support repository under extras. as well as when you not update the cordova with your cordova platform.because cordova and cordova platform must be use latest version.update your Cordova with npm update cordova -g --save and cordova platform with cordova platform update platform_name(like android).
This worked for me
1.goto platforms\android\cordova-plugin-crosswalk-webview folder
2.Open .gradle file
3.find
dependencies { compile xwalkSpec }
and replace with
dependencies {
compile 'org.xwalk:xwalk_core_library:22.52.561.4'
}
**
note: 22.52.561.4 is version of crasswalk on your machine
to know it , open ionic app , chrome://inspect then
window.navigator.userAgent
This will print some lines , copy xwalk details from there
I know it's a little late to add an answer. but I faced this issue for a long time and none of these steps fixed it. If your IP is from Iran, then you should build your project with VPN on. It seems that dependencies are banned for some countries.

Categories

Resources