mac 底下,配置 React-Native 遇到的一些問題
阿新 • • 發佈:2018-12-20
1.React Native - java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties
解決方法:
通過 sudo react-native run-android 啟動應用
2.
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable
環境沒有配置好
解決方法
(1)在終端中輸入 touch .bash_profile (建立.bash_profile檔案)
(2)在終端中輸入 open .bash_profile (開啟 .bash_profile檔案)
(3)在檔案中寫入以下內容
export ANDROID_HOME=/Users/。。。/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
其中的 。。。 是你的使用者名稱,如果你的sdk的路徑不是上面的那個路徑,將ANDROID_HOME路徑改為你的sdk所在的路徑
(4)在終端中輸入 source .bash_profile
(5)在你建立的react_native 專案中的android 底下 建立一個 local.properties 檔案並在檔案中填入以下內容
sdk.dir=/Users/。。。/Library/Android/sdk
重新執行下專案sudo react-native run-android 即可