Firebase电话登录报错:指定登录提供商已禁用,配置后仍异常
Flutter集成Firebase电话登录报错问题
已完成Firebase控制台应用注册,启用电话登录功能,添加了通过./gradle signingreport获取的SHA1和SHA256指纹,下载并配置了google-services.json,但仍触发报错:
given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console
此前还出现过错误:
SMS verification code request failed: unknown status code: 17499 Error code:39
已尝试执行flutterfire config、参考网络解决方案、修改gradle版本,问题仍未解决。
相关配置及代码
Firebase控制台截图
app/build.gradle
plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'com.google.gms.google-services' } def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new RuntimeException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file("key.properties") keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) android { namespace "com.xxxxhore.mosaic_doctors" compileSdkVersion flutter.compileSdkVersion compileSdkVersion 33 sourceSets { main.java.srcDirs += 'src/main/kotlin' } signingConfigs { release { // storeFile file("key2.jks") // storePassword "keystore3" // keyAlias "key" // keyPassword "keystore3" keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release shrinkResources false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } kotlin { jvmToolchain(8) } android.lintOptions { disable 'InvalidPackage' checkReleaseBuilds false abortOnError false ignoreWarnings true //false } defaultConfig { applicationId "com.xxxxhore.mosaic_doctors" minSdkVersion 20 targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true } } flutter { source '../..' } dependencies { // implementation 'androidx.appcompat:appcompat:1.6.1' // implementation 'com.google.android.material:material:1.0.0' // implementation 'androidx.legacy:legacy-support-v4:1.0.0' // implementation 'androidx.recyclerview:recyclerview:1.0.0' // implementation "androidx.browser:browser:1.3.0" // implementation platform('com.google.firebase:firebase-bom:25.12.0') // implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // implementation 'androidx.multidex:multidex:2.0.0' // implementation 'com.google.firebase:firebase-auth' // implementation 'com.google.firebase:firebase-firestore-ktx' } tasks.register("prepareKotlinBuildScriptModel"){} apply plugin: 'com.google.gms.google-services'
project/build.gradle
buildscript { ext.kotlin_version = '1.8.22' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.2.0' classpath 'com.google.gms:google-services:4.3.14' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir }
验证码发送代码
Future<void> sendOtp( String phoneNo) async{ await FirebaseAuth.instance.verifyPhoneNumber( phoneNumber: phoneNo, verificationCompleted: (PhoneAuthCredential credential) async{ await _auth.signInWithCredential(credential); }, verificationFailed: (FirebaseAuthException e) { if (e.code == 'invalid-phone-number') { print('The provided phone number is not valid.'); }else { print(e.code); } // Handle other errors }, codeSent: (String verificationId, int? resendToken) { this.verificationId = verificationId; print("verif id : ${this.verificationId}"); }, codeAutoRetrievalTimeout: (String verificationId) { this.verificationId = verificationId; }, ) ; }
内容的提问来源于stack exchange,提问作者Yazan
相关产品推荐
相关产品推荐

