添加Firebase后应用程序无响应 [英] Application not responding after adding Firebase
问题描述
我想将Firebase集成到我的Android应用程序中.这样做时,我需要将com.google.gms.google-services版本9添加到我的应用程序gradle中.
I want to integrate Firebase into my Android application. When I do so, I need to add com.google.gms.google-services version 9 into my app gradle.
经过几次测试并打开我的应用几次后,有时我的应用在启动后变得无响应(甚至还没有创建视图).
After testing it a few times and opening my app a couple of times, some times my app becomes not responding after start (the view has not even been created).
因此,我尝试将com.google.gms.google-services恢复为7.5版,这是我在添加Firebase之前使用的版本.然后,我的应用程序将像以前一样正常工作.
So, I tried to revert back the com.google.gms.google-services to version 7.5, which is the version I used before adding Firebase. Then, my application works normally just like before.
这是我的应用程序的gradle模块文件(还原回gms 7.5版之后)
This is the gradle module file of my application (after reverting back to gms version 7.5)
apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'
android {
// compileSdkVersion 23
// buildToolsVersion '23.0.0'
compileSdkVersion 22
buildToolsVersion '22.0.0'
defaultConfig {
applicationId "com.pasarumah.androidapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 7
versionName "1.6"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.7'
compile 'org.apache.httpcomponents:httpmime:4.3.5'
// compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile files('libs/httpcore-4.3.3.jar')
// compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/universal-image-loader-1.9.4.jar')
}
我已经搜索过,似乎有人与我有相同的问题: Android应用未响应
I've searched and seems someone has the same issue with me: Android app not responding
推荐答案
您需要此为项目等级
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
这在您的模块gradle底部
And this at the bottom of you module gradle
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:9.0.2'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
在您的代码中,依赖项之后没有应用插件
In your code you don't have the apply plugin after your dependencies
这篇关于添加Firebase后应用程序无响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!