com.google.firebase.provider.FirebaseInitProvider:java.lang.ClassNotFoundException:com.google.firebase.provider.FirebaseInitProvider [英] com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException:com.google.firebase.provider.FirebaseInitProvider

查看:118
本文介绍了com.google.firebase.provider.FirebaseInitProvider:java.lang.ClassNotFoundException:com.google.firebase.provider.FirebaseInitProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

KitKat 上接收到这个错误,而在Lollipop和更高版本上运行的版本更低



我在gradle和gradle中包含了所有需要的jar Firebase json文件来接收GCM。



我的应用程序gradle

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

android {
compileSdkVersion 23
buildToolsVersion24.0.0
defaultConfig {
applicationId
minSdkVersion 13
targetSdkVersion 23
versionCode 6
versionName1.6
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android。 txt'),'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
$ b useLibrary'org.apache.http.legacy'
}


依赖项{
编译fileTree(dir:' libs',包括:['* .jar'])

编译项目(':httpmime-4.2.5')
编译项目(':universal-image-loader-1.9。 3')
编译项目(':universal-image-loader-1.9.3')
编译组:'org.apache.httpcomponents',名称:'httpclient-android',版本:'4.3 .3'

compile'c​​om.android.support:appcompat-v7:23.4.0'
compile'c​​om.loopj.android:android-async-http:1.4.9'
compile'c​​om.readystatesoftware.sqliteasset:sqliteassethelper:+'

compile'c​​om.android.support:design:23.4.0'
compile'c​​om.google.android.gms :play-services:9.0.0'
testCompile'junit:junit:4.12'
}


all 的代码g> Google Play服务API:

  compile'c​​om.google.android.gms:play-services:9.0.0 '

这很可能会导致您的应用程序超过65K方法参考限制,要求您使用Multidex在预棒棒糖设备上运行。



您有两种选择。您只能包含您实际需要的Play服务API。 列表在这里标题为选择性地将API编译为可执行文件的。或者,您可以按照说明启用Multidex。尽管在build.gradle文件中有 multiDexEnabled true ,但这只是配置Multidex所需的三个步骤之一。您还需要将库包含为依赖项并更新清单。



如果您使用的是Android Studio 2.2.2,则可以看到您的方法引用有多少应用程序使用 APK分析器。从菜单栏中选择构建>分析APK。 APK位于 ... / app / build / outputs / apk 文件夹中。选择APK文件,然后在出现的窗口中,点击 classes.dex 查看方法和方法引用的数量。


Receving this error on KitKat and lower version running perfectly on Lollipop and above

I have included all the required jars in th gradle and Firebase json file to receive GCM.

my app gradle

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

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId ""
        minSdkVersion 13
        targetSdkVersion 23
        versionCode 6
        versionName "1.6"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    defaultConfig {
        multiDexEnabled true
    }
    useLibrary 'org.apache.http.legacy'
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile project(':httpmime-4.2.5')
    compile project(':universal-image-loader-1.9.3')
    compile project(':universal-image-loader-1.9.3')
    compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.3'

    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'

    compile 'com.android.support:design:23.4.0'
    compile 'com.google.android.gms:play-services:9.0.0'
    testCompile 'junit:junit:4.12'
}

解决方案

This dependency includes the code for all of the Google Play Services APIs:

compile 'com.google.android.gms:play-services:9.0.0'

This is very likely causing your app to exceed the 65K method reference limit, requiring you to use Multidex to run on pre-Lollipop devices.

You have two choices. You can include only the Play Services APIs you actually need. The list is here in the section titled Selectively compiling APIs into your executable. Or you can enable Multidex following the instructions here. Although you have multiDexEnabled true in your build.gradle file, that is only one of the three steps required to configure Multidex. You also need to include the library as a dependency and update your manifest.

If you are using Android Studio 2.2.2, you can see how many method references are in your app using the APK Analyzer. From the menubar, select Build > Analyze APK. The APK is in folder .../app/build/outputs/apk. Select the APK file, and in the resulting window, click on classes.dex to see the number of methods and method references.

这篇关于com.google.firebase.provider.FirebaseInitProvider:java.lang.ClassNotFoundException:com.google.firebase.provider.FirebaseInitProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆