在上面,“开始”的意思是做
// 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"
},
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"
}
}
}
android.useDeprecatedNdk=true
android.enableAapt2=false
...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Android/app/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'
你读过这个吗?
“如果GoogleService-info.plist没有在XCode中注册,你的应用程序将在启动后立即崩溃。”
阅读'iOS疑难解答'https://rnfirebase.io/docs/v4.2.x/troleshooting/iOS
我是react native的新手,我正在尝试使用android Studio开始我的第一个项目。我遵循react native的“设置开发环境”中的说明,最终使用 然后我在android studio中打开了我的项目来启动AVD,但是gradle抛出了以下错误 错误:评估脚本时出现问题。 无法运行程序“node”(在目录“/home/deadshot/documents/playground/a
我正在开发的应用程序的调试版本有效。然而,当我为它构建apk时,当我试图启动它时,应用程序立即崩溃。 以下是安装调试版本时收到的信息/消息: 任务:react-native-picker:compiledebugjavawithjavac注意:/users/someguy/projects/third/some-app/node_modules/react-native-picker/androi
我根据模板创建了一个应用程序,并填充了一些日志,如下所示 和 当我运行它时,我注意到有时它会启动三次。(有时,它会发射两次,有时发射一次)。 日志如下 起初,我以为是活动启动了3次,但是当我注销应用程序oncread时,它也启动了3次。我显式地放了一个静态变量,并且清楚地看到应用程序是3个不同的实例(因为变量没有在3次中递增)。 确认这不是因为配置更改或活动被终止(如中所述)https://sta
我在全球范围内安装了react native,并确认安装在Windows 10上。然后,我在PowerShell中运行react-native命令来安装materials kit和vector图标。这些包的安装失败,该目录不再被视为react本机项目目录。因此,我必须重新安装react native。 如何在不导致系统卸载react native的情况下安装materials kit和vector
我需要在安装后立即将gcm注册到activity中的字符串变量,但我得到的是null值,而不是GCMinentService类注册显示的onRegistered值,但仅在第二次启动后第一次启动安装时才将其分配到activity中的变量。工作正常
当我清理gradle时,我得到错误:“不能将进程工作目录设置为'C:\code\rn\xs\node_modules\react-native-image-picker\example\android':不能设置当前目录(errno 3)” 当我试图在gradle中重建时,我也会得到错误:“清单合并失败:属性application@appcomponentFactory value=(Androi