我的Android Studio项目过去构建得更快,但现在需要很长时间来构建。知道是什么导致了延误吗?
我试过https://stackoverflow.com/a/27171878/391401但没有效果。我没有运行任何可能中断构建的反病毒程序。我的应用程序也没有那么大(大约5MB),它曾经在几秒钟内构建,但不确定发生了什么变化。
10:03:51 Gradle build finished in 4 min 0 sec
10:04:03 Session 'app': running
10:10:11 Gradle build finished in 3 min 29 sec
10:10:12 Session 'app': running
10:20:24 Gradle build finished in 3 min 42 sec
10:28:18 Gradle build finished in 3 min 40 sec
10:28:19 Session 'app': running
10:31:14 Gradle build finished in 2 min 56 sec
10:31:14 Session 'app': running
10:38:37 Gradle build finished in 3 min 30 sec
10:42:17 Gradle build finished in 3 min 40 sec
10:45:18 Gradle build finished in 3 min 1 sec
10:48:49 Gradle build finished in 3 min 30 sec
10:53:05 Gradle build finished in 3 min 22 sec
10:57:10 Gradle build finished in 3 min 19 sec
10:57:11 Session 'app': running
我很长一段时间都面临着同样的问题,但我通过调整gradle中的设置解决了它。
步骤1:在Module app中添加BuildScript中的依赖项
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
}
}
步骤2:添加dexOption并给出以下heapSize
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
第三步:添加产品口味
productFlavors {
dev {
minSdkVersion 23
applicationId = "com.Reading.home"
}
prod {
minSdkVersion 15
applicationId = "com.Reading.home" // you don't need it, but can be useful
}
}
这将减少您的构建时间。
我很长一段时间都面临着同样的问题,但我通过调整gradle中的设置解决了它。
步骤1:在Module app中添加BuildScript中的依赖项
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha9'
}
}
步骤2:添加dexOption并给出以下heapSize
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
第三步:添加产品口味
productFlavors {
dev {
minSdkVersion 23
applicationId = "com.Reading.home"
}
prod {
minSdkVersion 15
applicationId = "com.Reading.home" // you don't need it, but can be useful
}
}
这将减少您的构建时间。