【发布时间】:2017-05-21 12:42:36
【问题描述】:
我正在尝试将 FCM(Firebase 云消息传递)集成到应用程序中,遵循 google's guide。我已将 google-services.json 添加到 app 文件夹并尝试添加 SDK。
按照指南,我写在build.gradle (Project):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
在build.gradle(Module: mobile):
dependencies
{
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.google.android.gms:play-services:7.3.0'
(...)
compile 'com.google.firebase:firebase-core:9.6.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply plugin: 'com.google.gms.google-services'
这是问题开始的时候。成绩同步后,会出现一条错误消息:Error:(34, 0) Version: 7.3.0 is lower than the minimum version (9.0.0) required for google-services plugin.
我尝试通过将compile 'com.google.android.gms:play-services:7.3.0' 更改为compile 'com.google.android.gms:play-services:9.0.0' 并再次出现新错误、我不知道如何解决的错误来更新...:
Error:orientation|screenSize|screenLayout|uiMode|smallestScreenSize) from AndroidManifest.xml:79:4-113
Error:orientation|screenLayout|uiMode|screenSize|smallestScreenSize).
Error:Execution failed for task ':mobile:processDebugManifest'.
> Manifest merger failed : Attribute activity#com.google.android.gms.ads.AdActivity@configChanges value=(keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize) from AndroidManifest.xml:79:4-113
is also present at [com.google.android.gms:play-services-ads-lite:9.0.0] AndroidManifest.xml:28:13-122 value=(keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize).
Suggestion: add 'tools:replace="android:configChanges"' to <activity> element at AndroidManifest.xml:77:3-79:116 to override.
抱歉很久了。 Android新手在这里。感谢所有未来的帮助!
编辑:AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.www.appname"
android:installLocation="auto">
<!-- versionCode, versionName, minSdkVersion, targetSdkVersion properties are set via Gradle script -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <!-- allows the API to access Google web-based services -->
<uses-feature android:glEsVersion="0x00020000" android:required="false" />
<application
android:name=".Application"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:allowBackup="true"
tools:replace="android:icon, android:configChanges">
<activity
android:name="com.www.appname.activity.MainActivity"
android:label="@string/app_name"
android:launchMode="standard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.www.appname.activity.DetailActivity"
android:label="@string/title_detail"
android:launchMode="standard" />
<activity
android:name="com.www.appname.activity.MapActivity"
android:label="@string/title_map"
android:launchMode="standard" />
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|smallestScreenSize" />
<provider
android:name="com.www.appname.content.SearchRecentSuggestionsProvider"
android:authorities="ccom.www.appname.content.SearchRecentSuggestionsProvider"
android:exported="false" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource" android:resource="@xml/analytics_global_tracker" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/maps_api_key" />
</application>
</manifest>
【问题讨论】:
标签: android firebase firebase-cloud-messaging