AS(Android studio)常见问题
1.JUnit 找不到問題
JUnit是一個Java語言的單元測試框架,在as gradle編譯的時候需要引入單元測試的東西,因此需要引用這個jar包。
以前一直用Eclipse開發Android,最近準備用用Android Studio好不容易配置完了,新建了個工程竟然是有錯誤
Error:A?problem?occurred?configuring?project?':app'.
>?Could?not?download?junit.jar?(junit:junit:4.12)
???>?Could?not?get?resource?'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar'.
??????>?Could?not?GET?'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar'.
?????????>?peer?not?authenticated
翻墻下載了junit-4.12.jar,才創建成功。然后我找到了junit-4.12.jar的文件路徑,大家再遇到這個問題,也不想麻煩去翻墻,可以直接下載一個junit-4.12.jar,放到自己的Android Studio的相應目錄中,然后重啟android studio就可以了。
1.找到自己android studio 的安裝目錄,下面是我自己的android studio安裝目錄:D:\Android\Android Studio\
2.把junit-4.12.jar放到D:\Android\Android Studio\gradle\gradle-2.4\lib\plugins\目錄下就ok了。
或者將中間代碼注釋掉
dependencies {compile fileTree(dir: 'libs', include: ['*.jar'])//testCompile 'junit:junit:4.12'compile 'com.android.support:appcompat-v7:23.3.0' } 2.解決Android studio Instance Run 錯誤(Tools | Android | Enable ADB integration' to be enabled) 研究了一下Instant Run是Android Studio 2.0新加入的功能,可以快速部署代碼的更改到模擬器/手機上,不用像之前一樣等半天。
可以在設置里把Instant Run打開或者關掉,設置地方如下圖:
這個開關要是打開,那么在?Tools - Android - Enable ADB Integration 也需要打開
3.解決 Android studio 導入jar 問題 在 app/build.gradle文件中如果引入 compile fileTree(dir: 'libs', include: ['*.jar']) 那么jar文件是直接可以放置在libs文件下。在 AS 中引入jar有幾種方式:1.引入Android studio安裝目錄中的lib文件夾中的庫,常見的有annotation,junit等。2.就是gradle下載的,如:compile 'com.google.android.gms:play-services:9.8.0' 3.sdk中下載的jar 4.工程目錄下libs文件夾中的jar. 4.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. 其實很好解決啦,就是你的工程項目路徑或者項目名稱包含了中文,修改相關的名稱就好了! 5. 運行Android studio工程
Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException:?
org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java''?
finished with non-zero exit value 2
這個問題可能是jar包的重復導入也有可能是方法數溢出。 加上 ?multiDexEnabled?true?
[java]?view plaincopy總結
以上是生活随笔為你收集整理的AS(Android studio)常见问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 个人住房公积金账户怎么查询 公积金账户怎
- 下一篇: Object转Map和Map转Objec