mac 底下,配置 React-Native 遇到的一些問題

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 即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章