这是我的manifest
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.payne.simpletestapp">
<uses-permission android:name="android.permission.VIBRATE" />
<!-- GPS + OSMDroid -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivities.Home"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!--
TODO : add an ACTION-VIEW INTENT FILTER (to allow for Google to search for app)
https://stackoverflow.com/questions/34367875/android-adding-at-least-one-activity-with-an-action-view-intent-filter-after-u
-->
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivities.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".DeviceStorage.SettingsActivity"
android:label="@string/title_activity_settings" />
<activity android:name=".Authentification.AuthUIActivity" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- TODO: Firebase Cloud Messaging -->
<!-- [START fcm_default_icon] -->
<!--
Set custom default icon. This is used when no icon is set for incoming notification messages.
See README(...) for more.
-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/logo_couleur_icon" />
<!--
Set color used with incoming notification messages. This is used when no color is set
for the incoming notification message. See README(...) for more.
-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
<!-- [END fcm_default_icon] -->
<!-- [START fcm_default_channel] -->
<!-- TODO: For default_notif_chans, see: https://medium.com/exploring-android/exploring-android-o-notification-channels-94cd274f604c -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id" /> <!-- TODO: Add default notif channel id -->
<!-- [END fcm_default_channel] -->
<service
android:name=".Notifications.Firebase.MyFirebaseMessagingService"
android:enabled="true"
android:exported="true"> <!-- TODO: make sure "enabled" and "exported" are necessary -->
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".Notifications.Firebase.MyJobService"
android:exported="false">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<activity android:name=".Notifications.Firebase.NotifTestActivity"></activity>
</application>
</manifest>
我得到的错误如下:
java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
如您所见,Manifest实际上包含了这段代码。
这是怎么了?
这是我的build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.payne.simpletestapp"
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// TODO: revert 'api' to 'implementation' (checks relative dependencies)
// Firebase Authentication
api 'com.google.firebase:firebase-auth:16.0.2'
api 'com.firebaseui:firebase-ui-auth:4.1.0'
api 'com.google.firebase:firebase-core:16.0.1'
api 'com.google.android.gms:play-services-auth:15.0.1'
// Firebase Cloud Messaging (Notifications)
api 'com.google.firebase:firebase-messaging:17.1.0'
api 'com.firebase:firebase-jobdispatcher:0.8.5'
// OSMDroid (Map)
api 'org.osmdroid:osmdroid-android:6.0.1'
api 'org.osmdroid:osmdroid-wms:6.0.1'
api 'org.osmdroid:osmdroid-mapsforge:6.0.1'
api 'org.osmdroid:osmdroid-geopackage:6.0.1'
api 'com.github.MKergall:osmbonuspack:6.5.1' // Historical Pin Clusters
// Spring Android
api 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
api 'org.apache.httpcomponents:httpclient-android:4.3.5'
// JSON @ https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
api 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
// Animations et Images
api 'com.squareup.picasso:picasso:2.71828'
api 'com.github.faruktoptas:FancyShowCaseView:1.0.1'
api 'com.daimajia.easing:library:2.0@aar'
api 'com.daimajia.androidanimations:library:2.3@aar'
// @Getters/@Setters
compileOnly 'org.projectlombok:lombok:1.18.0'
annotationProcessor 'org.projectlombok:lombok:1.18.0'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
apply plugin: 'com.google.gms.google-services'
以防万一,这是我的@integer/google_play_services_version
的内容:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">0</integer>
</resources>
是的,我的课以前曾经上过课。我做了一些重构,但是没有什么改变我班级背后的逻辑,也没有什么新的要求。
答案 0 :(得分:0)
确保版本号正确且是最新的(在app
依赖项和module
gradle实现中),然后重新同步项目。