Android app starts slow, but works fine after that slow start

谁说胖子不能爱 提交于 2019-12-06 06:39:59
Danielson

Some items that need to be resolved:

To start, make sure you have imported the v4 and v7 support libraries in your project... For more specific results,,, see below:

Start with Errors: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza <-- check https://stackoverflow.com/a/29276586/928952

Warnings: String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.* <-- check https://stackoverflow.com/a/23418561/928952

Seems slow: DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil <-- check https://stackoverflow.com/a/30052809/928952

Link of class Landroid/support/v4/* <-- Check whether you have imported the support v4 jar

VFY: unable to resolve virtual method 630: Landroid/content/res/TypedArray <-- add support v7 jar

Fixing the above should help speedup startup time

Julius

I figured it out myself. So in the end, it was due to how I implemented the ActiveAndroid library.

It just makes your app start really slow unless you use a configuration that helps the AA to quickly find the models.

I fixed it using this code: How to disable scanning for model in Activeandroid

Code like this (but I had different model names):

 Configuration.Builder configurationBuilder = new Configuration.Builder(this);
    configurationBuilder.addModelClasses(Test.class);
    configurationBuilder.addModelClasses(ShoppingList.class);
    configurationBuilder.addModelClasses(ShoppingListItem.class);
    configurationBuilder.addModelClasses(ArticleInfoModel.class);

    ActiveAndroid.initialize(configurationBuilder.create());

Now it starts nearly instant. I'm still not sure on why I got all these strange logcat entries. All the 'unable to resolve superclass' where probably some sort of indirect artifact of how AA operates without a configuration. These lines are gone now since I added the configuration.

These logcat lines confused my in looking for an answer that had to do with gradle and support libraries, but that was not where the problem originated.

So I should have implemented that configuration right from the start. But the way it was written at AA it felt as a 'nice to have'.

https://github.com/pardom/ActiveAndroid/wiki/Creating-your-database-mode

So I learned that next time when I see something that I think is 'nice to have', I should write my assumption in the comments, so I can quickly see where I might need to change things if I run into problems..

Thank you Danielson for trying to help out :).

Android app starts slow, but works fine after that slow start ,this is because when your app destroyed ondestoryed and that time app cache get clear (if your clearing )else or from settings->apps->yourapp either of these two .when again launching the app that time you will find this issue .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!