我有一个多项目(2个模块),每次建筑大约需要1/2分钟 . 当我在Android Studio中按Run时,我必须每次都等待重建应用程序,这非常慢 . 每次花费6/8分钟 .
是否可以在Android Studio中自动化构建过程?或者您对如何更快地完成此过程有任何建议?
这是我的build.gradle文件(app模块):
allprojects {
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile fileTree(dir: 'libs', include: '*.jar')
compile('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.nirhart:parallaxscroll:1.0'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.android.support:support-v4:22.0.1'
compile 'com.android.support:appcompat-v7:22.0.1'
compile 'com.android.support:design:22.2.+'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.github.fenjuly:ArrowDownloadButton:9e15b85e8a'
compile 'ch.acra:acra:4.5.0'
compile 'com.yalantis:contextmenu:1.0.5'
compile project(':locationlib')
}
configurations {
compile.exclude group: 'javax.inject', module: 'javax.inject'
}
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
compileOptions {
encoding "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
dexOptions {
javaMaxHeapSize "8g"
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
targetSdkVersion 22
renderscriptTargetApi 19
renderscriptSupportModeEnabled false
multiDexEnabled true
}
productFlavors {
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex'
}
}
}
My notebook spects are I3 8GB RAM and Windows 10 64bits
实际上我有这个studio64.exe.vmoptions的Android Studio 2.0预览9
-Xms256m
-Xmx1280m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-XX:-OmitStackTraceInFastThrow
-Djna.nosys=true
-Djna.boot.library.path=
-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Didea.paths.selector=AndroidStudioPreview2.0
-Didea.platform.prefix=AndroidStudio
并且 The Gradle work is OFFLINE
2 回答
您应该使用 Android Studio 1.5.1 ,这比以前版本的Android Studio快得多 .
47deg maven存储库真的很慢 . 您最好的选择是找到一种方法来解决其他地方提供的依赖关系,并从您的存储库主体中删除此行:
构建时间将明显缩短 .