React Native Could Not Find Com.android.tools.build:gradle:3.4.2
I am new to React native trying to start a new project. I followed google docs and already had the android studio installed. added ANROID_HOME to env variables and platform tools to system variables as mentioned in the docs. while running ```react-native run-android``. I get this error
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'AwesomeProject'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.4.2.
my android studio version plugin is 3.4.2 and here is my build.gradle
file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
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' }
}
}
and my gradle-wrapper.properties
file
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Answer
Thanks all for the Answers I think I will provide the answer here for others to use.
my issue was due to the version conflict of gradle and android studi plugin.
1- open android studio and start a new project
2- There should be a builde.gradle and gradle wrapper file
3- the versions you see for gradle here for e.g 5.1.1 or etc is the version you must use in your project**
4- change the classpath com.android.tools.build:gradle:to 3.4.2 in your project build.gradle file
5- change the gradle wrapper properties distribution path to distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View