react native related problems and solutions

將用博客來記錄自己在react native開發(fā)過程中遇到的問題,這篇主要側(cè)重于配置過程中用到的問題。這種問題可能只需要一個合適的答案,找尋這個答案可能需要花費(fèi)半天的工作時間,甚至更久。
可以在我的博客http://haiyangjiajian.com/交流更多相關(guān)內(nèi)容。

1. error: could not install smartsocket listener: Address already in use

解決方法:genymotion的adb設(shè)置Android sdk

2. cant find local.properties

解決方法:手動添加文件,然后sdk.dir=xx

3. Undefined symbols for architecture x86_64: “std::terminate()”

解決方法:I ran in to this issue as well, and the solution @charpeni proposed solved the issue. To be clear for others, if you are upgrading to 0.26+ then you need to make the following changes.

In ios/YourProject.xcodeproj/project.pbxproj, look for the two lines like OTHER_LDFLAGS = "-ObjC";. Replace them with the following:

 OTHER_LDFLAGS = (
        "-ObjC",
        "-lc++",
);

4. react-native run-android時出現(xiàn)Could not download imagepipeline.aar

解決方法:修改build.gradle的版本,com.android.tools.build:gradle:2.1.0,改為更高的,然后更改gradle/wrapper/gradle-wrapper.properties中相應(yīng)的gradle-2.10-all.zip。

5. Application ReactExample has not been registered. This is either due to a require() error during initialization or failure to call AppRegistry.registerComponent.

解決方法: 關(guān)掉其他react-native server和node進(jìn)程

6. realm對于schema的更新需要重新啟動應(yīng)用,如果應(yīng)用已經(jīng)在本地數(shù)據(jù)庫中寫入了數(shù)據(jù),則需要將應(yīng)用刪除,重裝,因為schema和已有數(shù)據(jù)會存在沖突。

7. 自己react-native init test.然后測試realm。在ios端總是提示‘Cannot read property 'debugHosts' of undefined’ 和‘Module AppRegistry is not a registered callable module’

解決方法:是rnpm的問題,對于ios項目來說,project name中不能有excample和test,需要在packaje.json中加入。但是自己測試并沒有成功。測試將project name命名為其他可以。Realm團(tuán)隊稱在下一個版本中會修復(fù)這個問題

"rnpm": {
    "ios": {
    "project": "ios/<project-name>.xcodeproj"
    }
}

對于andorid新建的包含realm的rn項目中還會有'Missing Realm constructor-please ensure RealmReact framework is included'的問題

解決方法是在MainApplication.java中添加如下兩行

 import io.realm.react.RealmReactPackage; // ADD THIS
  @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RealmReactPackage() // AND THIS
      );
    }

如在android中出現(xiàn)“Project with path ':realm' could not be found in project ':app'. realm”的問題,則需要在setting.gradle中添加

 include ':realm'
 project(':realm').projectDir = new File(settingsDir, '../node_modules/realm/android')

8. react native realm的可視化

官方文檔中只介紹了Objective-C,Java,Swift中有realm的可視化工具Realm Browser(暫時只支持mac),在react native中也可以使用。

console.log(db.path);//輸出realm在模擬器上存儲的目錄
adb pull /data/data/<packagename>/files/ . //從模擬器上或者真機(jī)(需要root)拉取realm文件

用Realm Browser打開即可,默認(rèn)名字是default.realm

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,938評論 25 709
  • afinalAfinal是一個android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,857評論 2 45
  • 結(jié)婚后才知道所謂的家家都有難念的經(jīng),工地一起的材料員談起了結(jié)婚20年以后他們現(xiàn)在的種種,故事是這樣的。 結(jié)婚20年...
    芬悅靈閱讀 222評論 0 1
  • 將水替換為金屬的對比
    89cc282590b3閱讀 698評論 0 0
  • 2017.10.22 (星期日) 晴 第二十七篇 乖巧懂事的女兒,沒有因是星期日而睡懶覺,還是定了五點半的鬧鈴,早...
    雨后彩虹_56e2閱讀 487評論 0 3

友情鏈接更多精彩內(nèi)容