2016-04-12 5 views
0

Мое приложение таит очень долгое время ~ 20 секунд на Nexus 6 перед вызовом onCreate метода запуска моего приложения. Это журналы, прежде чем моя первая активность станет видимой.Приложение занимает очень долгое время, чтобы загрузить первую активность.

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 

Пожалуйста, обратите внимание, что приложение начался на 46-е второго, но onCreate метода моей первой активности LoginActivity называется на 9-е секунды следующей минуты.
Во-первых, я подозревал, что это связано с какой-то недавно добавленной зависимостью, но проблема по-прежнему сохраняется после того, как я их удалил. Вот мой файл модуля build.gradle на всякий случай.

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:[email protected]') { 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:[email protected]' 

    // Taplytics 
    // compile("com.taplytics.sdk:taplytics:[email protected]") 
    // 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" 
    // } 
} 

Это мой класс Application.

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; 
    } 
} 
+1

Вы выполняете много инициализации в onCreate(), измеряете, насколько каждый метод initInstance() принимает и делает выводы оттуда. – Egor

+0

Использование Instant Run на Android Studio 2.0? У этого есть такие проблемы. – laalto

+0

@laalto да я это делаю. Но проблема не возникает при установке из студии Android. Когда я очищаю данные приложения и запускаю его, он снова занимает много времени для загрузки. –

ответ

0

Чтобы узнать, какой метод занимает много времени, вы можете попробовать использовать этот http://developer.android.com/tools/debugging/debugging-tracing.html

вам действительно нужно все, что методы применения на создание ли? Я полагаю, что один из них занимает некоторое время.

+0

Проблема ДО выше onCreate(). –

Смежные вопросы