我正在尝试使用react-native和firebase构建一个应用程序,并且在此过程中遇到了相当多的安装问题。目前,我的问题是应用程序在启动后立即崩溃,在安装后的第一次启动(调试或释放模式)。一旦被杀死并重新开始,它就能正常工作。
日志中似乎没有记录特定错误。使用日志消息来缩小崩溃点,它似乎是:
Firebase.auth().signInAnonymouslyAndRetrieveData()
或doc_ref.get()
其中doc_ref
是Firebase.firestore().collection("profiles").doc(instance_id)
取决于通话顺序。
在上面,“开始”意味着做
如果尚未安装应用程序,请执行以上任一操作导致其启动并立即崩溃,但随后会显示在手机的已安装应用程序列表中。安装应用程序后重复上述操作会使其按预期工作。
任何帮助都会非常感激!
环境:
相关申请代码:
// Top level app component
export default class App extends React.Component<Props, State> {
...
componentDidMount() {
try {
IconFiles.load();
StatusBar.setHidden(true);
BackHandler.addEventListener("hardwareBackPress",
this.hardwareBackPress.bind(this));
const that = this;
this.setupProfile()
...
.catch(function (err) {
Log.error(`error in new App() end of promise chain: ${err}`);
Crashlytics.recordError(1, err);
});
...
export default class Profile {
...
public static getProfile(): Promise<Profile> {
const that = this;
Log.debug(`getProfile() starting: ${RNFirebase.SDK_VERSION}`);
return RNFirebase.auth().signInAnonymouslyAndRetrieveData()
.then(function (blah) {
Log.debug(`getProfile() signInAnonymouslyAndRetrieveData() return okay: ${blah}`);
return RNFirebase.iid().get()
})
.then(function (instance_id: string): Promise<Profile> {
Log.debug(`getProfile() got instance id: ${instance_id}`);
const firestoreCollection: any
= RNFirebase.firestore().collection("profiles");
const doc_ref = firestoreCollection.doc(instance_id);
Log.debug(`getProfile() got profile doc_ref: ${doc_ref.id}`);
return doc_ref.get();
})
.then(function (doc_snapshot: any /*Firebase.firestore.DocumentSnapshot*/) {
Log.debug(`getProfile() got profile doc_snap: ${doc_snapshot.exists}`);
let data: Constrob;
if (doc_snapshot.exists) {
data = <Constrob>doc_snapshot.data();
} else {
data = {
created_date: new Date(),
feedback: null,
starts: null,
token: null,
};
}
return new Profile(doc_snapshot.ref, data, doc_snapshot.exists);
});
}
...
的package.json ...
"dependencies": {
"firebase": "^4.12.0",
"loglevel": "^1.6.0",
"moment": "^2.21.0",
"react": "^16.3.1",
"react-native": "0.55.2",
"react-native-firebase": "^4.0",
"react-native-htmlview": "^0.12.1",
"react-native-star-rating": "^1.0.9",
"react-native-svg": "^6.3.1",
"react-native-vector-icons": "^4.6.0"
},
机器人/的build.gradle
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.0"
classpath "com.google.gms:google-services:3.1.2"
classpath "io.fabric.tools:gradle:1.+"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
机器人/ gradle.properties
android.useDeprecatedNdk=true
android.enableAapt2=false
机器人/ gradle这个/ gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
机器人/应用/的build.gradle
apply plugin: "com.android.application"
apply plugin: "io.fabric"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
defaultConfig {
applicationId "com.doorkey"
minSdkVersion 16
targetSdkVersion 23
versionCode 4
versionName "1.0.3"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
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
}
}
}
}
dependencies {
implementation(project(":react-native-firebase")) {
transitive = false
}
implementation "com.google.android.gms:play-services-base:12.0.1"
implementation "com.google.firebase:firebase-core:12.0.1"
implementation "com.google.firebase:firebase-auth:12.0.1"
implementation("com.crashlytics.sdk.android:crashlytics:2.9.1@aar") {
transitive = true
}
implementation "com.google.firebase:firebase-firestore:12.0.1"
implementation "com.google.firebase:firebase-messaging:12.0.1"
implementation project(':react-native-vector-icons')
implementation project(':react-native-svg')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// 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 plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
你读过这个吗?
&#34;如果GoogleService-Info.plist未在XCode中注册,则您的应用会在启动后立即崩溃。&#34;
阅读&#39; IOS故障排除&#39; https://rnfirebase.io/docs/v4.2.x/troubleshooting/ios
答案 1 :(得分:0)
我对RN v0.55.4有类似的问题
最简单的解决方案是使用upgrade guide或您的偏好方法将RN更新为v> = 0.57。
另外,如果要升级点火项目,则还需要解决不兼容问题,see here