Can not Resolved FirebaseOptions.Builder().setCredentials() i have referred to answers in this link but it did not solve my problem.
here's my code:
FileInputStream serviceAccount =
new FileInputStream("./ServiceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://imiocr-f4522.firebaseio.com")
.build();
FirebaseApp.initializeApp(options);
FirebaseApp.initializeApp(options);
String customToken = FirebaseAuth.getInstance().createCustomTokenAsync("3mLImCwhyddkVZ9PWWNlw34pFVR2").get();
this is my app gradle file 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.2'
testImplementation 'junit:junit:4.12'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
implementation 'com.wang.avi:library:2.1.3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:4.2.0'
implementation 'com.intuit.ssp:ssp-android:1.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation 'com.android.support:design:28.0.0-alpha1'
//implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.firebaseui:firebase-ui-storage:4.1.0'
//implementation 'com.google.firebase:firebase-admin:6.2.0'
setCredentials method is never recognized, please help.
You seem to be trying to use both the Admin SDK and the regular Android SDK for Firebase in the same app. This is not a supported scenario.
The Admin SDK is specifically meant for use on servers, and other trusted environments. Using in Android apps that you share with your users opens your Firebase project up to abuse.
If you need some functionality in your app that is not available in the Android SDK, but is possible through the Admin SDK, consider wrapping that functionality in Cloud Functions, and calling that from your Android app. That way you can control what specific functionality you make available, instead of giving them full access to your Firebase project.
Related
I want to use Cotter as an alternative for Firebase to verify phone.
I followed the steps on:
Cotter page: Verifying email and phone number in your mobile app using our Android SDK
But I get this error when trying to sync the gradle:
Failed to resolve: com.github.cotterapp:android-sdk:0.3.0
Code is:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.preference:preference:1.1.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
//Cotter
implementation 'com.github.cotterapp:android-sdk:0.3.0'
}
And I also want to know how to do this:
For step 2 I need to Initialize Cotter with your API_KEY_ID. Using this code:
Cotter.init(this.getApplicationContext(),
"https://www.cotter.app/api/v0",
<API_KEY_ID>);
Where must I put this code?
I tried to make an object from FirebaseVisionLabelDetectorOptions class but my app doesn’t import it
I got this error . And this is my dependencies
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.wonderkiln:camerakit:0.13.1'
implementation 'com.github.d-max:spots-dialog:1.1#aar'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-ml-vision:18.0.1'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-ml-vision:24.0.3'
You are using the Cloud Landmarks API so you will need the Cloud Options class
FirebaseVisionCloudDetectorOptions options =
new FirebaseVisionCloudDetectorOptions.Builder()
.setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL)
.setMaxResults(15)
.build();
The Cloud based APIs work differently to on-device ones, so the options will be slightly different.
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'
implementation 'com.firebase:firebase-client-android:2.5.2+'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.android.volley:volley:1.1.0'
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.google.firebase:firebase-auth:16.0.1:15.0.0'
}
I don't know but the error only shows the appcompat 28.0.0 won't work.
Change
this, implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
to this, implementation 'com.google.firebase:firebase-auth:16.0.1'
and better, update all dependencies to the latest versions
The following dependency is put in by the Firebase Assistant to "Add Firebase Authentication to the App"
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
If you remove 15.0.0, and make it
implementation 'com.google.firebase:firebase-auth:16.0.1'
that automatically removes Firebase Authentication in the Firebase Assistant, beating the whole purpose. Also if you change to the '...firebase-auth:16.0.1:15.0.0' to the latest version '...firebase-auth:16.1.0:15.0.0', nothing happens to the error, as it is due to the '15.0.0' part.
This is probably a blocker bug from Firebase or Google side, which could be only corrected by them. Hope this catches their attention soon. Otherwise all new developments using this version of Firebase Auth or Database will be stalled. Older versions may be working though.
I use the latest version of Android Studio 3.2 & Plugin. When I try to connect firebase it show me to add dependencies -implementation 'com.google.firebase:firebase-auth:16.0.3:15.0.0' for Firebase authentication | implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0' for Realtime Database | implementation 'com.google.firebase:firebase-storage:16.0.1:15.0.0' for Cloud Storage
When using these dependencies it connect Firebase properly but Sync Failed. How to Use these dependencies?
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design: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.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3:15.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
I had faced the same issue before. If there is the update available then update your android it will fix it. from my experience when I use the assistant to add the dependencies then it comes like this
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
but the it is not correct update it with this
implementation 'com.google.firebase:firebase-database:16.0.1'
or
implementation 'com.google.firebase:firebase-database:15.0.0'
or this
maybe this will help you
here is official documentation for help
Update you firebase dependencies like this:
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
Basically, remove the last ":15.0.0" part. You probably copied these from the firebase website and made a mistake while pasting
I'm getting this strange behavior that I'm not able to import OnSuccessListener to my code after git cloning and building in a different machine (this resolved fine in my previous machine). However the project builds fine and runs on the emulator. But I'm not able to write firebase related codes further as the listener isn't resolving.
I tried cleaning the project, rebuilding, invalidating the cache but still no luck.
Gradle Dependencies,
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:support-v4: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'
implementation 'com.google.firebase:firebase-firestore:17.0.4'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation 'com.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.github.drawers:SpinnerDatePicker:1.0.6'
implementation 'com.github.yalantis:ucrop:2.2.2'
}
Please try adding this into your app-gradle file.
implementation 'com.google.android.gms:play-services-tasks:16.0.1'
What you do is make all the firebase and gms version of the same number like for example:
implementation 'com.google.firebase:firebase-auth:102.0'
implementation 'com.google.android.gms:play-services-auth:10.2.0'