cannot resolve FirebaseMessagingService android - android

I'm new to android studio and I'm trying to set up firebase messaging but I keep getting the error in the message receiver class:
cannot resolve FirebaseMessagingService
I've already set up all the gradle dependencies, not sure where I'm going wrong, here's my code:
Project Gradle script
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.1' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app gradle script
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.app.com"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.android.gms:play-services:11.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: "com.google.gms.google-services"
my class:
package com.app.com;
import FirebaseMessagingService;
/**
* Created by abdulahmad on 1/4/18.
*/
public class PushMessageReceiver extends FirebaseMessagingService {
private static final String TAG = "FCM Service";
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO: Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated.
Log.d(TAG, "From: " + remoteMessage.getFrom());
Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
}
}

Apparently you have the wrong import, From docs it should be
import com.google.firebase.messaging.FirebaseMessagingService;
instead of
import FirebaseMessagingService;

Related

Message sent by Firebase not displayed in logcat

I'm a beginner in Android, and I'm trying to send a message with Firebase, but when I send it nothing is displayed in the logcat while my emulator is running and I sent the message.
My service :
package com.example.tibdev.notiffirebase;
import android.app.Service;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
//récupération du message
String message = remoteMessage.getNotification().getBody();
Log.d("FireBaseMessage", "Notfication : " + message);
}
}
My graddle file app :
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.tibdev.notiffirebase"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
}
My gradle file build :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've been trying to debug this for a day, but nothing happens, even if I follow some tutorials

Unable to resolve dependency for ':app#release/compileClasspat': could not resolve com.nineoldandroidlibs:library:2.4.0

Unable to resolve dependency for ':app#release/compileClasspat': could not resolve com.nineoldandroidlibs:library:2.4.0 I am trying to import fancy button and pie chart libraries but i am getting the error mention above. I tried everything but nothing works. Following is my gradle file of project
buildscript {
repositories {
google()
// maven { url "https://maven.google.com"}
maven {
url 'https://maven.google.com'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
google()
// maven { url "https://maven.google.com"}
//maven { url "https://jitpack.io" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Following is my Gradle Project file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.hamzanaeem.gasapplication"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.blackfizz:eazegraph:1.2.2#aar'
compile 'com.github.medyo:fancybuttons:1.8.4'
}
Please help I`ve already tried all of the solution from stackoverflow too.
Thanks

I cannot receive push notification on my vritual device android

I received it in my vritual device before...but after I uninstall and reinstalled my app from my AVD then I didnt get any messages but in firebase console its showing completed status..plz some one help me
This is Main Activity
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageButton budbtn=(ImageButton)findViewById(R.id.buddies);
budbtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent= new Intent(MainActivity.this,BuddiesAct.class);
startActivity(intent);
}
});
ImageButton prim=(ImageButton)findViewById(R.id.primary);
ImageButton senior=(ImageButton)findViewById(R.id.senior);
ImageButton suprsen=(ImageButton)findViewById(R.id.supersenior);
}
}
Project level built gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.zion.kidskount"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
apply plugin: 'com.google.gms.google-services'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'gr.pantrif:easy-android-splash-screen:0.0.1'
compile 'com.google.firebase:firebase-messaging:9.0.0'
testCompile 'junit:junit:4.12'
}
Everytime you reinstall or clear data of your application, your token is generated again.
Log your token everytime onTokenRefresh() is called as described here.
So, get your token and use it to send your push notification :D

plugin Fabric Android Studio not found import com.crashlytics & io.fabric

On my new project i would like to integrate Crashlytics from Fabric.io
I've already installed Fabric on others projects without issue, one project with the tutorial here : https://fabric.io/kits/android/crashlytics/install
And on the other project, I've using the plugin Fabric integrated into Android Studio (picture)
here's the problem :
import android.app.Application;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
public class UILApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics()); // Fabric not found
}
}
Error:(6, 31) error: package com.crashlytics.android does not exist
Error:(7, 29) error: package io.fabric.sdk.android does not exist
Error:(20, 31) error: cannot find symbol class Crashlytics
Error:(20, 9) error: cannot find symbol variable Fabric
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
my build.gradle (Project) :
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
build.gradle (Module:app) :
buildscript {
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
// maven { url 'https://maven.fabric.io/public' } THIS LINE FORGOTTEN
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
//classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: "com.android.application"
//apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
// maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion = 24
buildToolsVersion = "23.0.3"
defaultConfig {
applicationId "agemos.testkalman1"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-SNAPSHOT#aar'){
transitive=true
}
// // Crashlytics Fabric io
// compile('com.crashlytics.sdk.android:crashlytics:2.6.3#aar') {
// transitive = true;
// }
}
I've change compileSdkVersion 23 to 24 but nothing has changed, someone had this problem ?
Thanks in advance for your help :)
I've forgot one line
Now it works ! sorry for the inconvenience ^^'
Mike from Fabric here.
It appears that you've commented out all initialization of Fabric in your build.gradle? If you un-comment the lines below, that should work.
classpath 'io.fabric.tools:gradle:1.+'
apply plugin: 'io.fabric'
maven { url 'https://maven.fabric.io/public' }
// Crashlytics Fabric io
compile('com.crashlytics.sdk.android:crashlytics:2.6.3#aar') {
transitive = true;
}
The full build.gradle would have all of the following changes:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.3#aar') {
transitive = true;
}
clear and Rebuild and Restart Android Studio Its Working
build.gradle project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'io.fabric.tools:gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle module
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.holostik.ozoneoverseas"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
// TODO FCM
// implementation 'com.google.firebase:firebase-messaging:11.0.4'
//compile 'com.google.firebase:firebase-messaging:11.0.4'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'me.dm7.barcodescanner:zxing:1.9.7'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.android.volley:volley:1.0.0'
// compile 'com.google.android.gms:play-services-location:7.8.0' // TODO Previous working
// compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.google.android.gms:play-services-location:11.0.4'
// compile "com.google.android.gms:play-services-gcm:9.2.0"
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
//TODO camera Crop dependency working
// compile files('libs/ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar')
// implementation 'com.google.firebase:firebase-messaging:11.0.4'
// compile 'com.google.android.gms:play-services:11.4.0'
compile 'com.google.android.gms:play-services:11.0.4'
// compile 'com.facebook.android:facebook-android-sdk:4.8.0' // Works here
compile 'com.facebook.android:facebook-android-sdk:4.13.1' // Works here
compile('com.crashlytics.sdk.android:crashlytics:2.9.0#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:2.0.2#aar') {
transitive = true;
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
/*buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.1' // google-services plugin
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}*/
// TODO FCM
//apply plugin: 'com.google.gms.google-services' // TODO FCM add auto in Bottom When Google Service Add uncomment this
//dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'com.android.support:appcompat-v7:26.1.0'
// implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'com.android.support.test:runner:1.0.1'
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//}
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}
manifest.xml
<meta-data
android:name="io.fabric.ApiKey"
android:value="1864e6d3e59158a5206d2d073e7e14c7ad811cbd" />
Splash Activity
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
}

Error in realm when using stripe payment method

i am integrating "Strip" payment method in my app but when i add the stripe dependence compile 'com.stripe:stripe-android:1.0.3' also try compile 'com.stripe:stripe-android:+' an error occur that is
i see many answer for realm Re-linker like using
compile 'com.getkeepsafe.relinker:relinker:1.2.1'
Compile 'io.reactivex:rxjava:1.1.0' but the problem is still exist
this is my Realm application class
public class WifiExploreApplication extends Application {
#Override
public void onCreate(){
super.onCreate();
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this)
.name("com.holygon.zaingz.alu").build();
Realm.setDefaultConfiguration(realmConfiguration)
}
}
this is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Apis:Google Apis:23'
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.wifiexplorer"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.github.sembozdemir:ViewPagerArrowIndicator:1.0.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:multidex:1.0.0'
compile "com.android.support:support-v4:23.0.0"
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.getkeepsafe.relinker:relinker:1.2.1'
compile 'com.stripe:stripe-android:1.0.3'
}
dependencies {
repositories {
mavenCentral()
}
compile 'com.sothree.slidinguppanel:library:3.3.0'
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
apply plugin: 'realm-android'
and
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath "io.realm:realm-gradle-plugin:0.88.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
before using stripe all the things going well but when i use strip it will show error
any suggestion will appreciate able..
You're using the AAR Gradle Plugin version of Realm (as in 0.88.0+, but an outdated one, considering the latest is 1.1.0) but you're never actually calling apply plugin: 'realm-android' in your build.gradle file.
You're also missing this from your application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Oh by the way, you probably should use modularized version of Google Play Services so that you wouldn't even need Multi-Dex in the first place.

Categories

Resources