1

App builds and runs fine from Android Studio, but after I build signed APK and upload to Google Play Store, download from Play Store onto device and the app will crash on the initial launch. Subsequent launches of the app run fine.

Here is the logcat from the initial launch crash.

--------- beginning of crash
08-02 14:47:05.629 8343-8343/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.company.app, PID: 8343
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
        at com.google.android.gms.internal.zzark.zzbl(Unknown Source)
        at com.google.android.gms.analytics.CampaignTrackingReceiver.onReceive(Unknown Source)
        at host.exp.exponent.referrer.InstallReferrerReceiver.onReceive(InstallReferrerReceiver.java:34)
        at android.app.ActivityThread.handleReceiver(ActivityThread.java:3165)
        at android.app.ActivityThread.-wrap18(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1630)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6351)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.company.app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.company.app-1/lib/arm, /data/app/com.company.app-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.android.gms.internal.zzark.zzbl(Unknown Source) 
        at com.google.android.gms.analytics.CampaignTrackingReceiver.onReceive(Unknown Source) 
        at host.exp.exponent.referrer.InstallReferrerReceiver.onReceive(InstallReferrerReceiver.java:34) 
        at android.app.ActivityThread.handleReceiver(ActivityThread.java:3165) 
        at android.app.ActivityThread.-wrap18(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1630) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6351) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:786) 

And here is the build.gradle

def DEFAULT_COMPILE_SDK_VERSION             = 27
def DEFAULT_BUILD_TOOLS_VERSION             = "27.0.3"
def DEFAULT_TARGET_SDK_VERSION              = 26
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "15.0.1"

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
// apply plugin: 'com.neenbedankt.android-apt'

def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
    buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

    defaultConfig {
        applicationId 'com.company.app'
        targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
        versionCode 26
        versionName '0.2.6'
        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 {
        keepRuntimeAnnotatedClasses false
        jumboMode true
        javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
    }
    signingConfigs {
        debug {
            storeFile file('../debug.keystore')
        }
        release {
          storeFile file(keystoreProperties['storeFile'])
          storePassword keystoreProperties['storePassword']
          keyAlias keystoreProperties['keyAlias']
          keyPassword keystoreProperties['keyPassword']
        }

    }
    flavorDimensions 'default'
    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
            dimension 'default'
        }
        devRemoteKernel {
            minSdkVersion 21
            dimension 'default'
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 21
            dimension 'default'
        }
    }
    buildTypes {
        debug {
            debuggable true
        }
        release {
            minifyEnabled false
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.release
        }
    }
    lintOptions {
        abortOnError false
    }
    packagingOptions {
        pickFirst "**"
    }
}

apply from: 'expo.gradle'

dependencies {
    def googlePlayServicesVersion = rootProject.hasProperty("googlePlayServicesVersion")  ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    implementation project(":react-native-firebase")
    implementation fileTree(include: ["*.jar"], dir: "libs")
    implementation"com.android.support:multidex:1.0.3"


    // Our dependencies
    implementation ("com.google.android.gms:play-services-base:$googlePlayServicesVersion"){ force = true }
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
    // Our dependencies from ExpoView
    // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
    implementation"com.android.support:appcompat-v7:27.1.1"
    implementation"com.facebook.android:facebook-android-sdk:4.7.0"
    implementation 'com.facebook.android:audience-network-sdk:4.28.2'
    compileOnly "org.glassfish:javax.annotation:3.1.1"
    implementation"com.jakewharton:butterknife:7.0.1"
    implementation"de.greenrobot:eventbus:2.4.0"
    implementation"com.amplitude:android-sdk:2.9.2"
    // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
    implementation"com.squareup.picasso:picasso:2.5.2"
    implementation("com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"){ force = true }
    // implementation("com.google.android.gms:play-services-analytics:12.0.1"){ force = true }
    implementation("com.google.android.gms:play-services-maps:$googlePlayServicesVersion"){ force = true }
    // implementation("com.google.android.gms:play-services-auth:$googlePlayServicesVersion"){ force = true }
    implementation("com.google.android.gms:play-services-location:$googlePlayServicesVersion"){ force = true }
    // implementation("com.google.android.gms:play-services-ads:$googlePlayServicesVersion"){ force = true }

    annotationProcessor "com.raizlabs.android:DBFlow-Compiler:2.2.1"
    implementation"com.raizlabs.android:DBFlow-Core:2.2.1"
    implementation"com.raizlabs.android:DBFlow:2.2.1"
    implementation"com.madgag.spongycastle:core:1.53.0.0"
    implementation"com.madgag.spongycastle:prov:1.53.0.0"
    debugImplementation "com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1"
    // debugImplementation "com.squareup.leakcanary:leakcanary-android:1.4-beta1"
    releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1"
    implementation "com.facebook.device.yearclass:yearclass:1.0.1"
    implementation "commons-io:commons-io:1.3.2"
    implementation "me.leolin:ShortcutBadger:1.1.4@aar"
    implementation "com.nostra13.universalimageloader:universal-image-loader:1.9.5"
    implementation "com.theartofdev.edmodo:android-image-cropper:2.4.7"
    implementation "com.yqritc:android-scalablevideoview:1.0.1"
    implementation "commons-codec:commons-codec:1.10"
    implementation "com.segment.analytics.android:analytics:4.3.0"
    implementation "com.google.zxing:core:3.2.1"
    implementation "net.openid:appauth:0.4.1"
    implementation("com.airbnb.android:lottie:2.5.5") {
        exclude group: "com.android.support", module: "appcompat-v7"
    }
    implementation"io.branch.sdk.android:library:2.17.1"
    implementation("io.nlopez.smartlocation:library:3.2.11") {
        transitive = false
    }
    implementation"com.android.support:exifinterface:27.1.1"
    implementation"com.squareup.okhttp3:okhttp:3.4.1"
    implementation"com.squareup.okhttp3:okhttp-urlconnection:3.4.1"
    implementation"com.squareup.okhttp3:okhttp-ws:3.4.1"
    implementation"com.squareup.okio:okio:1.9.0"
    // Testing
    androidTestImplementation"com.android.support.test.espresso:espresso-core:3.0.1"
    // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
    androidTestImplementation "com.android.support.test:runner:1.0.1"
    androidTestImplementation "com.android.support:support-annotations:27.1.1"
    androidTestImplementation "com.google.code.findbugs:jsr305:3.0.0"
    androidTestImplementation "com.android.support.test.uiautomator:uiautomator-v18:2.1.1"
    androidTestImplementation "com.azimolabs.conditionwatcher:conditionwatcher:0.2"
    testImplementation "junit:junit:4.12"
    testImplementation "org.mockito:mockito-core:1.10.19"
    testImplementation "org.robolectric:robolectric:3.8"
    implementation("host.exp.exponent:expoview:28.0.0@aar") {
        transitive = true
    }

    implementation project(":react-native-twilio-video-webrtc")

    // implementation "me.leolin:ShortcutBadger:1.1.21@aar" // <-- Add this line if you wish to use badge on Android

    implementation "com.android.support:design:27.1.1"
}

// This has to be down here for some reason
apply plugin: 'com.google.gms.google-services'

Any thoughts would be much appreciated!

slvtrs
  • 31
  • 6
  • 2
    https://stackoverflow.com/questions/49818415/android-3-1-1-failed-resolution-of-lcom-google-android-gms-common-internal-zz seems like the same issue. – Sudhi Aug 02 '18 at 18:59
  • Thanks, that is a very similar problem, but none of those solutions have worked for me- all of my play-services are version 15.0.1 (within sub-projects as well), and replacing them with the "bundle services dependency" version 12.0.1 or 15.0.1 alerts "dependency not found". – slvtrs Aug 03 '18 at 11:28
  • 1
    Finally got it- my issue did pertain to play-services, but a missing dependency rather than a version conflict. My stack track pointed to `com.google.android.gms.analytics`, which I had removed because 12.0.1 caused issues and 15.0.1 does not exist. Turns out expo requires this dependency though, so I got it working with `com.google.android.gms:play-services-analytics:16.0.1` – slvtrs Aug 03 '18 at 12:51
  • thank you @slvtrs! I would have struggled without your comment. I had `java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/measurement/zzv;`. From your work, I tracked down that it was due to excluding `com.google.android.gms` from `com.google.firebase:firebase-core`. Resolved by adding `com.google.android.gms:play-services-measurement-api:16.0.1`, in addition to the `-auth`, `-iid`, `-gcm` I was already bringing in – Christian Chown Nov 17 '18 at 18:26

0 Answers0