Rajarajan viswanathan
Lurker
Hi,
I have implemented firebase cloud message concept to my app. It works fine when it running in normally, it generate token when i am running the app in testing.
When I build the app for publishing in google play store with singed apk. the token not generated. I don't know why the fcm token not generated. Please guide me, how to fix it.
The below are my code snippet:
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
System.out.print("Fetching FCM registration token failed");
return;
}
FCMRegkey = task.getResult();
System.out.print( FCMRegkey);
}
});
app level gradle:
apply plugin: 'com.android.application'
// Add this line for notification
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "com.sia.taxefilling"
minSdkVersion 21
targetSdkVersion 31
versionCode 5
versionName "3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-messaging:23.1.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.wang.avi:library:1.0.3'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'com.google.android.material:material:1.2.0-alpha01'
// standard retrofit dependency
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
//implementation 'com.squareup.retrofit:retrofit:1.9.0'
//Razorpay
implementation 'com.razorpay:checkout:1.5.16'
//you need this to use RxAndroid with retrofit.
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
// AWS s3 Bucket
implementation 'com.amazonaws:aws-android-sdk-s3:2.18.0'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.18.0'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.18.0'
implementation 'com.google.android.gmslay-services-location:21.0.1'
implementation 'com.google.android.gmslay-services-auth-api-phone:18.0.1'
//For google analytics
implementation 'com.google.android.gmslay-services-analytics:18.0.2'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
// Workmanager background process
def work_version = "2.5.0"
// (Java only)
//noinspection GradleDependency
implementation "androidx.work:work-runtime:$work_version"
// optional - RxJava2 support
//noinspection GradleDependency
implementation "androidx.work:work-rxjava2:$work_version"
// library for Play In-App Update:
// Make sure you also include that repository in your project's build.gradle file.
implementation("com.google.android.play:app-update:2.0.1")
// For Kotlin users, also import the Kotlin extensions library for Play In-App Update:
implementation("com.google.android.play:app-update-ktx:2.0.0")
}
I have implemented firebase cloud message concept to my app. It works fine when it running in normally, it generate token when i am running the app in testing.
When I build the app for publishing in google play store with singed apk. the token not generated. I don't know why the fcm token not generated. Please guide me, how to fix it.
The below are my code snippet:
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
System.out.print("Fetching FCM registration token failed");
return;
}
FCMRegkey = task.getResult();
System.out.print( FCMRegkey);
}
});
app level gradle:
apply plugin: 'com.android.application'
// Add this line for notification
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "com.sia.taxefilling"
minSdkVersion 21
targetSdkVersion 31
versionCode 5
versionName "3.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-messaging:23.1.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.wang.avi:library:1.0.3'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'com.google.android.material:material:1.2.0-alpha01'
// standard retrofit dependency
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
//implementation 'com.squareup.retrofit:retrofit:1.9.0'
//Razorpay
implementation 'com.razorpay:checkout:1.5.16'
//you need this to use RxAndroid with retrofit.
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
// AWS s3 Bucket
implementation 'com.amazonaws:aws-android-sdk-s3:2.18.0'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.18.0'
implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.18.0'
implementation 'com.google.android.gmslay-services-location:21.0.1'
implementation 'com.google.android.gmslay-services-auth-api-phone:18.0.1'
//For google analytics
implementation 'com.google.android.gmslay-services-analytics:18.0.2'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
// Workmanager background process
def work_version = "2.5.0"
// (Java only)
//noinspection GradleDependency
implementation "androidx.work:work-runtime:$work_version"
// optional - RxJava2 support
//noinspection GradleDependency
implementation "androidx.work:work-rxjava2:$work_version"
// library for Play In-App Update:
// Make sure you also include that repository in your project's build.gradle file.
implementation("com.google.android.play:app-update:2.0.1")
// For Kotlin users, also import the Kotlin extensions library for Play In-App Update:
implementation("com.google.android.play:app-update-ktx:2.0.0")
}