I have a multi-project (2 modules) of which building takes about 1/2 min each time. When I press Run in Android Studio, I have to wait every time to rebuild the app, which is extremely slow. It's took 6/8 min each time.
Is it possible to automate building process in Android Studio? Or do you have any advice on how to make this process faster?
here is my build.gradle file (app module):
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
Actually I have Android Studio 2.0 preview 9 with this studio64.exe.vmoptions
-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
And The Gradle work is OFFLINE
Dynamic Dependencies slow down your build since they keep searching for the latest builds every time. To improve the performance we need to fix the version in place. Use only those dependencies that you need. For example google maps dependency, instead of importing compile 'com.
When I joined my current company a few months ago, building our Android app took an average of 14 minutes on my machine.
Android Studio needs at least 8 GB RAM to run better. Change your Hard Disk to SSD. Loading/Compiling/Designing/Writing time will be reduced even in 4GB RAM. Use Power Save mode from File Menu that will reduce lots of background work.
You should use Android Studio 1.5.1 which is much faster than prior version of Android Studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With