Kashan Danish
Kashan Danish

Reputation: 155

App is taking really long time to load first activity

My app is taaking a really long time ~20 seconds on Nexus 6 before calling onCreate method of launcher activity of my app. These are logs before my first activity becomes visible.

04-12 19:30:46.564 12518-12518/com.dealsmash.dealsmashapp W/System: ClassLoader referenced unknown path: /data/app/com.dealsmash.dealsmashapp-1/lib/arm
04-12 19:31:05.862 12518-12518/com.dealsmash.dealsmashapp W/System: ClassLoader referenced unknown path: /data/app/com.dealsmash.dealsmashapp-1/lib/arm
04-12 19:31:05.909 12518-12518/com.dealsmash.dealsmashapp I/MultiDex: VM with version 2.1.0 has multidex support
04-12 19:31:05.909 12518-12518/com.dealsmash.dealsmashapp I/MultiDex: install
04-12 19:31:05.910 12518-12518/com.dealsmash.dealsmashapp I/MultiDex: VM has multidex support, MultiDex support library is disabled.
04-12 19:31:06.045 12518-13453/com.dealsmash.dealsmashapp I/GMPM: App measurement is starting up
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162190): avc: denied { getattr } for path="/proc/sysrq-trigger" dev="proc" ino=4026544381 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc_sysrq:s0 tclass=file permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162191): avc: denied { getattr } for path="/proc/1" dev="proc" ino=8630890 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:init:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162192): avc: denied { getattr } for path="/proc/2" dev="proc" ino=8630891 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162193): avc: denied { getattr } for path="/proc/3" dev="proc" ino=8630892 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162194): avc: denied { getattr } for path="/proc/7" dev="proc" ino=8630893 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162195): avc: denied { getattr } for path="/proc/8" dev="proc" ino=8630894 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162196): avc: denied { getattr } for path="/proc/9" dev="proc" ino=8630895 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162197): avc: denied { getattr } for path="/proc/10" dev="proc" ino=8630896 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162198): avc: denied { getattr } for path="/proc/11" dev="proc" ino=8630897 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162199): avc: denied { getattr } for path="/proc/12" dev="proc" ino=8630898 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162200): avc: denied { getattr } for path="/proc/15" dev="proc" ino=8630899 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.174 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162201): avc: denied { getattr } for path="/proc/16" dev="proc" ino=8630900 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162202): avc: denied { getattr } for path="/proc/19" dev="proc" ino=8630901 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162203): avc: denied { getattr } for path="/proc/20" dev="proc" ino=8630902 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162204): avc: denied { getattr } for path="/proc/23" dev="proc" ino=8630903 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162205): avc: denied { getattr } for path="/proc/24" dev="proc" ino=8630904 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162206): avc: denied { getattr } for path="/proc/26" dev="proc" ino=8630905 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162207): avc: denied { getattr } for path="/proc/28" dev="proc" ino=8630906 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162208): avc: denied { getattr } for path="/proc/29" dev="proc" ino=8630907 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:06.184 12518-12518/com.dealsmash.dealsmashapp W/sh.dealsmashapp: type=1400 audit(0.0:162209): avc: denied { getattr } for path="/proc/30" dev="proc" ino=8630908 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:r:kernel:s0 tclass=dir permissive=0
04-12 19:31:08.740 12518-12518/com.dealsmash.dealsmashapp I/CrashlyticsCore: Initializing Crashlytics 2.3.8.97
04-12 19:31:08.772 12518-12518/com.dealsmash.dealsmashapp D/LoginManager: initInstance
04-12 19:31:08.817 12518-12518/com.dealsmash.dealsmashapp D/ContentManager: initInstance
04-12 19:31:08.825 12518-12518/com.dealsmash.dealsmashapp D/BeaconManager: initInstance
04-12 19:31:08.907 12518-13554/com.dealsmash.dealsmashapp D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-12 19:31:09.086 12518-12518/com.dealsmash.dealsmashapp D/LoginActivity: onCreate
04-12 19:31:09.585 12518-12524/com.dealsmash.dealsmashapp W/art: Suspending all threads took: 11.012ms
04-12 19:31:09.727 12518-12518/com.dealsmash.dealsmashapp D/ContentManager: fetching all interests
04-12 19:31:09.904 12518-13554/com.dealsmash.dealsmashapp I/Adreno: QUALCOMM build                   : 52af4d2, I8366cd0437
                                                                Build Date                       : 10/20/15
                                                                OpenGL ES Shader Compiler Version: XE031.05.13.02
                                                                Local Branch                     : M14
                                                                Remote Branch                    : 
                                                                Remote Branch                    : 
                                                                Reconstruct Branch               : 
04-12 19:31:09.909 12518-13554/com.dealsmash.dealsmashapp I/OpenGLRenderer: Initialized EGL, version 1.4

Please note that app started at 46th second but the onCreate method of my first activity LoginActivity is called on 9th second of the next minute.
First, I suspected that it is due to some newly added dependency but the issue is still their after i removed them. Here is my Module's build.gradle file just in case.

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

android {
    signingConfigs {
        releaseConfig {
            keyAlias 'ds_a'
            keyPassword 'dealsmash'
            storeFile file('C:/Android/keystore/dealsmash_android.keystore')
            storePassword 'dealsmash'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "com.dealsmash.dealsmashapp"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 21
        versionName "2.1"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.releaseConfig
        }
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    packagingOptions {
        exclude 'main/AndroidManifest.xml'
    }
}

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
//    maven { url 'https://github.com/taplytics/Taplytics-Android-SDK/raw/master/AndroidStudio/' }
}

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.shamanland:xdroid-toaster:0.2.4'
    compile 'com.kontaktio.sdk:kontakt-sdk:2.1.2'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile "com.android.support:design:${android_support_lib_version}"
    compile "com.android.support:cardview-v7:${android_support_lib_version}"
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.mcxiaoke.volley:library:1.0.17'
    compile 'com.google.zxing:core:3.2.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true; }
    //    compile 'com.github.javiersantos:MaterialStyledDialogs:1.3'
    compile 'com.bugfender.sdk:android:0.1.8-SNAPSHOT'

    //  compile 'com.github.nitinverma:ViewPagerIndicator:2.4.2.0:release@aar'

    // Taplytics
    //    compile("com.taplytics.sdk:taplytics:+@aar")
    // Dependencies for Taplytics
    //    compile("com.squareup.okhttp:okhttp-urlconnection:+")
    //    compile("com.squareup.okhttp:okhttp:+")
    //Excluding org.json due to compiler warnings
    //    compile("com.github.nkzawa:socket.io-client:+") {
    //        exclude group: "org.json"
    //    }
    //    compile("com.github.nkzawa:engine.io-client:+") {
    //        exclude group: "org.json"
    //    }
}  

Here is my Application class.

public class DealSmashApplication extends Application
{
    private Tracker mTracker;
    public PollManager pollManager;

    @Override
    public void onCreate()
    {
        super.onCreate();
        Bugfender.init(this, "Eu6Djgg8dakcYwjBQKIlmYL9A3Xxo7AK", BuildConfig.DEBUG);
//        Taplytics.startTaplytics(this, "ce36925556402e12404b38586de9cb5fb7d4e5ec");
        Fabric.with(this, new Crashlytics());
        LoginManager.initInstance(this);
        pollManager = PollManager.initInstance(this);
        ContentManager.initInstance(this);
        BeaconManager.initInstance(this);
    }

    @Override
    protected void attachBaseContext(Context base)
    {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    @Override
    public void onTerminate()
    {
        AlertsAndLogs.log("Application", "onTerminate");
        super.onTerminate();
        pollManager.stopPolling();
    }

    /**
     * Gets the default {@link Tracker} for this {@link Application}.
     *
     * @return tracker
     */
    synchronized public Tracker getDefaultTracker()
    {
        if (mTracker == null)
        {
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
            // To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
            mTracker = analytics.newTracker(R.xml.global_tracker);
        }
        return mTracker;
    }
}

Upvotes: 0

Views: 727

Answers (1)

Mike Holtkamp
Mike Holtkamp

Reputation: 94

To find out which method takes long you can try to use this http://developer.android.com/tools/debugging/debugging-tracing.html

Do you really need all that methods in the application on create? I supspect one of them is take a while

Upvotes: 1

Related Questions