react-native錯誤集錦

1.react-native run-android報錯

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.確認模擬器是否啟動
2.模擬器狀態是否正常
3.真機是否連接好
下圖為模擬器正常狀態

Simona_Test1

下圖就是錯誤狀態
Simona_Test2

2.SyntaxError /user/Destop/xxxx.js:Unexpected token(80:8)

報錯信息

Simona_Test3

報錯代碼:
Simona_Test4

原因:多了一個 > 號,這種報錯一般需要自己檢查一下代碼,一般可能是多了一個 : } >

3.CFBundle identifier xxnot found

網絡不好的情況下,rncash包沒有下載好,建議多試幾次

4.application has not been registered

1.:MainActivity.java檢查的項目名稱與index.android.js文件里的項目名稱是否相同
2:是否同時開啟了兩個項目

5.:unable to load script from assets 'index.android bundle' ,make sure your bundle is packaged correctly or youu're runing a packager server

錯誤如下圖:


Simona_Test5

修改方法:

Simona_Test6

在終端進入到當前文件目錄下,輸入:
1.mkdir android/app/src/main/assets
(如果提示:mkdir: android/app/src/main/assets: File exists可直接執行第二步)
2.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

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

在當前文件夾下查看是否有local.properties這個文件,如果沒有就創建一個
下圖示例:

Simona_Test7

7. A problem occurred configuring project ':app'. > failed to find Build Tools revision 23.0.1

當我在終端react-native run-android時報了上述錯誤,修改方法為:進入到android/app/build.gradlebuildToolsVersion改成所提示版本
下圖為正確示例:

Simona_Test8

8.no bundle URL present

請檢查是否打開了兩個項目/模擬器,先全部退出,在再終端輸入:react-native run-ios
報錯如圖:

Simona_Test9

9.Super expression must either be null or a function

這種一般是代碼寫錯了,需要仔細檢查自己的代碼,錯誤圖例如下


Simona_Test10.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容