繼上篇遷移整理了 Android Studio使用的那些事(一)安裝、重裝、啓動問題 這篇將整理遇到常見的錯誤和問題
常見錯誤
1、AS中的項目路徑,不能包含中文
Error:(1, 0) Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by using the command line flag -Dcom.android.build.gradle.overridePathCheck=true, or adding the line com.android.build.gradle.overridePathCheck=true' to gradle.properties file in the project directory.
<a href="openFile:H:\項目整理\聯想_XXX\MPAndroidChart-master\MPChartExample\build.gradle">Open File</a>
2、AS需指定ANDROID_HOME
Error:(28, 0) SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
<a href="openFile:H:\LenovoP\MPAndroidChart-master\MPChartExample\build.gradle">Open File</a>
注意:我在AS 2.1.2的安裝中,並不需要指定ANDROID_HOME
3、Open Android SDK Manager
Error:Cause: failed to find target with hash string 'Google Inc.:Google APIs:22' in: D:\yyh_installSoft\androidTools\Android_Studio\sdk
<a href="openAndroidSdkManager">Open Android SDK Manager</a>
解決方式:
AS菜單欄 Tools --->Android --->SDK Manager --->然後彈出default settings窗口,
選擇Appearance & Behavior/ System settings /Android SDK --->SDK Platforms選項卡 --->
點擊下方的藍色文本Launch Standalone SDK Manager --->彈出Android SDK Manager --->
選擇Android5.0.1/Google APIs Install
4、Java.lang.UnsupportedClassVersionError: com/Android/dx/command/Main : Unsupported major.minor ver
把compile sdk version與Build tool version改成對應的,然後重啓AS