因为项目需要,需要用react native 来写两个app。想要借助facebook官网的demo去学习下:https://github.com/fbsamples/f8app,但是在搭建中却遇到了各种奇葩问题。
1,首先遇到的是duplicate parse 这样一个报错信息。我就懵逼了。
解决方案:
{
"name": "F8v2",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "babel-node ./server/server.js",
"import-data": "babel-node ./scripts/import-data-from-parse.js",
"update-schema": "babel-node ./server/schema/updateSchema.js",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"art": "~0.10.1",
"babel-cli": "~6.10.1",
"babel-relay-plugin": "~0.9.1",
"crc32": "~0.2.2",
"express": "~4.14.0",
"express-graphql": "~0.5.3",
"graphql-relay": "~0.4.2",
"moment": "~2.13.0",
"parse": "1.9.2",
将parse :改为了1.9.2。
2,紧接着给我报错,说主题有问题
/Users/liuhanlin/qiniuwork/ticket/f8app/android/app/src/main/AndroidManifest.xml:55:11-70 Error:
Attribute activity#com.facebook.FacebookActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar) from AndroidManifest.xml:55:11-70
is also present at [com.facebook.android:facebook-android-sdk:4.18.0] AndroidManifest.xml:32:13-63 value=(@style/com_facebook_activity_theme)
Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:53:7-56:46 to override
:app:processDebugManifest FAILED
找到那个xml
<activity android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
解决方法:
直接干掉那个
android:theme="@android:style/Theme.Translucent.NoTitleBar"
哪一行就可以了
3,后来终于能运行了,结果呢gmc是google的api,我权限登录不要用。
直接报错
java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.android.gms.iid.zzd' (declaration of 'com.google.android.gms.iid.zzd' appears in /data/app/com.facebook.f8-1/base.apk)
at com.google.android.gms.iid.zzd.zzdL(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.zzd.<init>(Unknown Source)
at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService.onHandleIntent(RNPushNotificationRegistrationService.java:20)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
各方面求证,
I finally solved this issue by doing the following changes
comment out those lines in F8App.js
render: function() {
// if (!this.props.isLoggedIn) {
// return ;
// }
return (
);
},
});
please make sure that you remove PushNotificationController in that code
do the following changes in setup.js
render() {
// if (this.state.isLoading) {
// return null;
// }
return (
);
so this will load directly your main screen showing schedules and navigation drawer
就这样啦。继续写代码。