27

since I've updated to Android Studio 3.1, my project is not running anymore. I have searched for a solution all over the internet with no positive results. Here's the error I get in the Logcat:

 --------- beginning of crash
04-13 13:33:55.466 12720-12720/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: woopy.domain.com.woopy, PID: 12720
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/woopy.domain.com.woopy-KqNv1gE1ZomaesHCq33DJw==/base.apk"],nativeLibraryDirectories=[/data/app/woopy.domain.com.woopy-KqNv1gE1ZomaesHCq33DJw==/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.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:6239) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722) 
        at android.app.ActivityThread.-wrap1(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
04-13 13:33:55.567 12720-12727/? I/zygote: Debugger is no longer active

Here's my build.gradle (Module:app) file:

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "woopy.domain.com.woopy"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        // Enabling multidex support.
        multiDexEnabled true

        aaptOptions {
            cruncherEnabled = false
        }

    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    testImplementation 'junit:junit:4.12'
    implementation 'com.parse:parse-android:+'
    implementation 'com.parse.bolts:bolts-android:1.+'
    //noinspection GradleCompatible
    implementation 'com.google.android.gms:play-services-maps:+'
    implementation 'com.google.android.gms:play-services-auth:12.0.1'
    implementation 'com.google.android.gms:play-services-location:12.0.1'
    implementation 'com.google.android.gms:play-services:+'
    implementation 'com.google.android.gms:play-services-ads:+'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.+'
    implementation 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
    implementation 'com.commit451:PhotoView:1.2.4'

}

And here's my build.gradle (Project: appname):

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'

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

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The Build is successful, but the app crashes at startup.

EDIT: It doesn't build successful anymore now, it throws this absolutely weird error in the Build message console:

AGPBI: {"kind":"error","text":"Program type already present: com.google.android.gms.location.places.zza","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'

.

Frank Eno
  • 2,581
  • 2
  • 31
  • 54
  • One thing I did try was updating all the play-services to 15.0.0 since it was released only a few days ago. But, when using it, I kept getting an error about how my version of Google Play services was too old. – Rob Avery IV Apr 13 '18 at 20:48
  • yes, same issue. so the only solution i’ve found so far is to downgrade to AS 3.1 – Frank Eno Apr 13 '18 at 20:55
  • https://github.com/evollu/react-native-fcm/issues/998 – NehaK Aug 28 '20 at 12:49

10 Answers10

26

Try adding this dependency to your gradle file:

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

Also you should use the same versions for the support and play services libraries. And you should avoid using "+" for latest version. Change this part:

implementation 'com.google.android.gms:play-services-maps:+'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services:+'
implementation 'com.google.android.gms:play-services-ads:+'

into this:

implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'

EDIT: You may also add this part to your app level gradle file and try again. I did not see anyone tried this but it may work.

allprojects {
    repositories {
       //...
    }

    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.google.android.gms'
                && !details.requested.name.contains('multidex') ) {
                    details.useVersion "12.0.1"
                }
            }
        }
    }
}

2ND UPDATE: Just seen this, the dependency below, covers all the others, then it may cause a duplication issue. Remove the other dependencies and leave this one:

implementation 'com.google.android.gms:play-services:12.0.1'
Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52
  • it doesn’t build without that line, i tried that yesterday already :( – Frank Eno Apr 14 '18 at 09:10
  • 1
    @cubycode you should add only what you need. Remove it and add what dependency is necessary, otherwise you need to remove other play services dependencies. Because this includes all of them. – Oğuzhan Döngül Apr 14 '18 at 09:12
  • i need maps and location, but it doesn’t build if i leave them and remove services+. anyway i’ll do some other tests – Frank Eno Apr 14 '18 at 10:08
  • i’ve tried using only the bundle services dependency and removed the other play services ones on another app: it worked, so thanks so much for your help! – Frank Eno Apr 14 '18 at 12:15
8

I had the same issue and I solved it.Update all your com.google.android.gms:play-services dependencies to 15.0.0. It should look like this:

implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services:15.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.0'

Once you do that, it should fix the issue with finding the NoClassDefFoundError error (at least it did for me).

Rob Avery IV
  • 3,562
  • 10
  • 48
  • 72
  • 1
    the following dependency covers all the other ones and may cause an issue on building the project: implementation 'com.google.android.gms:play-services:15.0.0', so you either remove it or remove all the other play-services dependencies and leave that one (because it's a bundle of all play services dependencies) – Frank Eno Apr 15 '18 at 04:33
5

That worked for me I added subprojects block as below to my project gradle file

allprojects {
repositories {
   //...
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.google.android.gms'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "+"
            }

            if (details.requested.group == 'com.google.firebase'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "+"
            }
        }
    }
}
}
Daniel Raouf
  • 2,307
  • 1
  • 22
  • 28
3
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services:15.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.0'

This helped me.
RakeshKB
  • 41
  • 3
2

You may be using different verions of libraries.

Important point is you may be using an external library which is using a different play services version (may be older) . Please check care fully all external libraries updates and match them all

HarshitG
  • 2,677
  • 3
  • 16
  • 13
2

I solved it by removing

implementation "com.google.android.gms:play-services:$play_service_version"

and keeping only important dependencies.

In my case I had

implementation "com.google.android.gms:play-services:$play_service_version"
implementation "com.google.android.gms:play-services-location:$play_service"

And I removed

implementation "com.google.android.gms:play-services:$play_service_version"

and kept

implementation "com.google.android.gms:play-services-location:$play_service"

Here play_service_version & play_service are versions

Kishan Solanki
  • 13,761
  • 4
  • 85
  • 82
1

I received the same error even with the 'zzbq;' at the end

In app build.gradle I had to update my com.google.firebase:firebase-core to 16.0.1 to match the same line in the react-native-firebase build.gradle

Example:

app/build.gradle

implementation 'com.google.firebase:firebase-core:16.0.1'

react-native-firebase/android/build.gradle

compileOnly "com.google.firebase:firebase-core:16.0.1"
bo_
  • 188
  • 1
  • 8
1

I had exactly the same problem. I tried quite a few things, but here's what actually helped.

I added this to my project: implementation 'com.google.android.gms:play-services-base:16.0.1'.

The error went away.

Then I removed it. Everything was still fine. Cleaned the project - still no error.

Don't ask me for logic behind this, it just worked for me, that's all I know.

zarsky
  • 680
  • 2
  • 14
  • 24
0

@cubycode I am also running into the same issue and I tried all solutions listed here.

  • Important point is you may be using an external library which is using a different play services version (may be older) . Please check care fully all external libraries updates and match them all – HarshitG May 03 '18 at 11:07
0

Step 1:

This kind of error throw the some logs. Read it carefully to find out which dependency cause this issue

Step 2:

Update that dependency to latest version.

For ex: In my case it throw the error in material design dependency. I just update that dependency to latest version - problem solved

My error log - Didn't find class "com.google.android.material.tabs........"

Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159