We have a project, which compiles and run for everybody EXCEPT me. I have exactly the same code, I try to run it exactly the same way, but the log says:
FAILURE: Build failed with an exception.
What went wrong: Could not resolve all files for configuration ':react-native-camera:debugCompileClasspath'.
> Could not find core.jar (com.google.zxing:core:3.3.0). Searched in the following locations:
https://artifactory.mycompany.eu/artifactory/mvn-libs-all/com/google/zxing/core/3.3.0/core-3.3.0.jar
I changed the url above (only the company name), but i checked, and the jar is presented there.
This jar is necessary for react-native-camera node module.
I have already:
run npm cache clean --force
run gradlew clean
deleted the whole project, checked out the source code, installed
node modules, tried to run
But nothing helped.
EDIT:
project/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
rootProject.ext.isRelease = project.hasProperty('buildForDebug')? false:true
def RNfile = new File("$rootDir/node_modules/react-native/package.json")
rootProject.ext.rnVersion = new groovy.json.JsonSlurper().parseText(RNfile.text).version
artifactId = project.artifactId
allprojects {
println "release $isRelease"
//version = "${project.version}-${isRelease ? project.property('build.number') : 'SNAPSHOT'}"
version = "${project.version}-${ project.hasProperty('build.number') ? project.property('build.number') : '0'}"
group = project.groupId
println "coordinates: $group:$artifactId:$version"
}
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion rootProject.ext.rnVersion
}
}
}
}
repositories {
mavenLocal()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/node_modules/react-native/android"
}
}
}
subprojects { project ->
afterEvaluate {
if (project.name.contains('react-native-')) {
project.tasks.collect { task ->
if (task.name == 'lint') {
task.enabled = false
}
}
}
}
}
project/android/app/build.gradle
project.ext.androidSignKeystorePassword = (project.hasProperty('keystorePassword'))? project.property('keystorePassword') : System.properties['android.keystorePassword']
project.ext.androidSignKeyPassword = (project.hasProperty('keyPassword'))? project.property('keyPassword') : System.properties['android.keyPassword']
project.ext.androidSignKeyAlias = (project.hasProperty('keyAlias'))? project.property('keyAlias') : System.properties['android.keyAlias']
configurations {
keystore
}
dependencies {
keystore "eu.dorsum.cm.config:jenkins-android-keystore:1#jks"
}
rootProject.ext.signApp = project.hasProperty('signKeyAlias') && project.hasProperty('keystore-android-password')
buildscript {
repositories {
google()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:4.1.0'
}
}
allprojects {
repositories {
mavenLocal()
google()
maven {
url "https://maven.google.com"
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion rootProject.ext.rnVersion
}
}
}
}
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
import com.android.build.OutputFile
project.ext.react = [
root: "$rootDir",
entryFile: "index.js"
]
apply from: "$rootDir/node_modules/react-native/react.gradle"
apply from: "$rootDir/node_modules/react-native-vector-icons/fonts.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.dbit"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName project.version
ndk {
abiFilters "armeabi-v7a", "x86"
}
if (!project.hasProperty('buildForDebug')) {
archivesBaseName = "${rootProject.name}-${versionName}"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
storeFile files(project.configurations.keystore.collect { it }).singleFile
storePassword project.ext.androidSignKeystorePassword
keyAlias project.ext.androidSignKeyAlias
keyPassword project.ext.androidSignKeyPassword
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.release
}
}
variantFilter { variant ->
// ignores unwanted build types
// no release type from development branch, no debug type from release branch
// (ignore = release type XOR release version)
setIgnore(variant.buildType.name.equals('release') ^ isRelease)
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation project(':react-native-view-overflow')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-fcm')
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-messaging'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.0.3"
implementation "com.facebook.react:react-native:${rootProject.ext.rnVersion}" // From node_modules
implementation (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
implementation 'com.android.support:exifinterface:27.1.0'
implementation ('com.google.android.gms:play-services-vision:12.0.1') {
force = true
}
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.implementation
into 'libs'
}
If you have any suggestion, it would be highly appreciated.
I think you miss repository in Gradle to get com.google.zxing:core:3.3.0
You need open Android Studio with project in folder /android of your react-native project.
and edit file build.gradle of project
like this
and add google() and jcenter() to respository of buildscript and allprojects
like this
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
In my case the solution was running the following command in the projectName/android folder:
gradlew cleanBuildCache
The strange thing for me is that gradlew clean was not enough.
According to this documentation https://developer.android.com/studio/build/build-cache#clear_the_build_cache:
"Similar to the Android plugin's clean task that clears your project’s
build/ directories, you can run the cleanBuildCache task to clear your
project’s build cache."
Based on this information, it is obvious that something went wrong in my build cache and that caused the problem.
I also had to delete the node_modules folder, and install all node modules again.
Related
In my react native application i am integrating react-native-push-notification and getting this error.
app/build.gradle
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-push-notification')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.0.2"
}
}
}
}
I tried various solutions like changing from "implementaion" to "api" , in configuration.all adding check to fetch particular version of firebase-core, but nothing worked.
React Native version is 0.55.4
I found the solution.
In my project's build.gradle buildscript->dependencies i replaced version of the google-services gradle plugin from "4.0.2" to "4.2.0" and it worked.
classpath 'com.google.gms:google-services:4.2.0'
The library react-native-push-notification has a dependency declared as '+' for the com.google.firebase:firebase-messaging in it's build.gradle. This will fetch the latest version of the library from maven repo.
This is clashing with your version declaration in your android/app/build.gradle file, which is 16.0.1.
Add this to your project level build.gradle
ext {
googlePlayServicesVersion = "[your_desired_version]"
firebaseVersion = "[your_desired_version]"
}
A problem occurred configuring project ':app'.
Could not resolve all artifacts for configuration ':app:classpath'.
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.11/kotlin-stdlib-jdk8-1.3.11.pom
- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.11/kotlin-stdlib-jdk8-1.3.11.jar
- https://maven.fabric.io/public/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.11/kotlin-stdlib-jdk8-1.3.11.pom
- https://maven.fabric.io/public/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.11/kotlin-stdlib-jdk8-1.3.11.jar
Required by:
project :app > com.android.tools.build:gradle:3.3.0
This stacktrace tells me that react-native is looking for Kotlin JDK for some reason. Not sure why Kotlin would be required, when everything is in Java.
I have included implementation org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11
in my app build.gradle, exactly the same version as seen in the stack dump
app build.gradle
buildscript {
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'com.recordit'
targetSdkVersion 26
minSdkVersion 16
versionCode 1
versionName '1.0.0'
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// Deprecated. Used by net.openid:appauth
manifestPlaceholders = [
'appAuthRedirectScheme': 'host.exp.exponent'
]
}
dexOptions {
javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
lintOptions {
abortOnError false
}
packagingOptions {
pickFirst "**"
}
configurations.all {
resolutionStrategy.force 'com.android.support:design:27.1.0'
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':rn-fetch-blob')
implementation project(':react-native-fs')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-radial-gradient')
implementation 'com.android.support:multidex:1.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation "com.facebook.react:react-native:+" // From node_modules
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
and project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version='1.1.1'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'de.undercouch:gradle-download-task:2.0.0'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// For non-detach
maven {
url "$rootDir/maven"
}
// For detach
maven {
url "$rootDir/../node_modules/expokit/maven"
}
maven {
// We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
url "$rootDir/maven-test"
}
maven {
url 'https://maven.google.com'
}
jcenter()
maven {
// Local Maven repo containing AARs with JSC built for Android
url "$rootDir/../home/node_modules/jsc-android/android"
}
flatDir {
dirs 'libs'
// dirs project(':expoview').file('libs')
}
maven { url "https://jitpack.io" }
// Want this last so that we never end up with a stale cache
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i am developing react native app.using google plugin project run on expo properly. when generating Android APK show error in google plugin.Example (react-native-google-places\android\src\main\java\com\arttitude360\reactnative\rngoogleplaces\RNGooglePlacesModule.java:49: error: RNGooglePlacesModule is not abstract and does not override abstract method onActivityResult(int,int,Intent) in ActivityEventListener).
Please help. Thanks in advance
Android/App/build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.projectphoto"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4' //should be 3.1.3 after the tutorial.
classpath 'com.android.support:support-media-compat:25.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-camera-kit')
compile project(':react-native-camera')
compile project(':react-native-vector-icons')
compile project(':react-native-maps')
compile project(':react-native-google-places')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation("com.google.android.gms:play-services-maps:16.0.0")
implementation("com.google.android.gms:play-services-tasks:16.0.1")
implementation("com.google.android.gms:play-services-basement:16.0.1")
implementation("com.android.support:support-v4:26.1.0")
implementation("com.android.support:support-media-compat:26.1.0")
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Android/build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}`enter code here`
Try Adding the Google Maven Repo in your android/build.gradle
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 {
url "https://maven.google.com"
}
}
}
I think you forgot to add below code in allprojects
maven {
url "https://maven.google.com"
}
Go to the module document Here as there are some new updates related to versions.
Try to keep the versions updated in your code.
Notice: The Google Play Services version of the Places SDK for Android
(in Google Play Services 16.0.0) is deprecated as of January 29, 2019,
and will be turned off on July 29, 2019. A new version of the Places
SDK for Android is now available.
Hope it works !
I build android app for debugging, script run with
cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug
not using react-native run-android because using react-native-navigation v2 from RNN recommend guide.
But, build fail with this error.
> Configure project :react-native-navigation
downloadRobolectricDependencies into /Users/ddinggu/test/android/build/robolectric-3.5.1-dependencies
> Configure project :react-native-webview
:react-native-webview:reactNativeAndroidRoot /Users/ddinggu/test/node_modules/react-native/android
> Task :app:preReleaseBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preReleaseBuild'.
> Android dependency 'com.facebook.react:react-native' has different version for the compile (0.58.4) and runtime (0.20.1) classpath.
You should manually set the same version via DependencyResolution
Also, other build types(preRelease, release) can't build with same this error.
Can't expect why occur this error because it occur after build release version android apk and not change any android code.
Please any tips what you know.
Android configs
android/app/build.gradle
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
// React-native-vectoricons
project.ext.vectoricons = [
iconFontNames: [ 'EvilIcons.ttf', 'Entypo.ttf' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.chopchopclient"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
versionCode 16
versionName "1.1.1"
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative51") || names.contains("reactNative55")) {
setIgnore(true)
}
}
}
}
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
// resolve problem : transformDexArchiveWithExternalLibsDexMergerForDebug
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-navigation')
implementation project(':react-native-inappbrowser-reborn')
implementation project(':react-native-vector-icons')
implementation project(':react-native-device-info')
implementation project(':react-native-webview')
implementation project(':react-native-splash-screen')
implementation project(':react-native-version-check')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 19
compileSdkVersion = 27
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://jitpack.io' }
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
Binaries:
Node: 10.14.2 - ~/.nvm/versions/node/v10.14.2/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.14.2/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
npmPackages:
react: ^16.8.4 => 16.8.4
react-native: 0.58.4 => 0.58.4
I solved and it just happened missmatch to RN's require compile version and my code script compile version.
Please check your RN version and android gradle compile version if anyone hard time like me.
Error:Could not find com.android.tools.build:gradle:3.1.2.
Searched in the following locations:
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar
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
Required by:
project :react-native-push-notification
Open File
my gradle-wrapper.properties-
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
my android/build.gradle-
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 26
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.1"
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "12.0.1"
def DEFAULT_SUPPORT_LIBRARY_VERSION = "27.1.0"
android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0.0"
}
lintOptions {
abortOnError false
warning 'InvalidPackage'
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com'
}
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
dependencies {
def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
def supportLibVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIBRARY_VERSION
compileOnly 'com.facebook.react:react-native:+'
compileOnly 'com.facebook.infer.annotation:infer-annotation:+'
implementation "com.google.zxing:core:3.2.1"
implementation "com.drewnoakes:metadata-extractor:2.9.1"
implementation "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
implementation "com.android.support:exifinterface:$supportLibVersion"
implementation "com.android.support:support-annotations:$supportLibVersion"
implementation "com.android.support:support-v4:$supportLibVersion"
}
my app file-
apply plugin: "com.android.application"
import com.android.build.OutputFile
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.myappname"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-camera')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-push-notification')
compile project(':react-native-maps')
compile project(':react-native-i18n')
// compile project(':react-native-vector-icons')
// compile project(':react-native-restart')
// compile project(':react-native-push-notification')
// compile project(':react-native-maps')
// compile project(':react-native-i18n')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-push-notification')
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile 'com.google.android.gms:play-services-base:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile project(':react-native-i18n')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:23.4.1"
compile ("com.facebook.react:react-native:0.53.3") { force = true } // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
def task = task(copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
})
task
myAppname file-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.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"
}
jcenter()
google()
}
}
This has something to do with versions only.
Try with the changes mentioned below and this might help.
gradle-wrapper.properties -
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
android/build.gradle -
buildscript {
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}