为什么我得到' java.lang.NoSuchMethodError:没有虚方法zzUV()Ljava / lang / String;'?

时间:2017-05-17 10:10:23

标签: android firebase firebase-authentication nosuchmethoderror

我有一个包含Firebase的应用程序,现在应用程序在运行时崩溃,发出此错误:java.lang.NoSuchMethodError: No virtual method zzUV()Ljava/lang/String; in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.xxx.abc-2/split_lib_dependencies_apk.apk:classes34.dex)

在下面指定的行上:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Fabric.with(this, new Crashlytics());

        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);            
        setSupportActionBar(toolbar);

        uploadLocationBtn = (AppCompatButton) findViewById(R.id.upload_location);

        uploadLocationBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Construct an intent for the place picker
                try {
                    PlacePicker.IntentBuilder intentBuilder =
                            new PlacePicker.IntentBuilder();
                    Intent intent = intentBuilder.build(MainActivity.this);
                    // Start the intent by requesting a result,
                    // identified by a request code.
                    startActivityForResult(intent, PLACE_PICKER_REQUEST);

                } catch (GooglePlayServicesRepairableException e) {
                    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                    // ...
                } catch (GooglePlayServicesNotAvailableException e) {
                    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                    // ...
                }
            }
        });

        // error on this line below
        auth = FirebaseAuth.getInstance();
        if (auth.getCurrentUser() != null) {
            // already signed in
            Toast.makeText(getBaseContext(), "Hello, " + auth.getCurrentUser().getDisplayName(), Toast.LENGTH_SHORT).show();
            logUser();
        } else {
            // not signed in
            Intent intent = new Intent(MainActivity.this, SignUpActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);

            Toast.makeText(getBaseContext(), "sent from 2", Toast.LENGTH_SHORT).show();
        }

    }

此处build.gradle(模块:应用):

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.xxx.abc"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.firebaseui:firebase-ui-auth:1.2.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
    compile 'com.google.firebase:firebase-database:10.2.4'
    compile 'com.google.android.gms:play-services-location:10.2.4'
    compile 'com.google.android.gms:play-services-places:10.2.4'
}

apply plugin: 'com.google.gms.google-services'

此处&{39} build.gradle(项目:projectName):

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

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'io.fabric.tools:gradle: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.fabric.io/public' }
    }
}

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

为什么我收到此错误?这里出了什么问题?

1 个答案:

答案 0 :(得分:-1)

看起来像是指数问题。

整合Google Play服务时,最好启用MultiDex功能。

请参阅Enabling MultiDex - stackoverflow以了解如何启用MultiDex。

请参阅MultiDex - android official以了解有关MultiDex的更多信息。