0

I searched a lot for the issue but the only answer i could find is refactoring the code from onCreate to enable quick startup. But the problem looks different in my case. I and my team member are working on same code synchronized through GITHUB,builds made by him opens in a flash and builds made by me takes more than 10 seconds to start up. Another issue, his builds are of 90MB or so and my builds are just 30MB. App is anyway fully functional but the difference seen in startup time and build size is too huge.

I am not sure about his system configuration, but I use JAVA8 for compilation, SDK 24 and Gradle 2.10 for building the app.

Here is my gradle file

buildscript {
    repositories {
        jcenter()
        /*flatDir {
            dirs 'libs'
        }*/
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        //compile(name:'library-release', ext:'aar')
        classpath 'io.realm:realm-gradle-plugin:0.88.0'
        classpath 'io.fabric.tools:gradle:1.21.2'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 24
    buildToolsVersion '24.0.0'

    useLibrary 'org.apache.http.legacy'
    dexOptions {
        maxProcessCount 4 // this is the default value
        javaMaxHeapSize "4g"
        dexInProcess = false
    }

    defaultConfig {
        applicationId "com.sample.app"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 31
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        /*debug {
            minifyEnabled true
            useProguard false
        }*/
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            java.srcDirs = ['src/main/java']
        }
        robolectric {
            java.srcDir file('src/test/java/')
        }
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.twitter.sdk.android:twitter:1.9.0@aar') {
        transitive = true;
    }
    testCompile 'org.robolectric:shadows-play-services:3.0'
    testCompile 'org.robolectric:shadows-support-v4:3.0'
    testCompile 'org.powermock:powermock-module-junit4:1.6.2'
    testCompile 'org.powermock:powermock-module-junit4-rule:1.6.2'
    testCompile 'org.powermock:powermock-api-mockito:1.6.2'
    testCompile 'org.powermock:powermock-classloading-xstream:1.6.2'
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
    testCompile 'org.assertj:assertj-core:1.7.0'
    androidTestCompile 'com.android.support:support-annotations:24.0.0'
    androidTestCompile 'com.android.support.test:runner:0.4'
    androidTestCompile 'com.android.support.test:rules:0.4'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
        transitive = true;
    }

    //    compile(group: 'com.google.gms', name: 'google-services', version: '2.0.0-beta4', ext: 'pom')
    //apply plugin: 'com.android.application'
    compile 'com.google.android.gms:play-services:9.2.1'
    compile 'com.google.android.gms:play-services-location:9.2.1'
    compile 'com.google.android.gms:play-services-gcm:9.2.1'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.coinbase.android:coinbase-android-sdk:1.0.1'
    compile 'org.roboguice:roboguice:2.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.14'
    compile 'com.sprylab.android.texturevideoview:texturevideoview:1.1.1'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.google.android.gms:play-services-ads:9.2.1'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
}
//put 'com.google.gms.google-services' plugin at the bottom
apply plugin: 'com.google.gms.google-services'
Mohammed Atif
  • 4,383
  • 7
  • 28
  • 57
  • 1
    The size of the APK shouldn't be that different! It might be useful to know which IDE/version he's using and also if both of you are using the same resources, etc. The 30 vs 90MB size seems weird. – Sufian Jul 21 '16 at 07:52
  • Yes I know @Sufian, we have matched the resources, they are nearly same. And we both are using Android Studio 2.1.2 – Mohammed Atif Jul 21 '16 at 07:56
  • See this thread as well http://stackoverflow.com/questions/22064591/apk-size-is-bigger-than-expected-android-studio – Sufian Jul 21 '16 at 08:00

1 Answers1

7

if it happens only in debug mode so you can try to disable the instant run

Preferences > Build,Execution,deployment>instant run

and there uncheck "Enable Instant Run..."

Yoni
  • 1,346
  • 3
  • 16
  • 38
  • I don't rule out instant run causing weirdness like this. It has been such a mess. – Sufian Jul 21 '16 at 08:00
  • It worked, app runs faster and size changed from 30MB to 120MB. Works well, but it will be more helpful if you can provide any link or explanation for this behavior. – Mohammed Atif Jul 21 '16 at 08:09
  • @MohammedAtif this might answer your query - http://stackoverflow.com/questions/34925708/android-studio-difference-in-size-between-build-apk-vs-run-apk – Sufian Jul 21 '16 at 08:20
  • @Sufian, kind of useful. But more structured details, specially from any Googles official doc will help more. May be I can use some customisations with instant run to prevent such bugs. – Mohammed Atif Jul 21 '16 at 11:17
  • @MohammedAtif Google does terrible documentation. Personally I believe (which I hope many share this with me) that Instant Run is still broken and shouldn't be considered even beta-ready. – Sufian Jul 21 '16 at 11:42