使用android studio中遇到的常見問題及解決方法
軟體環境:android studio
記錄一下自己使用android studio過程中遇到的問題和解決方案
Question 1: "cannot resolve symbol R"
解決方法:Build -> Clean Project
Question 2:"NumberFormatException: Invalid revision: 24.0.0-alpha1"
解決方法:
找到Android
sdk安裝目錄
在sdk/extras/android/m2repository/com/android/support/appcompat-v7資料夾中刪除
24.0.0-alpha1 資料夾
並在sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml檔案中刪<version>24.0.0-alpha1</version>
這一行
Question 3:“Cannot reload AVD list: cvc-enumeration-valid: Value '280dpi' is not facet-valid with respect to enumeration '[ldpi, mdpi, tvdpi, hdpi, xhdpi, 400dpi, xxhdpi, 560dpi, xxxhdpi]'. It must be a value from the enumeration.
解決方法:
找到Android sdk安裝目錄
用/sdk/tools/lib/devices.xml
替換 system-images\android-22\android-wear\x86\devices.xml
再替換 system-images\android-22\android-wear\armeabi-v7a\devices.xml
Question 4:"can not resolve maketext() method of Toast"
Toast.makeText(this,"start" ,Toast.LENGTH_LONG).show();
error: java: no suitable method found for makeText(idtech.ESDN.ShapeData,java.lang.CharSequence,int) method android.widget.Toast.makeText(android.content.Context,int,int) is not applicable (actual argument
idtech.ESDN.ShapeData cannot be converted to android.content.Context by method invocation conversion) method android.widget.Toast.makeText(android.content.Context,java.lang.CharSequence,int) is not applicable (actual argument idtech.ESDN.ShapeData cannot be
converted to android.content.Context by method invocation conversion)
解決方法:
改為: Toast.makeText(getApplicationContext()
,"start"
,Toast.LENGTH_LONG).show();