M.W*_*vez 69 android exception firebase firebase-realtime-database
我已使用此更新我的应用程序到新的firebase ,现在当我编译我的项目时,我得到以下异常.
这是我的logcat:
11:57:54.533 27844-27844/com.example.dayshift_2.traveyy E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dayshift_2.traveyy, PID: 27844
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4871)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4466)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4406)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1270)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
我的Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.dayshift_2.traveyy"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-database:9.0.0'
compile 'com.google.firebase:firebase-auth:9.0.0'
compile 'com.android.support:support-v13:23.3.0'
compile 'com.roughike:bottom-bar:1.2.1'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
不知道我从哪里得到这个例外.任何帮助将受到高度赞赏.谢谢
BKC*_*BKC 142
这对我有用:
然后将该行添加compile 'com.android.support:multidex:1.0.1'
到您的dependancies(或者只是删除,multiDexEnabled true
如果不需要)
将此属性添加到清单中的应用程序标记:android:name="android.support.multidex.MultiDexApplication"
如果您已在Android Manifest中定义了自定义应用程序类,则将其从而MultiDexApplication
不是Application
希望它有所帮助!
ena*_*nam 45
使用最新的Google Play服务但无效.对我来说这个程序是有效的:
更新了我的Application类:
public class App extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Run Code Online (Sandbox Code Playgroud)更新build.gradle
文件:
defaultConfig {
...
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)包含的依赖项:
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Run Code Online (Sandbox Code Playgroud)Rus*_*ppa 22
修复人员非常简单.如果您在项目中使用了播放器服务和firebase,请确保不要导入google中的所有可用服务.只需导入实际需要的API.例如:
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.android.gms:play-services:9.2.0'
Run Code Online (Sandbox Code Playgroud)
这样做可以给你noclassdeffounderror.要解决这个问题
删除播放服务并同步您的项目.如果您在应用中使用广告或地图等依赖关系,请定义特定的API.喜欢:
compile 'com.google.android.gms:play-services-maps:9.2.0'
Run Code Online (Sandbox Code Playgroud)
注意:最大不要尝试使用multiDexEnabled为true.这应该是你解决问题的最后一步.
希望这是有帮助的.
Ars*_*hak 17
我降低了谷歌播放服务的依赖性
compile 'com.google.android.gms:play-services:9.2.0'
Run Code Online (Sandbox Code Playgroud)
至
compile 'com.google.android.gms:play-services:8.4.0'
Run Code Online (Sandbox Code Playgroud)
这为我解决了这个问题.
请注意:升级到最新的Google Play服务时,
compile 'com.google.android.gms:play-services:9.4.0'
它也解决了这个问题.
或者您可以有选择地导入您需要的某些服务,而不是导入所有谷歌播放服务.
son*_*368 13
第1步:修复multidex
申请类:
public class StudyNApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
}
Run Code Online (Sandbox Code Playgroud)
成绩档案
defaultConfig {
...
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Run Code Online (Sandbox Code Playgroud)
第2步:修复java.lang.NoClassDefFoundError:com.google.firebase.FirebaseOptions
去掉
compile 'com.google.android.gms:play-services:9.4.0'
Run Code Online (Sandbox Code Playgroud)
添加两个lib:
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
Run Code Online (Sandbox Code Playgroud)
它工作正常.
不要忘记它.
android:name="android.support.multidex.MultiDexApplication"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
84982 次 |
最近记录: |