"duplicate entry: com/google/android/gms/internal/zzfkt.class" - react-native

I'm trying to build a React Native project on Android, but I'm running into all sorts of Android dependency issues. Currently, I'm seeing this error:
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzfkt.class
Here is my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
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"
}
maven {
url 'https://maven.google.com'
}
maven {
url "$rootDir/../node_modules/react-native-background-geolocation-android/android/libs"
}
maven {
url "$rootDir/../node_modules/react-native-background-fetch/android/libs"
}
}
}
ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "26.0.2"
supportLibVersion = "26.1.0"
playServicesVersion = "11.8.0"
}
And my app/build.gradle:
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
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.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
targetSdkVersion rootProject.targetSdkVersion
applicationId "com.gonote"
minSdkVersion 16
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
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 'com.google.firebase:firebase-core:10.0.1' //this decides your firebase SDK version
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile project(':react-native-svg')
compile project(':react-native-sms')
compile project(':react-native-image-resizer')
compile project(':react-native-image-picker')
compile project(':react-native-fcm')
compile project(':react-native-device-info')
compile project(':react-native-contacts')
compile project(':react-native-background-geolocation-android')
compile project(':react-native-background-fetch')
compile project(':react-native-android-location-services-dialog-box')
compile project(':react-native-device-info')
compile project(':react-native-contacts')
compile project(':react-native-android-location-services-dialog-box')
compile project(':react-native-background-fetch')
compile project(':react-native-background-fetch')
compile project(':react-native-background-geolocation-android')
compile project(':react-native-background-geolocation-android')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.android.support:appcompat-v7:$rootProject.supportLibVersion"
}
// 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'
}
This error message gives me very little to go on. From what I've found searching google is it's caused by some kind of google play services version mismatch, but I have no idea how I'm supposed to find it in this mess.

This bug is related to different versions of gms module required by different libraries that you use in the project. Please check this article for the best explanation on how to fix it: https://medium.com/#suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f

Related

Android dependency 'com.google.firebase:firebase-iid' has different version for the compile (16.0.0) and runtime (18.0.0) classpath

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]"
}

Generate Android APK compileReleaseJavaWithJavac error

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 !

React-native build android fail dismatch react-native module complie version and runtime version error

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.

after install of react-native-camera accured this error. tried to change versions and sdk tools as suggested in some answers on git but no sollution

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'
}
}

Error when running app with react-native-maps, Execution failed for task: ':app:transformClassesWithInstantRunForDebug'

I'm trying to add the package 'react-native-maps' to my app.
I started by following the installation guide till I got to the point where I could run the app on my device, but with the map showing only a blank white background and a red border around it. then I looked up those issues: #118 and #684 but I had no luck.
I tried to reset my local repo and redo it using this guide. and I ended up having the following error for which I found no clue yet:
Error:FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithInstantRunForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Failed to find byte code for com/google/android/gms/maps/GoogleMap$OnPoiClickListener
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 7s
my android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.android.tools.build:gradle:3.1.0'
//classpath 'com.android.tools.build:gradle:2.3.3'
//classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
// 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"
}
}
}
my android/app/build.gradle:
...
...
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
dexOptions {
jumboMode true
}
defaultConfig {
applicationId "com.friendture"
minSdkVersion 16
targetSdkVersion 25
versionCode 19
versionName "1.9"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
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"
}
}
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]
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
}
}
}}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-appsee')
compile project(':react-native-contacts')
compile project(':react-native-fbsdk')
compile project(':react-native-fetch-blob')
compile project(':react-native-image-picker')
compile project(':react-native-image-crop-picker')
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':react-native-fabric')
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.android.support:multidex:1.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true
}
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile 'com.google.android.gms:play-services-auth:9.0.0' // should be at least 9.0.0
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:9.0.0'
implementation 'com.google.android.gms:play-services-maps:9.0.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'
}
UPDATE:
I reached the point where the app loads the packager %99.9 then crashes, here's the log I get on the crash:
FATAL EXCEPTION: Thread-6
Process: com.friendture, PID: 7497
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/GoogleMap$OnPoiClickListener;
at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
at com.facebook.react.ReactInstanceManager.createAllViewManagers(ReactInstanceManager.java:660)
at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:220)
at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:75)
at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:152)
at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:149)
at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:81)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1009)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:933)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109)
at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:743)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.GoogleMap$OnPoiClickListener" on path: DexPathList[[zip file "/data/app/com.friendture-SzJNEe1uEBVylMi5o8IdBQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.friendture-SzJNEe1uEBVylMi5o8IdBQ==/lib/x86, /data/app/com.friendture-SzJNEe1uEBVylMi5o8IdBQ==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39) 
at com.facebook.react.ReactInstanceManager.createAllViewManagers(ReactInstanceManager.java:660) 
at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:220) 
at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:75) 
at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:152) 
at com.facebook.react.CoreModulesPackage$8.get(CoreModulesPackage.java:149) 
at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:81) 
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106) 
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1009) 
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:933) 
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109) 
at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:743) 
at java.lang.Thread.run(Thread.java:764)
Please feel free to ask for any other related information.
Majority of the time the issue is related to version of the various services being installed. As of today I used the latest ver for this service " implementation 'com.google.android.gms:play-services-maps:16.1.0", ie '16.1.0' and the error is gone and build successful