ReactNative開發(fā)-紅屏\報(bào)錯(cuò)記錄(持續(xù)更新...)

BUG描述

error: bundling failed: "Unable to resolve module react-native/Libraries/EventEmitter/EventEmitter

解決辦法

1.先把node_modules目錄下的react-native-root-siblings刪除

2.再把根目錄下package.json里的react-native-root-toast刪除

3.然后重新安裝npm install react-native-root-toast —save

1.進(jìn)入/node_modules/react-native-root-siblings/lib/AppRegistryInjection.js

2.找到import EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitter’;并修改為import EventEmitter from 'react-native/Libraries/EventEmitter/EventEmitter';


BUG描述

A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugApk'.

Configuration with name 'default' not found.

解決辦法

待補(bǔ)充


BUG描述

Execution failed for task ':app:installDebug'.

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.gs2000_rn signatures do not match the previously installed version; ignoring!

解決辦法

刪除當(dāng)前鏈接設(shè)備中已有的項(xiàng)目


BUG描述

Execution failed for task ':app:prepareGs2000_rnReactNativeImagePickerUnspecifiedLibrary'.

Could not expand ZIP 'C:\Users\user\WebstormProjects\gs2000e_rn\node_modules\react-native-image-picker\android\build\outputs\aar\react-native-image-picker-release.aar'.

解決辦法

網(wǎng)絡(luò)問(wèn)題,刪除node-modules目錄,重新執(zhí)行npm install


BUG描述

Execution failed for task ':app:mergeDebugResources'.

Error: Cannot create directory C:\Users\user\WebstormProjects\union\union\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values

解決辦法

刪除項(xiàng)目根目錄下\android\app的build文件夾即可


BUG描述

What went wrong:

Execution failed for task ':app:installRelease'.

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.union signatures do not match the previously installed version; ignoring!

解決辦法

這是由于正在安裝的APP與已安裝再手機(jī)上的APP沖突引起的。直接刪除手機(jī)上的APP即可。


BUG描述

*What went wrong:

A problem occurred configuring project ':app'.

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

解決辦法

項(xiàng)目缺少android環(huán)境變量,從其他原生android項(xiàng)目根目錄下復(fù)制一份local.properties文件到RN項(xiàng)目的android目錄下即可!


BUG描述

發(fā)布新的熱更新版本時(shí)出現(xiàn)問(wèn)題

Cannot find module 'metro-bundler/src/babelRegisterOnly

解決辦法

根據(jù)問(wèn)題查找得知是在高版本(0.52)以上在metro-bundler引用的路徑錯(cuò)了。將node_modules\react-native-update\local-cli\lib\bundle.js的439行種的metro-bundler改成metro可成功運(yùn)行![參考文獻(xiàn)


BUG描述

SyntaxError:Strict mode does not allow function declarations in a lexically nested statement.

react-native的源碼問(wèn)題,在use strict嚴(yán)苛模式下,不允許如上的方式聲明函數(shù),會(huì)編譯不通過(guò)。

解決辦法

將react-native版本改成0.38.0或以上。


BUG描述

A problem occurred configuring root project 'one'.

Could not resolve all dependencies for configuration ':classpath'.

Could not download builder.jar (com.android.tools.build:builder:2.2.3)

Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/builder/2.2.3/builder-2.2.3.jar'.

Could not GET 'https://jcenter.bintray.com/com/android/tools/build/builder/2.2.3/builder-2.2.3.jar'.

Read timed out

解決辦法

網(wǎng)絡(luò)異常導(dǎo)致,保證網(wǎng)絡(luò)的穩(wěn)定下再次嘗試基本可以解決


BUG描述

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

解決辦法

SDK路徑無(wú)效!

1.可以使用Android Studio打開該項(xiàng)目的android項(xiàng)目,Android Studio就會(huì)自動(dòng)校正

2.也可以打開local.properties文件,手動(dòng)修改SDK路徑


BUG描述

運(yùn)行項(xiàng)目出現(xiàn)unable to load script from assets 'index.android.bundle',

unable to load script from assets 'index.android.bundle'錯(cuò)誤

如圖所示:

解決辦法

1.進(jìn)入項(xiàng)目的根目錄

2.在終端輸入

mkdir android/app/src/main/assets

3.繼續(xù)在終端輸入

React-native bundle --platform Android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res


BUG描述

Error: Validation error
    at /Users/lee/RNWorkStation/Demo/node_modules/react-native-update/local-cli/lib/api.js:8:27
    at Generator.next (<anonymous>)
    at step (/Users/lee/RNWorkStation/Demo/node_modules/react-native-update/local-cli/lib/api.js:82:191)
    at /Users/lee/RNWorkStation/Demo/node_modules/react-native-update/local-cli/lib/api.js:82:361
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

解決辦法

已經(jīng)上傳過(guò)同樣版本號(hào)的ipa,重新上傳需要修改版本號(hào)

[問(wèn)題參考](https://github.com/reactnativecn/react-native-pushy/issues/143

  • android平臺(tái):修改根目錄/android/app/build.gradle下的versionCodeversionName.例如:

    versionCode 2
    versionName "1.0.02"
    
  • ios平臺(tái):(待添加)

BUG描述

* What went wrong:
Could not resolve all files for configuration ':react-native-code-push:_internal_aapt2_binary'.
> Could not resolve com.android.tools.build:aapt2:3.2.1-4818971.
  Required by:
      project :react-native-code-push
   > Could not resolve com.android.tools.build:aapt2:3.2.1-4818971.
      > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom'.
         > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.1-4818971/aapt2-3.2.1-4818971.pom'.
            > Connect to 127.0.0.1:1087 [/127.0.0.1] failed: Connection refused (Connection refused)

解決辦法

systemProp.https.proxyPort=``1080
systemProp.http.proxyHost=``127.0``.``0.1
systemProp.https.proxyHost=``127.0``.``0.1
systemProp.http.proxyPort=``1080

gradle.properties文件中使用了代理,刪除gradle.properties中的代理以及計(jì)算機(jī)用戶目錄下的.gradle文件夾中的代理即可。

BUG描述

undefined is not a function (evaluating '_react.default.createContext(null)')
<unknown>
    Context.js:10:53
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:20
<unknown>
    Provider.js:16:23
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:20
<unknown>
    index.js:7:47
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:20
<unknown>
    index.js:5
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:126:36
_require
    require.js:110:20
<unknown>
    index.android.js:1:8
loadModuleImplementation
    require.js:174:12
guardedLoadModule
    require.js:119:45
_require
    require.js:110:20
global code

解決辦法

這是由于react版本引起的,猜測(cè)可能是react版本與引入react-redux兼容性問(wèn)題所導(dǎo)致。

引起B(yǎng)UG的環(huán)境:

"react": "16.0.0-alpha.12",
"react-native": "0.48.1",
"react-navigation": "1.0.0-beta.13",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"

消除BUG的環(huán)境:(降低了react-redux版本)

"react": "16.0.0-alpha.12",
"react-native": "0.48.1",
"react-navigation": "1.0.0-beta.13",
"react-redux": "5.0.5",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0"

BUG描述

執(zhí)行react-native run-android后提示:

leedeMac-mini:RepairUnion lee$ react-native run-android
Scanning 688 folders for symlinks in /Users/lee/RNWorkStation/RepairUnion/node_modules (8ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

解決辦法

1.配置全局環(huán)境變量

$ vim ~/.bash_profile
$ export ANDROID_HOME="/Users/[your name]/Library/Android/sdk/android-sdk_r24.2" # 以實(shí)際位置為準(zhǔn)
$ source ~/.bash_profile # 立即生效

2.配置權(quán)限

如果配置環(huán)境后不可以運(yùn)行 可能是無(wú)權(quán)限運(yùn)行,在項(xiàng)目下運(yùn)行 就是為android文件夾下的gradlew命令添加權(quán)限, **在根目錄下執(zhí)行 chmod 755 android/gradlew,本次就是用這個(gè)方法解決 **

3.項(xiàng)目中android目錄下新建文件local.properties,并添加如下內(nèi)容:

sdk.dir=/Users/[your name]/Library/Android/sdk/android-sdk_r24.2

BUG描述

Expected a component class, got [object Object].

解決辦法

類名必須大寫。檢查引入的類是否有小寫存在。

image.png
image.png

BUG描述

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to install all

解決辦法

安裝錯(cuò)誤: Gradle 的編譯版本過(guò)高, 不兼容部分5.0+手機(jī), 需要降低版本為 1.3
有兩種解決辦法,一是降低gradle的build版本,改為1.2.3;另一種是升級(jí)你的React-Native至最新版本。
這里提供第一種方法:
1.打開 React Native 的項(xiàng)目, 修改最外層工程的 build.gradle 配置, 降低 gradle 的 build 為1.2.3版本
2.修改Gradle的Wrapper版本,需要修改android/griddle/wrapper/grade-wrapper.properties文件:

classpath 'com.android.tools.build:gradle:1.2.3' // 修改1.2.3
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip

BUG描述

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:\Program Files\Java\jdk1.8.0_77\bin\java.exe” finished with non-zero exit value 2 

解決辦法

1.Builde→rebuild project
2、如果第一步不行的話,那就是因?yàn)閖ar包重復(fù)了,檢查我們的libs文件夾中是否有不使用的jar包,或者
重復(fù)的jar包,delete掉他們。


BUG描述

node_modules/react-native/Libraries/WebSocket/libfishhook.a'

解決辦法

  • 1.在Xcode中找到RCTWebSocket.xcodeproj文件

    image.png
  • 2.找到Build Phases的Link Binary With Libraries, 點(diǎn)擊減號(hào)去掉libfishhook.a引用

    image.png
  • 3.再加回去: 點(diǎn)加號(hào)把libfishhook.a引用

    image.png
  • 4.clean build 以及重新編譯,OK解決!


BUG描述

":CFBundleIdentifier", Does Not Exist

解決辦法

  • 1.打開Project settings
image.png
  • 2.點(diǎn)擊Advanced按鈕
image.png
  • 3.選擇Custom,然后點(diǎn)擊下拉選擇Relative to Workspace

  • 4.修改Build/Products 為 build/Build/Products

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

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

  • 在學(xué)習(xí)React Native的過(guò)程中,相信對(duì)于一個(gè)App開發(fā)工程師,沒(méi)有充分的學(xué)習(xí)過(guò)前端開發(fā)技術(shù)的同學(xué)來(lái)說(shuō),順利...
    簡(jiǎn)而精閱讀 1,959評(píng)論 1 0
  • 原文地址:https://medium.com/airbnb-engineering/react-native-a...
    莫寂嵐閱讀 3,589評(píng)論 0 9
  • 我很焦慮,我總是感覺(jué)自己無(wú)能為力,感覺(jué)自己還是不夠努力,知識(shí)點(diǎn)背了一遍又一遍,卻還是記不住,一道道的做題,卻總是不...
    黎沫yan閱讀 115評(píng)論 0 1
  • 她的纖細(xì)指尖滑過(guò)一排書脊 沒(méi)有停留在上面 她緩緩走出書攤 沒(méi)入人群 我的目光斷了線索 看書的人被窗欞隔著一份風(fēng)雅 ...
    樸二雄閱讀 680評(píng)論 0 3
  • 不記得從什么時(shí)候起 我偷偷地種下一顆種子 在黑夜深處,在無(wú)人經(jīng)過(guò)的角落 我只能在這里,在這個(gè)地方耕作! 白天鳥兒很...
    鄉(xiāng)村詩(shī)人閱讀 273評(píng)論 1 7

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