简体   繁体   English

无法解析FirebaseOptions.Builder()。setCredentials(…)中的setCredentials

[英]Cannot Resolve setCredentials in FirebaseOptions.Builder().setCredentials(…)

Can not Resolved FirebaseOptions.Builder().setCredentials() i have referred to answers in this link but it did not solve my problem. 无法解决FirebaseOptions.Builder()。setCredentials()我已在此链接中引用了答案,但它没有解决我的问题。 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: 这是我的应用程序gradle文件依赖项:

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. setCredentials方法无法识别,请提供帮助。

You seem to be trying to use both the Admin SDK and the regular Android SDK for Firebase in the same app. 您似乎正在尝试在同一应用中同时使用Admin SDK和用于Firebase的常规Android SDK。 This is not a supported scenario. 这不是受支持的方案。

The Admin SDK is specifically meant for use on servers, and other trusted environments. Admin SDK特别适合在服务器和其他受信任的环境上使用。 Using in Android apps that you share with your users opens your Firebase project up to abuse. 与您的用户共享的Android应用程序中使用将使Firebase项目遭受滥用。

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 . 如果您需要在应用程序中使用某些功能,这些功能在Android SDK中不可用,但可以通过Admin SDK来使用,请考虑将该功能包装在Cloud Functions中 ,然后从您的Android应用程序中调用 That way you can control what specific functionality you make available, instead of giving them full access to your Firebase project. 这样,您可以控制可用的特定功能,而不必授予他们对Firebase项目的完全访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM