android - react native 谷歌登录开发人员错误代码 10

标签 android firebase react-native firebase-authentication google-signin

我正在尝试为我的项目使用 google 登录和 firebase。我以前用过它并成功了,但这次我无法让它工作,遵循了所有正确的步骤。使用 React Native 0.60。

GitHub 上的 Troubleshoot 建议将 signingConfigs 添加到 build.gradle,但它已经在那里了。 SHA Key 是正确的,在另一个项目中使用它并且工作正常,唯一的区别是 react-native 0.59

创建新的消防基地项目 选择 Google Cloud Platform (GCP) 资源位置 设置支持邮箱 启用谷歌身份验证 将来自 Google Auth 的 Web Client ID 添加到项目配置 使用 keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore 生成的 SHA key //相同的 key 适用于其他项目 将 google-services.json 放在 app///内容与页面和项目配置中的 Web 客户端 ID 相匹配 将所有必需的代码添加到 build.gradle 我在构建过程中没有收到任何错误。

//主build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")
        classpath 'com.google.gms:google-services:4.2.0'

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

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
    }
}

//应用级build.gradle

...
def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.profitmaster"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }
    }

    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-core:17.0.0'

    if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'

//应用启动

warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - native-base: https://github.com/GeekyAnts/NativeBase#readme
  - react-native-google-signin: https://github.com/react-native-community/react-native-google-signin
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info Starting JS server...
info Installing the app...

> Configure project :app
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Task :app:processDebugGoogleServices
Parsing json file: ...\projectPath\android\app\google-services.json

> Task :app:installDebug
11:46:22 V/ddms: execute: running am get-config
11:46:22 V/ddms: execute 'am get-config' on '192.168.240.103:5555' : EOF hit. Read: -1
11:46:22 V/ddms: execute: returning
Installing APK 'app-debug.apk' on 'Google Nexus 5 - 5.0' for app:debug
11:46:22 D/app-debug.apk: Uploading app-debug.apk onto device '192.168.240.103:5555'
11:46:22 D/Device: Uploading file onto device '192.168.240.103:5555'
11:46:22 D/ddms: Reading file permision of ...\projectPath\android\app\build\outputs\apk\debug\app-debug.apk as: rwx------
11:46:22 V/ddms: execute: running pm install -r -t "/data/local/tmp/app-debug.apk"
11:46:26 V/ddms: execute 'pm install -r -t "/data/local/tmp/app-debug.apk"' on '192.168.240.103:5555' : EOF hit. Read: -1
11:46:26 V/ddms: execute: returning
11:46:26 V/ddms: execute: running rm "/data/local/tmp/app-debug.apk"
11:46:26 V/ddms: execute 'rm "/data/local/tmp/app-debug.apk"' on '192.168.240.103:5555' : EOF hit. Read: -1
11:46:26 V/ddms: execute: returning
Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 13s
65 actionable tasks: 3 executed, 62 up-to-date
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync adb ENOENT
info Starting the app...

最佳答案

似乎与 rn 0.60 的大多数教程相反,使用的 SHA 应该来自 android/app 文件夹

keytool -list -v -alias androiddebugkey -keystore 项目名\android\app\debug.keystore

关于android - react native 谷歌登录开发人员错误代码 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56998163/

相关文章:

java - 从可扩展卡片 View android中删除箭头图标

java - Android 预览中的空白屏幕

android - 将 Firebase 数据库中的值加载到 Android 中的下拉 TextView 中

angularjs - 使用 AngularJS + Firebase + Google App Engine 进行用户身份验证和授权

android - react native : Version code too big for Android using enableSeparateBuildPerCPUArchitecture

javascript - 在与 Create-React-App 一起使用时,我们应该导入整个库还是特定的单个组件?

java - 简单代码上的简单错误,但我不明白?

android - 如何在webview中显示键盘隐藏的内容

android - 通过滑出应用程序来关闭应用程序时调用 Firebase onDisconnected

react-native - 错误 : undefined Unable to resolve module `@react-navigation/bottom-tabs`