0

Here is my 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>

The error I get is the following:

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" />

As you can see, my Manifest actually does contain this piece of code.

What is wrong here?

Here's my 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'

And just in case, here is the content of my @integer/google_play_services_version:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="google_play_services_version">0</integer>
</resources>

And yes, my class used to work before. I have done a bit of refactoring, but nothing that changes the logic behind my class, nor that calls anything new.

payne
  • 4,691
  • 8
  • 37
  • 85
  • Did you try to `clean` your project? – Khaled Lela Jul 27 '18 at 22:56
  • I thought that was mostly related to the IDE itself, and not the way it compiles the application for debugging directly on the phone. Anyhow, I just tried it and it did not fix the problem. :( – payne Jul 27 '18 at 23:00
  • 1
    It's weird that the version in your xml is 0. it should be different. I'd try to re-install Google Play Services' Library through the SDK manager (I believe you work with android studio), and then remove its implementations from gradle file, and add them back again – Barak Jul 27 '18 at 23:33
  • 1
    **EDIT**: I changed one number in the VERSION number of the app gradle, Synced, and then changed it back to the latest version, and now it's fixed. How weird. Feel free to respond as an answer and I'll mark it. :) – payne Jul 27 '18 at 23:39
  • I'm glad it worked eventually :) – Barak Jul 27 '18 at 23:48

1 Answers1

0

Make sure the version number is correct and up-to-date (inside app dependencies and module gradle implementations), and re-sync the project.

Barak
  • 1,390
  • 15
  • 27