为什么我的应用程序在首次运行时启动的速度慢得令人难以置信(10s +),在android 5.0上只显示白屏?

埃德蒙德·塔玛斯(Edmond Tamas)

我有一个新创建的应用程序(内置于android studio 2.0中),有一些活动。

当我在Android 4.3(note 2)设备上对其进行测试时,它在全新安装后可以很好且快速地启动,然后在具有android 5.0的三星银河S4上运行相同的应用程序时,挂起大约10-15秒,而仅显示白屏。

为确保我已经从android studio中拔出电源并注释掉MainActivity中的几乎所有方法,但这没有什么区别,在安装后或清除应用程序的缓存后,我会得到相同的10秒启动时间。

我真的很担心这个问题,这可能真的会伤害我的应用程序的用户体验。

有什么事吗

Logcat:

05-10 02:07:14.266 26036-26631/com.cerculdivelor I/GMPM: App measurement is starting up
05-10 02:07:14.747 26036-26036/com.cerculdivelor W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:14.867 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:14.907 26036-26036/com.cerculdivelor I/LOGTAG: Table has been created!
05-10 02:07:14.967 26036-26650/com.cerculdivelor D/OpenGLRenderer: Render dirty regions requested: true
05-10 02:07:15.007 26036-26649/com.cerculdivelor I/Timeline: Timeline: Activity_launch_request id:com.cerculdivelor time:111211793
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isShipBuild true
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Thread-62285-755755249: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
05-10 02:07:15.127 26036-26645/com.cerculdivelor I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
05-10 02:07:15.137 26036-26645/com.cerculdivelor I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
                                                               OpenGL ES Shader Compiler Version: E031.25.03.06
                                                               Build Date: 01/24/15 Sat
                                                               Local Branch: AF11_RB1_AU15
                                                               Remote Branch: 
                                                               Local Patches: 
                                                               Reconstruct Branch: 
05-10 02:07:15.147 26036-26650/com.cerculdivelor I/OpenGLRenderer: Initialized EGL, version 1.4
05-10 02:07:15.197 26036-26650/com.cerculdivelor D/OpenGLRenderer: Enabling debug mode 0
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.417 26036-26036/com.cerculdivelor I/LOGTAG: Returned0rows
05-10 02:07:15.988 26036-26051/com.cerculdivelor I/art: Background sticky concurrent mark sweep GC freed 40699(4MB) AllocSpace objects, 12(383KB) LOS objects, 0% free, 49MB/49MB, paused 1.007ms total 161.285ms
05-10 02:07:16.168 26036-26043/com.cerculdivelor W/art: Suspending all threads took: 5.249ms
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call secproduct feature valuefalse
05-10 02:07:16.228 26036-26036/com.cerculdivelor D/Activity: performCreate Call debug elastic valuetrue
05-10 02:07:16.238 26036-26036/com.cerculdivelor I/Choreographer: Skipped 44 frames!  The application may be doing too much work on its main thread.
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: [email protected] time:111214133
05-10 02:07:17.349 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: [email protected] time:111214133
05-10 02:07:17.369 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{10b472f8 [email protected] {com.cerculdivelor/com.cerculdivelor.MainActivity}} show : false
05-10 02:07:30.622 26036-26036/com.cerculdivelor I/Timeline: Timeline: Activity_idle id: [email protected] time:111227400
05-10 02:08:36.286 26036-26036/com.cerculdivelor V/ActivityThread: updateVisibility : ActivityRecord{1e1f9137 [email protected] {com.cerculdivelor/com.cerculdivelor.SplashActivity}} show : true

主要活动:

public class MainActivity extends AppCompatActivity implements View.OnClickListener, HttpConActivity.downloadListener {

    private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
    private BroadcastReceiver mRegistrationBroadcastReceiver;
    private boolean isReceiverRegistered;
    CallbackManager callbackManager;
    private AccessTokenTracker accessTokenTracker;
    private List<ProductsGetterSetter> products;
    private SQLiteDataSource datasource;
    private TextView toolbarTitle;
    private String fbId;
    private String name;
    private TextView notifBubbleText;
    private TextView inboxBubbleText;
    private ArrayList<NotificationSetter> notifications;
    private SharedPreferences preferences;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
        toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
        setSupportActionBar(toolbar);

        /**** 
TextView title = (TextView) findViewById(R.id.toolbar_title);
        Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Baron.otf");
        title.setTypeface(tf);

        TextView feedTv = (TextView) findViewById(R.id.feedTv);
        feedTv.setOnClickListener(this);
        TextView shopTv = (TextView) findViewById(R.id.shopTv);
        shopTv.setOnClickListener(this);
        TextView sellTv = (TextView) findViewById(R.id.sellTv);
        sellTv.setOnClickListener(this);
        TextView likesTv = (TextView) findViewById(R.id.likesTv);
        likesTv.setOnClickListener(this);
        TextView myShopTv = (TextView) findViewById(R.id.myShopTv);
        myShopTv.setOnClickListener(this);


        // Send crash report if exists
        if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
            Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
        }

        ****/

    }


    @Override
    protected void onResume() {
        super.onResume();

       /****
        datasource = new SQLiteDataSource(this);
        datasource.open();

        preferences = getSharedPreferences("user", MODE_PRIVATE);
        if (preferences.getString("fbId", "").equals("")) {
            promtForLogin();
        } else {
            initialiseApp();
        }

        this.invalidateOptionsMenu();
        ****/
    }

摇篮

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.cerculdivelor"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.android.support:cardview-v7:23.0.+'
    compile 'com.android.support:recyclerview-v7:23.0.+'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile "com.google.android.gms:play-services-gcm:8.3.0"

}
贾里德·鲁姆勒(Jared Rummler)

这是因为即时运行需要一段时间才能加载。黑屏/白屏将在生产版本中消失。

我不确定为什么即时运行需要这么长时间才能加载。如果您查看应用程序的内部缓存目录,则会看到很多dex文件。几天前,这里发布了一篇有关Instant Run工作原理的文章:https//medium.com/google-developers/instant-run-how-does-it-work-294a1633367f#.ntl30mbe2

您可以禁用“即时运行”,或者只是要注意您的生产版本将没有空白屏幕。

相似的问题:Android Studio 2.0-App首次运行时暂停/白屏

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档