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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。