Java 没有找到类“com.google.firebase.provider.FirebaseInitProvider”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39812558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Didn't find class "com.google.firebase.provider.FirebaseInitProvider"
提问by TSR
Before, my program run well. But When I just updated my Android studio to the latest version (2.2 built on 15-sept-16), I am having the following error. When I built it, it says: Built sucessfully, but this error appears when I run my program:
之前,我的程序运行良好。但是当我刚刚将我的 Android Studio 更新到最新版本(2.2 建于 15 年 9 月 16 日)时,出现以下错误。当我构建它时,它说:构建成功,但是当我运行我的程序时出现此错误:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.androidtutorial, PID: 28293 java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.androidtutorial-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.androidtutorial-2/lib/x86, /system/lib, /vendor/lib]] at android.app.ActivityThread.installProvider(ActivityThread.java:5814) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.example.androidtutorial-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.androidtutorial-2/lib/x86, /system/lib, /vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at android.app.ActivityThread.installProvider(ActivityThread.java:5799) at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403)? at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342)? at android.app.ActivityThread.-wrap2(ActivityThread.java)? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)? at android.os.Handler.dispatchMessage(Handler.java:102)? at android.os.Looper.loop(Looper.java:154)? at android.app.ActivityThread.main(ActivityThread.java:6077)? at java.lang.reflect.Method.invoke(Native Method)? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
5403)?在 android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342)?在 android.app.ActivityThread.-wrap2(ActivityThread.java)?在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)?在 android.os.Handler.dispatchMessage(Handler.java:102)?在 android.os.Looper.loop(Looper.java:154)?在 android.app.ActivityThread.main(ActivityThread.java: 6077)?在 java.lang.reflect.Method.invoke(Native Method)?在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)?在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
I already looked at other questions but the problem is not the same. What am I doing wrong? Please help
我已经看过其他问题,但问题不一样。我究竟做错了什么?请帮忙
回答by TSR
I got the same error. I resolved it by :
我得到了同样的错误。我通过以下方式解决了它:
1) Removing unnecessary packages in the build.gralde.
1) 删除 build.gralde 中不必要的包。
2) Disabling the Firebase plugin
2) 禁用 Firebase 插件
3) Upgrading the build tool to the latest
3) 将构建工具升级到最新版本
回答by Chi Minh Trinh
It seems you have a problem with Over 64K Methods and then tried to resolved it with multiDexEnabled true
in build.gradle (app module). But you need to add more than:
您似乎对超过 64K 的方法有问题,然后尝试multiDexEnabled true
在 build.gradle(应用程序模块)中解决它。但是您需要添加的不仅仅是:
add:
compile 'com.android.support:multidex:1.0.0'
in dependencies of build.gradleExtends your Application class to MultiDexApplication. and add
MultiDex.install(this);
inonCreated
method of Application class.
添加:
compile 'com.android.support:multidex:1.0.0'
在 build.gradle 的依赖项中将您的应用程序类扩展到 MultiDexApplication。并添加
MultiDex.install(this);
到onCreated
Application 类的方法中。
your issue should be resolved
你的问题应该得到解决
refer link: https://developer.android.com/studio/build/multidex.html
参考链接:https: //developer.android.com/studio/build/multidex.html
回答by Vaibhav Jain
I got the same error and resolved it using:
我遇到了同样的错误并使用以下方法解决了它:
- Clean/Rebuild your Project.
- Restart Android Studio.
- Update all SDK tools and Android Studio.
- Clear Cache and Clear Data on Device.
- 清理/重建您的项目。
- 重启安卓工作室。
- 更新所有 SDK 工具和 Android Studio。
- 清除缓存并清除设备上的数据。
回答by ProgrammerCk
This works great which you add multidex support in manifest, when ever i encounter problem i got it fixed this way more over 64K.
这很好用,你在清单中添加了 multidex 支持,当我遇到问题时,我通过这种方式修复了超过 64K。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
</manifest>
回答by Garg's
In app module build.gradle
在应用模块build.gradle
android {
...
defaultConfig {
multiDexEnabled true
...
}
}
dependencies {
// add dependency
compile 'com.android.support:multidex:1.0.1'
}
Change name in AndroidManifest.xml
在AndroidManifest.xml 中更改名称
<application
....
android:name=".MyApplication">
// ...
</application>
Crate a MyApplication.javafile
创建一个MyApplication.java文件
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
For MORE details can see this link.
有关更多详细信息,请参阅此链接。
回答by akitsme
just remove the google play services dependencies if you are including it. I am able to fix this error everytime using this. If you are using google maps or any other specific google service then include the dependency for that particular service only. Also try to check the version of google play service dependency.
如果包含它,只需删除 google play 服务依赖项。每次使用它我都能修复这个错误。如果您使用的是 google 地图或任何其他特定的 google 服务,则仅包含该特定服务的依赖项。还尝试检查 google play 服务依赖项的版本。
回答by pruthwiraj.kadam
app=>build.gradle
app=>build.gradle
android {
.....
defaultConfig {
......
multiDexEnabled true//add this line
}
......
dependencies{
compile 'com.android.support:multidex:1.0.1'//add this line
}
In manifest
在清单中
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
....
<application
....
android:name="android.support.multidex.MultiDexApplication"
...>
<activity />
...
</application>
</manifest>
回答by Zubair Akber
A simple solution that works for me after trying all of these solution is by deleting outputsfolder under project\app\build\and rebuilding project will let it to running state.
在尝试了所有这些解决方案后,一个对我有用的简单解决方案是删除project\app\build\下的输出文件夹,然后重建项目将使其进入运行状态。
回答by Parinda Rajapaksha
Add following line to Manifest.xml
将以下行添加到 Manifest.xml
<application
android:name="android.support.multidex.MultiDexApplication"
Add this sn App level build.gradle file
添加这个 sn App 级别的 build.gradle 文件
defaultConfig {
multiDexEnabled true
}
......
dependencies {
compile 'com.android.support:multidex:1.0.1'
}