Android Firebase Authentication - android

mAuth!!.createUserWithEmailAndPassword(email,password)
.addOnCompleteListener(this){ task ->
if (task.isSuccessful){
Toast.makeText(applicationContext,"Successful login",Toast.LENGTH_LONG).show()
var currentUser =mAuth!!.currentUser
//save in database
if(currentUser!=null) {
myRef.child("Users").child(SplitString(currentUser.email.toString())).child("Request").setValue(currentUser.uid)
}
LoadMain()
}else
{
Toast.makeText(applicationContext,"fail login",Toast.LENGTH_LONG).show()
}
}
I get "developer warning for package 'com.example.package' Failed to post notification on channel 'null' See log for more details"
In the log
DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
GooglePlayServicesUtil: Google Play services out of date. Requires 11020000 but found 10932470
Notification: Use of stream types is deprecated for operations other than volume control
Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
I have
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.firebase:firebase-database:11.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
in build.gradle
I've been lookin at this https://developer.android.com/guide/topics/ui/notifiers/notifications.html#ManageChannels, but I don't know how to work on this

your version of play services is old.
use latest google play services in gradle:
dependencies {
compile 'com.google.android.gms:play-services:11.2.0'
}

For Oreo Copatability you must use channels and group them to run on Oreo (android O) otherwise your notifications will be dropped.
Use this link to Learn more about channels in Android O link
medium link
Read about android O changes here

Related

Google Play Services are randomly adding AD ID permission into my Manifest

I just found out that my Google Play Services are adding into merged manifest AD permission and for that reason I cant upload app to my playstore because it requires reasoning why I want ads in my app (I don't).
These are my gradle libraries:
//Google SDK
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.gms:play-services-auth:20.3.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.maps.android:android-maps-utils:2.0.3'
//GCM for internet connection monitoring
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
//GooglePay
implementation 'com.google.android.gms:play-services-wallet:19.1.0'
//Google Firebase SDK - Crashlytics, Firebase Messaging
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation ('com.google.firebase:firebase-crashlytics:18.2.13') {
transitive = true
}
implementation 'com.google.firebase:firebase-messaging:23.0.8'
This is merged manifest:
It seems like its google analytics (firebase). But I don't want and don't use any ad content in my app so I don't understand why is Google adding this stuff into my app without my approval.
I just tried to do this:
implementation 'com.google.firebase:firebase-core:21.1.1' {
exclude module: "play-services-ads-identifier"
exclude module: "play-services-measurement"
exclude module: "play-services-measurement-sdk"
}
as I found out but its not even compiling (got GradleScriptException):
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method com.google.firebase:firebase-core:21.1.1() for arguments [build_ballt3q1t2mmz35mzah3ugy17$_run_closure2$_closure23#69dcec81] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

Cannot fit requested classes in a single dex file ERROR When adding google play ads library in gradle

I am developing a project in which I have used Firebase and Google Play service maps and location. Here is my app-level build Gradle file.
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.google.android.gms:play-services-location:$playServicesVersion"
implementation "com.google.android.gms:play-services-maps:$playServicesVersion"
implementation 'com.google.android.libraries.places:places:2.0.0'
implementation "com.google.firebase:firebase-core:$firebaseCoreVersion"
implementation "com.google.firebase:firebase-perf:$firebasePerfVersion"
implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
implementation "com.crashlytics.sdk.android:crashlytics:$crashlyticsVersion"
// Room
implementation 'androidx.room:room-runtime:2.1.0'
annotationProcessor 'androidx.room:room-compiler:2.1.0'
// LiveData and ViewModel
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.0.0'
implementation "net.danlew:android.joda:$jodaTimeVersion"
// Annotations
implementation 'androidx.annotation:annotation:1.1.0'
implementation "com.squareup.picasso:picasso:$picassoVersion"
dependencies {
implementation 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
Now, this all works fine and the application runs normally. But when I tried to add below line:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
then the following error comes
cannot fit requested classes in a single dex file
I have searched that and found out some solutions like multi dex enabled and minifyenabled for debug but the when these solutions applied then the app runs and crash on start always.
I also applied the solution of removing some libraries just to check whether Google Ads gradle library can be added but it shows the same error. Even if I remove 3-4 libraries and add one Google Ad library then the error still the same.
What to do in this case.
Please make sure you are using the same version of all libs of Google Play Services. Also, enable multidex for your application.
implementation "androidx.multidex:multidex:2.0.1"
prior approach:
Instead of implementing entire ads library, you should implement only required one...
Check out this link for further info:
Other Approach.
You can follow this link.
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can add the multidex support library to your project:
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
Hope you will have your solution.

Many message in logcat - Firebase and other

When I debug my app, I see many log from Firebase, like these:
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
but I do not use any Firebase method. In my api manager developer console I've enabled the following service:
Mobile Crash and Performance Reporting API
 App Engine Admin API
 BigQuery API
 Firebase Rules API
 Google Cloud APIs
 Google Cloud Datastore API
 Google Cloud Messaging
 Google Cloud SQL
 Google Cloud Storage
 Google Cloud Storage JSON API
 Google Places API Web Service
 Google+ API
 Identity Toolkit API
 Stackdriver Debugger API
 Stackdriver Logging API
 Stackdriver Monitoring API
 Stackdriver Trace API
Token Service API
And these are my dependencies in build.gradle (app):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.4.1' //zoom image view
compile 'com.soundcloud.android:android-crop:1.0.1#aar' //crop image
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile "com.google.android.gms:play-services-gcm:9.4.0"
compile 'com.melnykov:floatingactionbutton:1.3.0' //fab
compile ('com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT'){exclude group: 'com.nineoldandroids'} //search bar
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.pkmmte.view:circularimageview:1.1' //circle image view
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.android.support:multidex:1.0.1'
}
This problem is related to Firebase, I think, but there are another problem. I've an app to change wallpaper. It works with Nougat on Nexus 5 or with Marshmallow on emulator.
I've the following error when I closed it but there is a broadcast with alarm manager in background to change wallpaper:
Thread[2,tid=7185,WaitingInMainSignalCatcherLoop,Thread*=0xaee57000,peer=0x12c560a0,"Signal Catcher"]: reacting to signal 3
then, a message tell me to see traces.txt in anr: https://drive.google.com/file/d/0B8qwgteGjSYIV19iQXZUU2U0S1k/view?usp=sharing
I think that the Firebase's logs doesn't create problem, but I would to resolve the "WaitingInMainSignalCatcherLoop".

Firebase: Failed to initialize crash reporting

My build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:22.2.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile "com.google.firebase:firebase-auth:9.4.0"
compile 'com.google.firebase:firebase-crash:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
This is how i am initializing FireBase Crash:
FirebaseCrash.report(new Exception("My first Android non-fatal error"));
but I am getting this from Logcat:
Failed to initialize crash reporting
com.google.firebase.crash.internal.zzg$zza: com.google.android.gms.internal.zzsb$zza:
No acceptable module found. Local version is 0 and remote version is 0.
Crash reporting won't initialize if you don't have updated Google Play Services on your device or you haven't it installed at all.
I agree with #user6749691 that the failure is most likely caused by Google Play Services being old or not present. The issue is discussed here.
You can confirm that your installed Play Services is sufficient to support Firebase by adding this method and calling it when your app initializes:
private void showGooglePlayServicesStatus() {
GoogleApiAvailability apiAvail = GoogleApiAvailability.getInstance();
int errorCode = apiAvail.isGooglePlayServicesAvailable(this);
String msg = "Play Services: " + apiAvail.getErrorString(errorCode);
Log.d(TAG, msg);
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
Check for typos, that can be a reason too.
compile 'com.google.firebase:firebase-ads:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
compile 'com.google.firebase:firebase-crash:11.0.1'
Silly mistake, hard to spot, but for e.g. I had x.x.1, instead of x.x.2, and all Firebase / Google Play Service libs should use the same version.

Compile time error for setServiceAccount() with FirebaseOptions.Builder()

I was working my Android app for sending push notifications using Firebase cloud messaging. I was setting up my server referring the guide https://firebase.google.com/docs/server/setup#prerequisites.
My project level build.gradle is like :
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}
App level build.grade :
dependencies {
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:geofire:1.1.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)'
compile 'com.google.firebase:firebase-core:9.0.0'
}
I have created the service account credentials on the console as well but while I am initializing the SDK referring https://firebase.google.com/docs/server/setup#add_the_sdk
FirebaseOptions options = new FirebaseOptions.Builder()
.setServiceAccount
(new FileInputStream("path/to/serviceAccountCredentials.json"))
.setDatabaseUrl("https://databaseName.firebaseio.com/")
.build();
I am getting compile Error:(116, 21) error: cannot find symbol method setServiceAccount(FileInputStream)
I have checked many places but I am unable to find what I am doing wrong. Any help would be highly appreciated.
In your server project you need to use only the dependency:
com.google.firebase:firebase-server-sdk:[3.0.0,) and remove:
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
The first is a server sdk while the others are client sdk and they will have conflicts if you try to use them together.
You're including a different version of the Firebase Database SDK than what you have for the other Firebase features:
compile 'com.firebase:firebase-client-android:2.5.2'
If you change it to:
compile 'com.google.firebase:firebase-database:9.0.0'
It will work better.
For more information, see the Firebase documentation for Android developers, from where I copied the line above.

Categories

Resources