Firebase身份验证仅在调试版本上起作用

huangapple go评论80阅读模式
英文:

Firebase authentication works only on debug version

问题

以下是您提供的内容的翻译:

我在Google Play上有一个应用程序:https://play.google.com/store/apps/details?id=com.conta.ftof
而且我有一个很大的问题。我无法在已签名的版本上使用手机号获得Firebase身份验证,事实上,它只能在调试版本中工作(当在发布版本中插入号码并单击发送按钮时,会返回未知错误的Toast)。确切地说,就是因为在发布版本中仅有错误...请问您能帮忙吗?我把代码留在这里:

RegistrationActivity中的重要代码

@Override
public void onVerificationFailed(FirebaseException e) {

    if (e instanceof FirebaseAuthInvalidCredentialsException) {
        Toast.makeText(RegistrationActivity.this, "Numero inserito non valido...", Toast.LENGTH_SHORT).show();
    }
    else if (e instanceof FirebaseTooManyRequestsException) {
        Toast.makeText(RegistrationActivity.this, "Troppe richieste per questo numero di telefono, riprova tra 24h", Toast.LENGTH_SHORT).show();
    }

    else if (e instanceof FirebaseNetworkException){
        Toast.makeText(RegistrationActivity.this, "Errore di rete...", Toast.LENGTH_SHORT).show();
    }

    else {

        Toast.makeText(RegistrationActivity.this, "Errore sconosciuto", Toast.LENGTH_SHORT).show();
    }

    Log.e(TAG,  "err : " + e);
    loadingBar.dismiss();


   // Toast.makeText(RegistrationActivity.this, "Numero inserito non valido...", Toast.LENGTH_SHORT).show();
    relativeLayout.setVisibility(View.VISIBLE);


    continueAndNextBtn.setText("Continue"); //Continue
    codeText.setVisibility(View.GONE);


}

RegistrationActivity: https://codeshare.io/5wBAzp

app的Build Gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    defaultConfig {
        applicationId "com.conta.ftof"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    implementation 'com.google.firebase:firebase-database:19.3.0'
    implementation 'com.google.firebase:firebase-core:17.4.3'
    implementation 'com.firebaseui:firebase-ui-database:3.2.2'
    implementation 'com.hbb20:ccp:2.1.9'
    implementation 'pub.devrel:easypermissions:0.4.0'
    implementation 'com.android.support:percent:29.0.0'
    implementation 'com.google.android.gms:play-services-ads:19.4.0'


    implementation 'com.google.firebase:firebase-storage:19.1.1'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'com.opentok.android:opentok-android-sdk:2.15.3'
    implementation 'pub.devrel:easypermissions:0.4.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    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-analytics:17.4.3'

}

Project的Build Gradle

// 在这里添加适用于所有子项目/模块的通用配置选项的顶级构建文件。
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.0"
        classpath 'com.google.gms:google-services:4.3.3'

        // 注意:不要在这里放置应用程序的依赖项;它们属于各个模块的 build.gradle 文件中
    }
}

allprojects {
    repositories {
        google()
        jcenter()

        maven { url 'https://maven.google.com'}
        maven { url 'https://tokbox.bintray.com/maven'}
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在DEBUG中的Logcat错误

2020-10-14 21:46:16.629 12564-12564/com.conta.ftof E/RegistrationActivity: err : com.google.firebase.FirebaseException: An internal error has occurred. [ Error code:39 ]

2020-10-14 21:46:16.697 2026-4029/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:718006122>, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/emeraldsea.mobileapps.doritos.cookie
rlv: Long live credential not available.
    at gbq.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):17)
    at gac.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):118)
    at cqx.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):235)
    at cqx.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):108)
    at cqx.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):240)
    at cox.onTransact(:com.google.android.gms@202614030@20.26.14 (100408-320008519):5)
    at android.os.Binder.transact(Binder.java:675
英文:

I have an app on google play: https://play.google.com/store/apps/details?id=com.conta.ftof
and I have a big problem. I can't get firebase authentication with phone number to work on the signed version. in fact, it works only with the debug version (when in the release version I insert the number and click the send button, the toast is returned: unknown error) ... Precisely for this reason I can't show the logcats, just because the error alone in the relase version ... Can you help me please? I leave you the code:

Important lines of registrationactivity

@Override
            public void onVerificationFailed(FirebaseException e) {

                if (e instanceof FirebaseAuthInvalidCredentialsException) {
                    Toast.makeText(RegistrationActivity.this, &quot;Numero inserito non valido...&quot;, Toast.LENGTH_SHORT).show();
                }
                else if (e instanceof FirebaseTooManyRequestsException) {
                    Toast.makeText(RegistrationActivity.this, &quot;Troppe richieste per questo numero di telefono, riprova tra 24h&quot;, Toast.LENGTH_SHORT).show();
                }

                else if (e instanceof FirebaseNetworkException){
                    Toast.makeText(RegistrationActivity.this, &quot;Errore di rete...&quot;, Toast.LENGTH_SHORT).show();
                }

                else {

                    Toast.makeText(RegistrationActivity.this, &quot;Errore sconosciuto&quot;, Toast.LENGTH_SHORT).show();
                }

                Log.e(TAG,  &quot;err : &quot; + e);
                loadingBar.dismiss();


               // Toast.makeText(RegistrationActivity.this, &quot;Numero inserito non valido...&quot;, Toast.LENGTH_SHORT).show();
                relativeLayout.setVisibility(View.VISIBLE);


                continueAndNextBtn.setText(&quot;Continue&quot;); //Continue
                codeText.setVisibility(View.GONE);


            }

**RegistrationActivity:**https://codeshare.io/5wBAzp

Build Gradle :app

    apply plugin: &#39;com.android.application&#39;
apply plugin: &#39;com.google.gms.google-services&#39;

android {
    compileSdkVersion 29
    buildToolsVersion &quot;29.0.3&quot;
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    defaultConfig {
        applicationId &quot;com.conta.ftof&quot;
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName &quot;1.0&quot;

        testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard-rules.pro&#39;

        }
    }
}

dependencies {
    implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;])
    implementation &#39;androidx.appcompat:appcompat:1.1.0&#39;
    implementation &#39;androidx.constraintlayout:constraintlayout:1.1.3&#39;
    implementation &#39;com.google.firebase:firebase-auth:19.3.1&#39;
    implementation &#39;com.google.firebase:firebase-database:19.3.0&#39;
    implementation &#39;com.google.firebase:firebase-core:17.4.3&#39;
    implementation &#39;com.firebaseui:firebase-ui-database:3.2.2&#39;
    implementation &#39;com.hbb20:ccp:2.1.9&#39;
    implementation &#39;pub.devrel:easypermissions:0.4.0&#39;
    implementation &#39;com.android.support:percent:29.0.0&#39;
    implementation &#39;com.google.android.gms:play-services-ads:19.4.0&#39;


    implementation &#39;com.google.firebase:firebase-storage:19.1.1&#39;
    implementation &#39;com.google.android.material:material:1.1.0&#39;
    implementation &#39;androidx.navigation:navigation-fragment:2.2.2&#39;
    implementation &#39;androidx.navigation:navigation-ui:2.2.2&#39;
    implementation &#39;androidx.lifecycle:lifecycle-extensions:2.2.0&#39;
    implementation &#39;com.opentok.android:opentok-android-sdk:2.15.3&#39;
    implementation &#39;pub.devrel:easypermissions:0.4.0&#39;
    implementation &#39;com.squareup.picasso:picasso:2.71828&#39;
    testImplementation &#39;junit:junit:4.12&#39;
    androidTestImplementation &#39;androidx.test.ext:junit:1.1.1&#39;
    androidTestImplementation &#39;androidx.test.espresso:espresso-core:3.2.0&#39;
    implementation &#39;com.google.firebase:firebase-analytics:17.4.3&#39;

}

Build Gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath &quot;com.android.tools.build:gradle:4.0.0&quot;
        classpath &#39;com.google.gms:google-services:4.3.3&#39;

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

        maven { url &#39;https://maven.google.com&#39;}
        maven { url &#39;https://tokbox.bintray.com/maven&#39;}
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

errori nei logcat nel DEBUG

        2020-10-14 21:46:16.629 12564-12564/com.conta.ftof E/RegistrationActivity: err : com.google.firebase.FirebaseException: An internal error has occurred. [ Error code:39 ]
        
        2020-10-14 21:46:16.697 2026-4029/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -&gt; BAD_AUTHENTICATION. Account: &lt;ELLIDED:718006122&gt;, App: com.google.android.gms, Service: oauth2:https://www.googleapis.com/auth/emeraldsea.mobileapps.doritos.cookie
        rlv: Long live credential not available.
            at gbq.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):17)
            at gac.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):118)
            at cqx.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):235)
            at cqx.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):108)
            at cqx.a(:com.google.android.gms@202614030@20.26.14 (100408-320008519):240)
            at cox.onTransact(:com.google.android.gms@202614030@20.26.14 (100408-320008519):5)
            at android.os.Binder.transact(Binder.java:675)
            at csu.onTransact(:com.google.android.gms@202614030@20.26.14 (100408-320008519):2)
            at android.os.Binder.transact(Binder.java:675)
            at zyq.onTransact(:com.google.android.gms@202614030@20.26.14 (100408-320008519):17)
            at android.os.Binder.execTransact(Binder.java:739)
        
            2020-10-14 21:46:16.718 612-832/? E/BufferQueueProducer: [] mConsumerName == NULL!!!!!!
    2020-10-14 21:46:16.577 688-1286/? E/dubaid: [DubaiUtils.h] parseMessage# Failed to find second tag: uid=
    2020-10-14 21:46:16.577 688-1286/? E/dubaid: [SystemHandler.cpp] parsePartialWakelockAcquiredMessage# Failed to parse count: lock=220525660 tag=*gms_scheduler*:internal count=0
    2020-10-14 21:46:16.577 688-1286/? E/dubaid: [SystemHandler.cpp] onPartialWakelockAcquireMessage# Failed to parse message
    2020-10-14 21:46:16.580 2664-7832/? E/Volley: [420] BasicNetwork.performRequest: Unexpected response code 503 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/sendVerificationCode?alt=proto&amp;key=AIzaSyA3J5SF6W94IhtZ_dQ6UOVqUhIN133zrhU

2020-10-14 21:46:15.834 1272-3654/? E/WifiService: enforceCanAccessScanResults: hiding ssid and bssidLocation mode is disabled for the device

答案1

得分: 0

在我的情况下,遇到了类似的问题,这里提出的解决方案解决了我的问题:

https://stackoverflow.com/a/50868434/559144

我试图从针对我发布版应用程序包使用keytool命令获取SHA1签名,但那并没有起作用,解决问题的方法是从Google Play控制台中获取该签名,在应用签名设置下,然后将其粘贴到Firebase控制台中,而无需删除调试签名,然后获取最新的Google JSON文件,放入Android Studio中,重新构建已签名的捆绑包,上传,发布,现在一切都运行良好。

英文:

in my case, having similar problem, the solution proposed here solved my issue:

https://stackoverflow.com/a/50868434/559144

I was trying to grab the SHA1 signature from the keytool command against my app bundle compiled in release mode, but that did not work, what fixed the issue was to grab that signature from the google play console, under app signing settings, then paste it into Firebase console, without removing the debug signature, then grab latest google json file, put it in Android Studio, rebuild signed bundle, upload, release, and now all works great.

huangapple
  • 本文由 发表于 2020年10月15日 03:51:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/64360590.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定