您好,登錄后才能下訂單哦!
1 在android studio 下新建android project ,編譯沒有問題。
而導入已經存在的項目時,一直報錯:Connection refused。
這個時候就要考慮是配置哪里跟自己android studio 本地的不一樣,果然:
問題出在 build.gradle:
classpath 'com.android.tools.build:gradle:com.android.tools.build:gradle:2.2.3'
這個要跟自己local一致才可以。
2
執行 android studio可以編譯項目但是在命令行 ./gradlew 則報錯:
Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.ConnectException: Connection timed out
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
需要配置project gradle.properties,添加
systemProp.http.proxyHost=proxy id systemProp.http.nonProxyHosts=192.168.*, systemProp.http.proxyPort=3128 systemProp.https.proxyHost=proxy id systemProp.https.nonProxyHosts=192.168.*, systemProp.https.proxyPort=3128
因為download 用的是https, 而直接用studio 編譯好像用的是http
3 andorid studio 升級后,直接安裝apk使用 multiple slice apks 的方式,即
adb install-multiple -r code/app/build/outputs/apk/app-debug.apk code/app/build/intermediates/split-apk/debug/slices/slice_3.apk code/app/build/intermediates/split-apk/debug/slices/slice_9.apk code/app/build/intermediates/split-apk/debug/slices/slice_2.apk code/app/build/intermediates/split-apk/debug/slices/slice_0.apk code/app/build/intermediates/split-apk/debug/slices/slice_1.apk code/app/build/intermediates/split-apk/debug/slices/slice_4.apk code/app/build/intermediates/split-apk/debug/slices/slice_8.apk code/app/build/intermediates/split-apk/debug/slices/slice_5.apk code/app/build/intermediates/split-apk/debug/slices/slice_6.apk code/app/build/intermediates/split-apk/debug/slices/slice_7.apk Split APKs installed
但是編譯出來的
app-debug.apk
直接安裝就會報錯,所以想使用adb install方式安裝的話需要
disable instant run.
具體 File->settings->searchbox(type instant run)-> select disable option.
4 apk安裝不上,報錯: INSTALL_FAILED_TEST_ONLY: installPackageLI.
原因: android studio ,gradle plugin, gradle tool是beta版本,版本配置不對導致的
in app/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip
app/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
}
都需要修改,再編譯即可。
5 在命令行編譯app ,
./gradlew clean assemble:
得到錯誤:
FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'FacebookTestPlan'. > Could not resolve all files for configuration ':classpath'. > 3.0.0-alpha4. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.jar Required by: project :
原因:看起來是下載組件不成功。
在project/build.gradle中
a)buildscript 和allprojects都需要添加
maven {
url 'https://maven.google.com'
// Alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
兩個都需要根據數據下載相應插件,
b)allprojects 并不包括buildscript. buildscript只是給build的組件用的。
The buildscript block is where you configure the repositories and dependencies for Gradle itself--meaning, you should not include dependencies
for your modules here.
The allprojects block is where you configure the repositories and
* dependencies used by all modules in your project, such as third-party plugins
* or libraries. Dependencies that are not required by all the modules in the
* project should be configured in module-level build.gradle files.
c) 寫在app/build.gradle里面和寫在allprojects是一樣的。
related URL :https://developer.android.com/studio/build/index.html
6
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。