【问题标题】:Getting Caused by: java.lang.RuntimeException: Android classes not found error. What is causing it?引起:java.lang.RuntimeException:找不到Android类错误。是什么原因造成的?
【发布时间】:2016-06-02 12:44:27
【问题描述】:

我正在开发一个应用程序,我在其中使用firebase 作为BaaS

问题是我收到了这个错误:Caused by: java.lang.RuntimeException: Android classes not found. Are you using the firebase-client-android artifact? 在这条线上Firebase.setAndroidContext(this);

这是FirebaseApplication.java文件的代码:

public class FirebaseApplication extends android.app.Application {

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

        Firebase.setAndroidContext(this);

    }
}

这是build.gradle 文件:

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'

我无法找出这里的问题。

【问题讨论】:

  • 你在清单文件中注册了类吗?
  • 你能展示你的 build.gradle 文件吗?
  • @AnandBarnwal FirebaseApplication.java 不是活动。不能在清单文件中声明。
  • @HammadNasir 对不起,我的错误
  • @chrynan 请检查已编辑的问题。

标签: java android firebase firebase-realtime-database firebase-hosting


【解决方案1】:

您正在使用 GeoFire 1.1.0 导入的旧版 Firebase(您也应该从 GeoFire 1.1.0 迁移到 Geofire 2.X)。

代替:

Firebase.setAndroidContext(this);

用途:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-22
    • 1970-01-01
    • 2015-01-07
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多