为什么在构建期间两次调用app:assembleDebug
?
我的应用程序包含两个模块,应用程序模块app
和库模块commons
。当我在Android Studio中单击“运行”以在设备上部署应用程序时,我看到了这种情况:
Gradle build using tasks: [:app:assembleDebug, :commons:assembleDebug]
。蓝色进度条将缓慢填充。 Gradle控制台中无输出。 Compilation completed succesfully in 3m
。好极了!此时,我希望该应用程序已安装。 executing post-compile tasks
和Executing tasks: [:app:assembleDebug]
的内容。 :app:assembleDebug
再次被调用,并花费了其他3分钟,而我们仍停留在100%。这次,Gradle控制台记录了输出。 为什么是这样?尽管同样适用,但不使用Instant Run。
gradle.properties
org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.daemon=true
项目级别build.grade
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
ext {
compileSdkVersion = 25
buildToolsVersion = "25.0.2"
minSdkVersion = 15
targetSdkVersion = 25
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用模块build.grade
apply plugin: 'com.android.application'
android {
dexOptions {
preDexLibraries true
javaMaxHeapSize "2g"
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.package.id"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
signingConfig signingConfigs.release_config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
debug {
minifyEnabled false
shrinkResources false
}
}
productFlavors {}
}
dependencies {
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.google.android.gms:play-services-maps:9.2.1'
compile 'com.google.android.gms:play-services-appinvite:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.google.android.gms:play-services-places:9.2.1'
compile ('com.facebook.android:facebook-android-sdk:4.16.1') {
exclude module: 'bolts-tasks'
}
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:preference-v14:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.parse.bolts:bolts-tasks:1.4.0'
compile 'com.parse:parse-android:1.14.0'
compile ('com.parse:parseui-widget-android:0.0.1') {
exclude module: 'parse-android'
}
compile project(':commons')
}
apply plugin: 'com.google.gms.google-services’
最佳答案