首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >因为“回-原生-谷歌-签名”而导致本机应用程序崩溃

因为“回-原生-谷歌-签名”而导致本机应用程序崩溃
EN

Stack Overflow用户
提问于 2019-09-24 10:03:43
回答 3查看 1.6K关注 0票数 5

React本机-本机-google-signin

在我安装了react本机-google-sigin之后

代码语言:javascript
复制
npm i react-native-google-signin

当应用程序启动时,它突然崩溃(强制关闭),我已经完成了github文档中告诉我的所有步骤,但当我立即运行app崩溃时,日志中没有任何错误。( android-log和adb logcat *:S React原住民:v ReactNativeJS:V nor )

这是我的密码:

build.gradle

代码语言:javascript
复制
// 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"
        googlePlayServicesAuthVersion = "16.0.1" // <--- use this version or newer
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.1")
        classpath 'com.android.tools.build:gradle:3.1.2' // <--- use this version or newer
        classpath 'com.google.gms:google-services:4.1.0' // <--- use this version or newer
        // 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()
    }
}

settings.gradle

代码语言:javascript
复制
rootProject.name = 'App'
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':react-native-google-signin', ':app'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':app'

app/build.gradle

代码语言:javascript
复制
dependencies {
    implementation project(':react-native-reanimated')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation(project(":react-native-google-signin"))
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation(project(':react-native-maps')){
            exclude group: 'com.google.android.gms', module: 'play-services-base'
            exclude group: 'com.google.android.gms', module: 'play-services-maps'
        }
        implementation 'com.google.android.gms:play-services-base:10.0.1'
        implementation 'com.google.android.gms:play-services-maps:10.0.1'

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

apply plugin: 'com.google.gms.google-services' // <--- this should be the last line

有人能帮我解决这个错误吗?因为当我卸载react-native-google-signin

代码语言:javascript
复制
npm uninstall react-native-google-signin

它工作得很好

EN

回答 3

Stack Overflow用户

发布于 2019-10-22 16:45:56

在app/build.gradle中设置implementation(project(":@react-native-community_google-signin"))

代码语言:javascript
复制
 implementation(project(":react-native-google-signin"))
票数 3
EN

Stack Overflow用户

发布于 2019-12-13 11:35:10

are本机Google签名有两个版本:

  • react-native-google-signin for React本地<= 0.59
  • @react-native-community/google-signin for React >= 0.60

由于您使用的是第一个版本,我想您的Reacti原住民版本是<= 0.59,如果没有,您必须切换到社区版本。

除此之外,您的android/build.gradle还包含一个复制的classpath com.android.tools.build:gradle

代码语言:javascript
复制
classpath("com.android.tools.build:gradle:3.4.1")
classpath 'com.android.tools.build:gradle:3.1.2' // <--- use this version or newer

由于React本机Google需要3.1.2或更高版本,所以您可以安全地删除第二个版本。

此外,根据文档中所述内容,您的android/app/build.gradle错过了以下实现:

代码语言:javascript
复制
implementation "com.android.support:appcompat-v7:23.0.1"

希望它能帮上忙

票数 2
EN

Stack Overflow用户

发布于 2019-12-14 12:17:44

既然您启用了Hermes,就意味着您有RN 0.60+。

只需使用社区版本:

"@react-native-community/google-signin": "^3.0.3"

RN 0.60+有自动收费,所以您不需要这些行

代码语言:javascript
复制
// settings.gradle
include ':react-native-google-signin', ':app'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/google-signin/android')


// MainApplication.java
new RNGoogleSigninPackage()

我认为您也应该尝试对其他库使用这种自动连接(您可能需要使用它们的最新版本)。

如果你仍然不工作,你可以在这里得到更多的信息。

https://github.com/react-native-community/react-native-google-signin/blob/master/docs/android-guide.md

(请注意,除非使用手动连接并检查步骤1-3,否则不应执行步骤4)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58077816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档