Unresolved class 'MyFirebaseMessagingService' Android Studio

Nikola Arsovski :

I have problem with Firebase in Android studio. Here is what happen: In debug mod everything is working fine with follow AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hajora.dndcommerce"
android:installLocation="auto"
android:versionCode="2"
android:versionName="1.0"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="21"
    tools:overrideLibrary="com.google.firebase.messaging"
    />
<supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true"
    android:anyDensity="true"
 />
<uses-permission android:name="android.permission.CALL_PHONE"  />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.hajora.dndcommerce.Education"
        android:label="@string/app_name">
    </activity>
    <activity android:name="com.hajora.dndcommerce.Splashscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.hajora.dndcommerce.SingleItemViewEducation" />
    <activity android:name="com.hajora.dndcommerce.SingleItemViewNews" />
    <activity android:name="com.hajora.dndcommerce.Main" />
    <activity android:name="com.hajora.dndcommerce.Submit" />
    <activity android:name="com.hajora.dndcommerce.News" />
    <activity android:name="com.hajora.dndcommerce.Contact" />
    <activity android:name="com.hajora.dndcommerce.About" />
    <activity android:name="com.hajora.dndcommerce.AboutCompany" />
    <activity android:name="com.hajora.dndcommerce.AboutHistory" />
    <activity android:name="com.hajora.dndcommerce.AboutVision" />
    <activity android:name="com.hajora.dndcommerce.AboutPartners" />
    <activity android:name="com.hajora.dndcommerce.Ask"
        android:windowSoftInputMode="stateUnchanged" />
    <activity android:name=".Partner" />
</application>
    <service
        android:name=".MyFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>
    <service
        android:name=".MyFirebaseInstanceIDService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service>

When i switch to release mode, i get the error:

Error:(54) Error: The <service> element must be a direct child of the <application> element [WrongManifestParent]

So, i then put both services inside tag and after that i get the error:

Unresolved class 'MyFirebaseMessagingService' less... (Ctrl+F1) 

Validates resource references inside Android XML files.

I cannot figure what is the problem

UPDATE gradle

    apply plugin: 'com.android.application'

android {

    compileSdkVersion 21
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId 'com.hajora.dndcommerce'
        minSdkVersion 21
        targetSdkVersion 21
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            signingConfig signingConfigs.release
        }
    }
    productFlavors {
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile files('libs/activation.jar')
    compile files('libs/mail.jar')
    compile files('libs/additionnal.jar')
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-core:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
Mohammed Farhan :

See this image first Image with error

check if Firebase classes are in correct package folder. example if firebase classes are in package 'services' then in manifest service would have android:name=".services.FirebaseMessagingService" then Unresolved class 'MyFirebaseMessagingService' error will get solved.

enter image description here

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=464818&siteId=1