Tra*_*rax 3 android firebase react-native firebase-authentication google-signin
我正在尝试在我的项目中使用带有 firebase 的 google 登录。我以前使用过它并且成功了,但这次我无法使它工作,请遵循所有正确的步骤。使用反应原生 0.60。
GitHub 上的疑难解答建议添加signingConfigs到 build.gradle,但它已经在那里了。SHA 密钥是正确的,在另一个项目中使用它并且工作正常,唯一的区别是 react-native 0.59
Create new fire base project
Choose a Google Cloud Platform (GCP) resource location
Set support email
Enable Google Auth
Added the Web Client ID from Google Auth to project config
SHA Key generated with keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore // Same key worked with other project
Placed google-services.json in app/ // Content matches the web client id from page and project config
Added all the required code to 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()
}
}
Run Code Online (Sandbox Code Playgroud)
//应用级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'
Run Code Online (Sandbox Code Playgroud)
// 应用程序启动
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...
Run Code Online (Sandbox Code Playgroud)
似乎与 rn 0.60 的大多数教程相反,使用的 SHA 应该来自 android/app 文件夹
keytool -list -v -alias androiddebugkey -keystore projectname\android\app\debug.keystore
| 归档时间: |
|
| 查看次数: |
3666 次 |
| 最近记录: |