Not found gradle 3.1.2 - android-gradle-plugin

I'm trying to run my react-native project ( react-native run-android ) and I get this error:
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.1.2.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar
Any help?

add google() to repositories in your project build.gr

Related

Project 'react-native-reanimated' not found in root project

In my react native project I don't have "react-native-reanimated" but when I rebuilt my project I got this error:
"Project "react-native-reanimated" was not found in the root project
So when I install ‍react-native-reanimated‍ I get an NDK install error, but when I install the ndk and get the apk from the project, the app won't open and crashes.
So I uninstalled react-native-reanimated and ndk and cmake but again I got the error "project 'react-native-reanimated' was not found in the root project"
please help me
Android Studio Error Message Picture
Possible gradle related issue - try out the solutions in this post:
Android: Project 'MyProject' not found in root project 'MyProject'
But basically, delete the .gradle folder in your project's root folder and resync gradle from Android Studio.
try to run below command
npm install --force react-native-reanimated
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
it work for me

React Native - Async Storage error when run react-native run-android

I'm trying to run react-native run-android but receive the following error:
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\#react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:26: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\#react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:34: error: cannot find symbol
#ReactModule(name = AsyncStorageModule.NAME)
^
symbol: class ReactModule
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-community_async-storage:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 16s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Things I've tried:
Reinstall node_modules
cd ./android and then ./gradlew clean
But none of them seems to work. I am glad to hear your suggestion, thank you in advance!
My version:
react-native-cli: 2.0.1
react-native: 0.61.4
android gradle plugin: 3.5.3
gradle: 5.4.1
Try with below command
react-native link #react-native-community/async-storage
feel free for doubts
Try the following solutions.
Uninstall Node Modules
Clean Gradle (cd android && gradlew clean)
now install back your modules (yarn install)
if this does not help try upgrading your packages.
yarn upgrade --pattern react-native
Open the AVD Manager and try to start your phone emulator with Cold Boot, then close all applications. Clean and compile your application again, it must work now.
Sometimes even when you clean your application, your emulator get stuck.
Annotations usually has something to do with Jetpack migrations
Try using this Jetifier tool
Just make sure to run npx jetify at the project root.
Using sudo solved the issue in my case. sudo react-native ..., sudo ./gradlew ... etc.
You can try to add this to your android/build.gradle file
allprojects {
repositories {
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
// NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
url "$rootDir/../node_modules/react-native/android"
}
}
}
mavenCentral()
mavenLocal()
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")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

React Native video build failed

after i add react native video package to my project i could'nt build the project. my rn version is 0.60.3 i have installed latest version of react-native-video . the error is
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.android.support:support-media-compat:28.0.0.
Searched in the following locations:
- file:/C:/Users/avajang-pc/.m2/repository/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.pom
- file:/C:/Users/avajang-pc/.m2/repository/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.jar
- file:/C:/Users/avajang-pc/Desktop/newSpoc/spocplus/node_modules/react-native/android/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.pom
- file:/C:/Users/avajang-pc/Desktop/newSpoc/spocplus/node_modules/react-native/android/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.jar
- file:/C:/Users/avajang-pc/Desktop/newSpoc/spocplus/node_modules/jsc-android/dist/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.pom
- file:/C:/Users/avajang-pc/Desktop/newSpoc/spocplus/node_modules/jsc-android/dist/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.jar
- https://dl.google.com/dl/android/maven2/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.pom
- https://dl.google.com/dl/android/maven2/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.jar
- https://jcenter.bintray.com/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.pom
- https://jcenter.bintray.com/com/android/support/support-media-compat/28.0.0/support-media-compat-28.0.0.jar
Required by:
project :app > project :react-native-video
i've added maven , i changed the gradle version, build tools version.
Try running this command, react-native 0.60 now uses androidX and not all libraries are update to support it (one of them is react-native-video):
npm install --save-dev jetifier && npx jetify && react-native run-android

Running react-native run-android gives error with com.google.android.gms:play-services-iid

Trying to run react-native run-android but this gives me error. The library com.google.android.gms:play-services-iid is being requested by various other libraries at [[16.0.1,16.0.1], [17.0.0,17.0.0]], but resolves to 17.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies
// build.graddle :
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/37
com.google.android.gms:play-services-measurement-base is being requested by various other libraries

react-native - unable to run sample app

Following the tutorial here, I am unable to run the app in the emulator. When I execute the react-native run-android command from the DOS prompt, here is the error I get:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'AwesomeProject'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
:AwesomeProject:unspecified
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://repo1.maven.org/maven2/com/android/to
ols/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/bu
ild/gradle/2.2.3/gradle-2.2.3.pom'.
> repo1.maven.org
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build
/gradle/2.2.3/gradle-2.2.3.pom'.
> jcenter.bintray.com
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
Things I tried:
Editing build.gradle file and changing classpath from classpath 'com.android.tools.build:gradle:2.2.3' to com.android.tools.build:gradle:3.3.0' (the version I have installed with Android Studio).
Verified that jcenter() is listed as a repository in build.gradle under both buildscript and allprojects
Try setting it to 2.3.0
Strange, I can't see any 2.2.3 in that path but I can see a 2.3.0
http://repo1.maven.org/maven2/com/android/tools/build/gradle/
I recreated the project using the react-native cli, and the issue seemed to correct itself. I should note that I believe I had not installed android studio when I initially created the project, so maybe that had something to do with it, not sure.