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
2.SyntaxError /user/Destop/xxxx.js:Unexpected token(80:8)
報錯資訊
報錯程式碼:
原因:多了一個 > 號,這種報錯一般需要自己檢查一下程式碼,一般可能是多了一個 : } >
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
錯誤如下圖:
修改方法:
在終端進入到當前檔案目錄下,輸入:
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
這個檔案,如果沒有就建立一個
下圖示例:
7. A problem occurred configuring project ‘:app’. > failed to find Build Tools revision 23.0.1
當我在終端react-native run-android
時報了上述錯誤,修改方法為:進入到android/app/build.gradle
將buildToolsVersion
改成所提示版本
下圖為正確示例:
8.no bundle URL present
請檢查是否打開了兩個專案/模擬器,先全部退出,在再終端輸入:react-native run-ios
報錯如圖:
9.Super expression must either be null or a function
這種一般是程式碼寫錯了,需要仔細檢查自己的程式碼,錯誤圖例如下