我的Android应用偶尔会(大约每4-5次尝试)快速构建(约7秒),但更多情况是卡在此任务上:app:transformDexWithInstantRunSlicesApkForDebug。这在大多数构建中都会发生,并且该构建无限期挂起。我通常的反应是取消构建,然后重新开始,但是它变得非常令人沮丧,我希望它每次都能快速构建。真的没有什么应该浪费时间的(我只有4个活动和5个模型类),所以我对发生的事情感到很困惑。
以下是最高级的Gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是应用程序Gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.yokogawa.jahziel.qcctourguide"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.google.code.gson:gson:2.8.0'
androidTestImplementation 'junit:junit:4.12'
implementation group: "com.twilio.sdk", name: "twilio", version: "7.21.5"
implementation 'com.android.support:multidex:1.0.3'
}