问题描述
我使用 @react-native-community/google-signin 在调试模式下运行良好,但不适用于 android 发布模式(独立应用)。
我已经尝试过文档中所说的,但什么也没做。 https://reactnative.dev/docs/signed-apk-android https://github.com/react-native-google-signin/google-signin
谁能帮帮我...
我从我的密钥库版本中获取了凭据 OAuth 2.0 客户端 ID 宽度 SHA-1。
这是我的代码
const signIn = async () => {
try {
GoogleSignin.configure({
scopes: ['email','profile'],webClientId: webClient
offlineAccess: true,forceCodeForRefreshToken: true,accountName: ''
});
await GoogleSignin.hasPlayServices();
const isSignedIn = await GoogleSignin.isSignedIn();
if(isSignedIn){
await GoogleSignin.revokeAccess();
await GoogleSignin.signOut();
}
const respLogGoogle = await GoogleSignin.signIn();
const responseLogBack =
await dispatch(authActions.loginSocials(
respLogGoogle.user.email,respLogGoogle.user.name,respLogGoogle.user.photo
))
;
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
// user cancelled the login flow
console.log('Cancel');
} else if (error.code === statusCodes.IN_PROGRESS) {
console.log('Signin in progress');
// operation (f.e. sign in) is in progress already
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
console.log('PLAY_SERVICES_NOT_AVAILABLE');
// play services not available or outdated
} else {
// some other error happened
console.log("GOOGLE:",error);
}
}
};
Gradle 属性
MYAPP_UPLOAD_STORE_FILE='KeyStore.keystore'
MYAPP_UPLOAD_KEY_ALIAS='keyAlias'
MYAPP_UPLOAD_STORE_PASSWORD='*********'
MYAPP_UPLOAD_KEY_PASSWORD='='*********''
构建gradle
signingConfigs {
release {
if (project.hasProperty('KeyStore.keystore')) {
storeFile file('KeyStore.keystore')
storePassword '*******'
keyAlias 'keyAlias'
keyPassword '*********'
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
/* signingConfigs {
} */
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production,you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro"
signingConfig signingConfigs.release
}
}
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)