0

I am NOT using firebase, which seems to be the cause of the problem for other people Here is screenshot of the error:

enter image description here

Here is my dependency list:

dependencies {
    implementation project(':react-native-connectivity-status')
    implementation project(':react-native-i18n')
    implementation project(':react-native-svg')
    implementation project(':react-native-extra-dimensions-android')
    implementation project(':react-native-google-analytics-bridge')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-spinkit')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-picker')
    implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.facebook.react:react-native:+'
    // From node_modules
    implementation 'com.facebook.fresco:fresco:1.3.0'
    implementation 'com.facebook.fresco:animated-gif:1.3.0'
    implementation project(':blelibrary')
    implementation project(':gaialibrary')
    implementation project(':vmupgradelibrary')
    implementation 'com.google.code.gson:gson:2.8.4'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation project(':react-native-connectivity-status')

    implementation("com.google.android.gms:play-services-basement:15.0.1")
    implementation("com.google.android.gms:play-services-base:15.0.1")
} 

and more information

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.someapp"
        minSdkVersion 19
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 28
        versionName "1.2.4"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        packagingOptions {
            exclude "lib/arm64-v8a/libgnustl_shared.so"
        }
        externalNativeBuild {
            cmake {
                arguments '-DANDROID_STL=c++_static'
            }
        }
    }

What is the best way to determine which dependencies are causing the error to appear?

Here's the build.gradle at the root level.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {

        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        // classpath 'com.google.gms:google-services:4.2.0'
        // 4.2.0 is the latest version of com.google.gms:google-services:4.2.0 as of Jan 15, 2019

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '15.0.1'
                }
            }
        }
        // Add jitpack repository (added by react-native-spinkit)
        maven { url "https://jitpack.io" }
        mavenLocal()

        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'
        }
        jcenter()
    }

}

I've also updated the Main.Application.java file as instructed by Andrew.

VK1
  • 1,676
  • 4
  • 28
  • 51

2 Answers2

1

This looks like a dex issue.

As you are targeting a minSDKVersion of 19 you need to add the following to your dependencies

implementation 'com.android.support:multidex:1.0.3'

I see that you have already enabled multidex in your defaultConfig, but have you made the required changes to your MainApplication.java?

You also need to change the following line in your MainApplication.java from

public class MainApplication extends Application implements ReactApplication {

to

public class MainApplication extends MultiDexApplication implements ReactApplication {

You can read more about enabling multidex here https://developer.android.com/studio/build/multidex as there are different ways to enable it depending on whether you override the Application class.

Andrew
  • 26,706
  • 9
  • 85
  • 101
  • Thank you for answering me. When I combined your answer with Ankush's answer, I was able to get it to build. At first I got an error like multidex symbol isn't recognized..then i realized I forgot to import at the top of the file. Thanks again! – VK1 Jan 15 '19 at 09:09
1

You have implementation project(':react-native-google-analytics-bridge') in your gradle file and if you open the project dependency, you would see that it is using implementation "com.google.android.gms:play-services-analytics:${safeExtGet('googlePlayServicesVersion', '+')}". That is where the problem lies. You are using a different version in dependencies of gradle. You can either use the dependency resolution

    allprojects {
    repositories {
    //start here
    configurations.all {
 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
   def requested = details.requested
       if (requested.group == 'com.google.android.gms') {
          details.useVersion '15.0.1'
       }
       }
     }
    //end
     jcenter()
       maven {
         url "https://maven.google.com"
       }
     }
 }

or can use the default + version for implementation("com.google.android.gms:play-services-basement:15.0.1") implementation("com.google.android.gms:play-services-base:15.0.1"). Remember to keep the versions same.

Ankush Sharma
  • 913
  • 11
  • 20
  • When I tried adding the dependency resolution, I got an error in android studio saying that "Could not find com.google.android.gms:play-services-analytics:15.0.1." – VK1 Jan 15 '19 at 08:48
  • I've updated the original post to reflect the changes that were instructed – VK1 Jan 15 '19 at 08:52
  • @vk1 ya because that version of services-analytics might not be available. Instead of `15.0.1`, use `+` – Ankush Sharma Jan 15 '19 at 09:00
  • It worked when I added the '+' instead of 15.0.1. Thanks a bunch! – VK1 Jan 15 '19 at 09:08