致命异常:java.lang.NoClassDefFoundError com.google.android.gms.internal.firebase-perf.zzw

时间:2022-08-13 21:11:40

Getting this Error on app launch.

在应用启动时出现此错误。

Fatal Exception: java.lang.NoClassDefFoundError: com.google.android.gms.internal.firebase-perf.zzw at com.google.firebase.perf.metrics.Trace.start(Unknown Source) at com.google.android.gms.internal.firebase-perf.zze.onActivityStarted(Unknown Source) at android.app.Application.dispatchActivityStarted(Application.java:205) at android.app.Activity.onStart(Activity.java:1156) at android.support.v4.app.FragmentActivity.onStart(Unknown Source) at android.support.v7.app.AppCompatActivity.onStart(Unknown Source) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1268) at android.app.Activity.performStart(Activity.java:6333) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2542) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2671) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1501) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5774) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)

致命异常:com.google.android.gms上的com.google.firebase.perf.metrics.Trace.start(未知来源)中的java.lang.NoClassDefFoundError:com.google.android.gms.internal.firebase-perf.zzw .internal.firebase-perf.zze.onActivityStarted(未知来源)位于android.app.App.d.A活动开始时在Android.app.App位于android.app.A.StartAsestart(未知来源)的android.app.Istrumentation.callActivityOnStart(Instrumentation.java:1268)的android.app.Activity.performStart上的android.support.v7.app.AppCompatActivity.onStart(未知来源) Activity.java:6333)在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2671)的android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2542)android.app.ActivityThread.-wrap11(ActivityThread.java)在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1501)在android.os.Handler.dispatchMessage(Handler.java:111)android.os .Looper.loop(Looper.java:207)位于com.android.internal.os的java.lang.reflect.Method.invoke(Method.java)的android.app.ActivityThread.main(ActivityThread.java:5774)。 ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:791)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)

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

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:3.2.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
        classpath 'io.fabric.tools:gradle:1.24.4'


        // 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"
        }
    }
}
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        google()
    }
}

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

//

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
apply plugin: 'io.fabric'
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.abc.xyz"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 18
        versionName "1.9"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }

//Signing configurations for build variants "release"
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.android.support.constraint:constraint-layout:1.1.2'
    compile 'com.android.support:design:27.1.1'
    compile 'com.android.support:support-v4:27.1.1'
    compile 'com.android.support:cardview-v7:27.1.1'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
    compile 'com.android.support:support-vector-drawable:27.1.1'
    compile 'com.google.firebase:firebase-crash:16.0.1'
    compile 'com.google.firebase:firebase-messaging:17.3.0'
    compile 'com.google.firebase:firebase-config:16.0.0'
    compile 'com.google.android.gms:play-services-location:15.0.1'
    compile 'com.google.android.gms:play-services-maps:15.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.firebase:firebase-auth:16.0.3'
    compile 'com.google.android.gms:play-services-auth:16.0.0'
    compile 'com.google.firebase:firebase-core:16.0.1'
    compile 'com.google.firebase:firebase-perf:16.1.0'
    compile 'com.google.android.gms:play-services-places:15.0.1'

 compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'

3 个解决方案

#1


2  

I had the same problem, although Siva Kumar's solution worked, what also worked for me was to use the latest google-services library on your project build.gradle :

我有同样的问题,虽然Siva Kumar的解决方案有效,但对我来说也有用的是在项目build.gradle上使用最新的google-services库:

dependencies {
    classpath 'com.google.gms:google-services:4.1.0'
}

#2


1  

Firebase-crash version and firebase-perf version must be lesser than or equal to the Firebase-core version so In your code just change the Firebase-crash:16.0.1 version to Firebase-crash:16.0.0 and firebase-perf:16.1.0 version to firebase-perf:16.0.0 Because your's firebase-core version is 16.0.1

Firebase-crash版本和firebase-perf版本必须小于或等于Firebase-core版本,因此在您的代码中只需将Firebase-crash:16.0.1版本更改为Firebase-crash:16.0.0和firebase-perf:16.1 .0版本到firebase-perf:16.0.0因为你的firebase-core版本是16.0.1

   compile 'com.google.firebase:firebase-perf:16.0.0'
   compile 'com.google.firebase:firebase-crash:16.0.0'

#3


-3  

As per the pre-requisites documentation on Firebase - Performance Monitoring documentation about android:

根据Firebase上的先决条件文档 - 关于android的性能监控文档:

Before you begin, you need a few things set up in your environment:

在开始之前,您需要在您的环境中设置一些内容:

A device running Android 4.0 (Ice Cream Sandwich) or newer, and Google Play services 16.1.0 or higher
The Google Play services SDK from the Google Repository, available in the Android SDK Manager
The latest version of Android Studio, version 2.2 or higher

This link explains in details for the setup.

此链接详细说明了设置。

Firebase Performance Monitoring Guide

Firebase性能监控指南

Moreover, Alex has mentioned about the way we can bring in the latest google services in build cycle by upgrading the dependency mentioned in the gradle

此外,Alex还提到了通过升级gradle中提到的依赖关系,我们可以在构建周期中引入最新的Google服务

classpath 'com.google.gms:google-services:4.1.0'

#1


2  

I had the same problem, although Siva Kumar's solution worked, what also worked for me was to use the latest google-services library on your project build.gradle :

我有同样的问题,虽然Siva Kumar的解决方案有效,但对我来说也有用的是在项目build.gradle上使用最新的google-services库:

dependencies {
    classpath 'com.google.gms:google-services:4.1.0'
}

#2


1  

Firebase-crash version and firebase-perf version must be lesser than or equal to the Firebase-core version so In your code just change the Firebase-crash:16.0.1 version to Firebase-crash:16.0.0 and firebase-perf:16.1.0 version to firebase-perf:16.0.0 Because your's firebase-core version is 16.0.1

Firebase-crash版本和firebase-perf版本必须小于或等于Firebase-core版本,因此在您的代码中只需将Firebase-crash:16.0.1版本更改为Firebase-crash:16.0.0和firebase-perf:16.1 .0版本到firebase-perf:16.0.0因为你的firebase-core版本是16.0.1

   compile 'com.google.firebase:firebase-perf:16.0.0'
   compile 'com.google.firebase:firebase-crash:16.0.0'

#3


-3  

As per the pre-requisites documentation on Firebase - Performance Monitoring documentation about android:

根据Firebase上的先决条件文档 - 关于android的性能监控文档:

Before you begin, you need a few things set up in your environment:

在开始之前,您需要在您的环境中设置一些内容:

A device running Android 4.0 (Ice Cream Sandwich) or newer, and Google Play services 16.1.0 or higher
The Google Play services SDK from the Google Repository, available in the Android SDK Manager
The latest version of Android Studio, version 2.2 or higher

This link explains in details for the setup.

此链接详细说明了设置。

Firebase Performance Monitoring Guide

Firebase性能监控指南

Moreover, Alex has mentioned about the way we can bring in the latest google services in build cycle by upgrading the dependency mentioned in the gradle

此外,Alex还提到了通过升级gradle中提到的依赖关系,我们可以在构建周期中引入最新的Google服务

classpath 'com.google.gms:google-services:4.1.0'