简体   繁体   中英

Getting Caused by: java.lang.RuntimeException: Android classes not found error. What is causing it?

I'm developing an app in which I am using firebase as BaaS .

The problem is that I am getting this error: Caused by: java.lang.RuntimeException: Android classes not found. Are you using the firebase-client-android artifact? Caused by: java.lang.RuntimeException: Android classes not found. Are you using the firebase-client-android artifact? on this line Firebase.setAndroidContext(this); .

Here's FirebaseApplication.java file's code:

public class FirebaseApplication extends android.app.Application {

    @Override
    public void onCreate() {
        super.onCreate();

        Firebase.setAndroidContext(this);

    }
}

Here's build.gradle file:

apply plugin: 'com.android.application'

    android {

        compileSdkVersion 23
        buildToolsVersion "23.0.2"
        defaultConfig {
            applicationId "com.abc.xyz"
            minSdkVersion 16
            targetSdkVersion 23
            versionCode 5
            versionName "0.4"
            multiDexEnabled true;
        }
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE-FIREBASE.txt'
            exclude 'META-INF/NOTICE'
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.config
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.google.android.gms:play-services-maps:9.0.1'
compile 'com.google.android.gms:play-services-plus:9.0.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-location:9.0.1'
compile 'com.firebase:geofire:1.1.0'
compile 'com.google.firebase:firebase-database:9.0.1'
compile 'com.google.firebase:firebase-core:9.0.1'
compile 'com.google.firebase:firebase-auth:9.0.1'
compile 'io.github.yavski:fab-speed-dial:1.0.4'
compile 'com.google.gms:google-services:3.0.0'
    }

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

I am unable to figure out the problem here.

You are using legacy Firebase, which GeoFire 1.1.0 imports (You should migrate from GeoFire 1.1.0 to Geofire 2.X aswell).

Instead of:

Firebase.setAndroidContext(this);

Use:

FirebaseApp.initializeApp(this, FirebaseOptions.fromResource(this));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM