日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

AS(Android studio)常见问题

發(fā)布時間:2023/12/19 Android 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AS(Android studio)常见问题 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.JUnit 找不到問題

JUnit是一個Java語言的單元測試框架,在as gradle編譯的時候需要引入單元測試的東西,因此需要引用這個jar包。

以前一直用Eclipse開發(fā)Android,最近準(zhǔn)備用用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,才創(chuàng)建成功。然后我找到了junit-4.12.jar的文件路徑,大家再遇到這個問題,也不想麻煩去翻墻,可以直接下載一個junit-4.12.jar,放到自己的Android Studio的相應(yīng)目錄中,然后重啟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新加入的功能,可以快速部署代碼的更改到模擬器/手機(jī)上,不用像之前一樣等半天。
可以在設(shè)置里把Instant Run打開或者關(guān)掉,設(shè)置地方如下圖:

這個開關(guān)要是打開,那么在?Tools - Android - Enable ADB Integration 也需要打開



3.解決 Android studio 導(dǎo)入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. 其實(shí)很好解決啦,就是你的工程項(xiàng)目路徑或者項(xiàng)目名稱包含了中文,修改相關(guān)的名稱就好了! 5. 運(yùn)行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包的重復(fù)導(dǎo)入也有可能是方法數(shù)溢出。 加上 ?multiDexEnabled?true?

[java]?view plaincopy
  • defaultConfig?{??
  • ????????applicationId?""??
  • ????????minSdkVersion?14??
  • ????????targetSdkVersion?21??
  • ????????versionCode?19??
  • ????????versionName?"1.2.7"??
  • ????????//?dex突破65535的限制??
  • ????????multiDexEnabled?true??
  • ????} ?

  • 總結(jié)

    以上是生活随笔為你收集整理的AS(Android studio)常见问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。