Проверка телефона Flutter Firebase не работает после выпуска в Play Store

# #firebase #flutter #firebase-authentication

Вопрос:

Я пытаюсь использовать проверку телефона с помощью firebase. Мой код отлично работает как в режиме отладки, так и в режиме выпуска, но когда я загружаю свое приложение в Play Store, оно не работает.

Вот ошибка, которую это дает:

«В этом запросе отсутствует действительный идентификатор приложения, что означает, что ни проверки SafetyNet, ни проверки reCAPTCHA не увенчались успехом. Пожалуйста, повторите попытку или проверьте logcat для получения более подробной информации.’

Я добавил все ключи в firebase, включил API проверки устройств Android, и все равно он выдает ту же ошибку.

Вот код, который я использовал для проверки телефона:

 Future<void> onVerifyCode(BuildContext context, UserModel userModel) async {
    print('i am verifycode');
    void verificationDone(PhoneAuthCredential credential) async {
      await _firebaseAuth.signInWithCredential(credential).then((value) {
        if (value.user != null) {
          Navigator.push(
            context,
            MaterialPageRoute(
              builder: (_) => AccountDetails(
                userModel: userModel,
              ),
            ),
          );
        } else {
          Fluttertoast.showToast(msg: "Error validating OTP, try again");
        }
      }).catchError((error) {
        print('verify done error'   error);
        Fluttertoast.showToast(msg: '$error');
      });
    }

    void verificationFail(FirebaseAuthException e) {
      print('i am fail'   e.message);
      Fluttertoast.showToast(msg: '${e.message}');
    }

    void codeSent(String verificationId, int resendToken) async {
      print('i am codeSent');
      _verificationId = verificationId;
      // dialogBox(verificationId, resendToken);
      // Create a PhoneAuthCredential with the code
    }

    final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
        (String verificationId) {
      _verificationId = verificationId;
    };

    await _firebaseAuth
        .verifyPhoneNumber(
            phoneNumber: " 91${userModel.phone}",
            timeout: const Duration(seconds: 60),
            verificationCompleted: verificationDone,
            verificationFailed: verificationFail,
            codeSent: codeSent,
            codeAutoRetrievalTimeout: codeAutoRetrievalTimeout)
        .catchError((error) {
      print('verifyPhoneNo'   error);
      Fluttertoast.showToast(msg: '$error');
    });
  }
 

Вот моя сборка.gradle(уровень приложения):

 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 GradleException("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: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 30

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.shdigital.vasts"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "androidx.browser:browser:1.3.0"
    implementation 'com.android.support:multidex:1.0.3'
}
 

Here is my build.gradle(project level):

 buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.4'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

Вот мой файл pub.yaml:

 name: demoappname

description: A new Flutter application.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.3 4

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  
  cupertino_icons: ^1.0.0

  provider: ^4.3.2 4

  video_player: ^2.0.2

  chewie: ^1.0.0

  flutter_windowmanager: ^0.0.2

  dio: ^3.0.10

  path_provider: ^1.6.27

  path: ^1.7.0

  #firebase
  firebase_core: "^0.7.0"

  firebase_auth: "^0.20.1"

  connectivity: ^2.0.2

  pin_code_text_field: ^1.7.1

  share: ^0.6.5 4

  http: ^0.12.2

  fluttertoast: ^7.1.6

  shared_preferences: ^0.5.12 4

  razorpay_flutter: 1.1.0

  image_picker: ^0.6.7 21



dev_dependencies:
  flutter_test:
    sdk: flutter


flutter:

 
  uses-material-design: true

  assets:
    - assets/images/
 

Комментарии:

1. Вы включили свой SHA ключ для подписи в Play Store в проект u r?

2. да, я включил все ключи из playstore .