我正在尝试使用反应-本机-谷歌-签名插件进行谷歌登录,但它给了我一个Developer_Error.I已经完成了与它的document.here中提到的完全相同的代码和步骤。
1.安装了使用npm的本机-google-signin插件-本机-google-signin。2.然后将其链接到react-本机链接react-原生链接--google--3.之后,我设置了他们在文档中提到的build.gradle文件。
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesAuthVersion = "15.0.1"
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
}
allprojects {
repositories {
mavenLocal()
google()
maven {url "https://maven.google.com"}
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}4.更新android/app/build.gradle,
dependencies {
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation project(':react-native-fbsdk')
compile project(':react-native-vector-icons')
compile project(':react-native-fused-location')
compile project(':react-native-fs')
compile project(':react-native-image-resizer')
compile project(':react-native-geocoder')
compile project(':react-native-device-info')
compile project(':react-native-image-picker')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.facebook.react:react-native:+" // From node_modules
implementation project(":react-native-google-signin")
compile (project(':react-native-maps')){
exclude group: "com.google.android.gms"
}
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services' 5.使用android生成SHA1密钥,并在firebase中生成google-services.json文件。
6.然后像这样设置login.js页面。
async componentDidMount() {
this._configureGoogleSignIn();
}
_configureGoogleSignIn() {
GoogleSignin.configure({
webClientId: '775060548127-5nfj43q15l75va9pfav2jettkha7hm2a.apps.googleusercontent.com',// my clientID
offlineAccess: false
});
}
async GoogleSignin() {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
// this.setState({ userInfo, error: null });
Alert.alert("success:" + JSON.stringify(userInfo));
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
// sign in was cancelled
Alert.alert('cancelled');
} else if (error.code === statusCodes.IN_PROGRESS) {
// operation in progress already
Alert.alert('in progress');
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
Alert.alert('play services not available or outdated');
} else {
Alert.alert('Something went wrong', error.toString());
this.setState({
error,
});
}
}
}这些是我的细节,所以请有人帮我解决这个问题,我找不到合适的解决方案,online.and,是的,我的SHA1和clientID是正确的,我已经把它写好了。
发布于 2020-05-21 13:02:54
我认为有时可能会有旧的指纹(以前来自不同的开发程序)可能会发生冲突。所以SHA1应该是合适的。删除旧的SHA-1并重新下载google-services.json
https://stackoverflow.com/questions/54417232
复制相似问题