3

I updated the code of my Android app to include:

  • ActiveAndroid
  • TargetsdkVersion 22 (with some Material Design elements now in lay-out)
  • MinSdkVersion 9 (this was also with my earlier version)
  • Google Analytics v4, part of Google Play Services

My earlier version was created in Eclipse, with this update I'm working with Android Studio. Importing didn't work, so I recreated the project in Android studio. And for the main part it seems to work fine.

But when the app starts the first time, it's slow. It takes about 1.5 seconds staring at a white screen before the main screen shows. After that the app works fine and quick.

Restarting it, when keeping the app in memory it start immediately. If you take the app out of memory, it needs another 1.5 seconds (/2 sec) to get started.

I tested it on my Nexus 7 (2013) and my FairPhone (Android 4.2.2). I don't understand where the problem lies, perhaps you can help me out. A solution would be great, but even pointing to what the cause is would be of great help.

Relevant code of App.java (extends Application):

@Override
public void onCreate() {
    super.onCreate();
    mContext = this;

    Log.v("App","onCreate App - before GoogleAnalytics.getInstance(this)");

    analytics = GoogleAnalytics.getInstance(this);
    analytics.setLocalDispatchPeriod(1800); // every 30 minutes
    tracker = analytics.newTracker("REMOVED CODE FOR STACKOVERLOW");
    tracker.enableExceptionReporting(true);

    // Since I do this 'by hand', enabling automatic will amount to double counting.
    tracker.enableAutoActivityTracking(false);

    Log.v("App", "onCreate App - after GA");


    // Because it is initialized here, we don't need to put it as the application in Manifest
    // This means we can use Google Analytics code referring to 'getApplication'.
    ActiveAndroid.initialize(this);

    Log.v("App", "onCreate App - after AA");

Gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }

    defaultConfig {
        applicationId "com.juliushuijnk.tools.ideagrowr"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 38
        versionName "1.38"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'uk.co.ribot:easyadapter:1.4.0@aar'
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}

Log on my Fairphone (android 4.2.2)

    07-19 14:18:24.517  18930-18930/com.juliushuijnk.tools.ideagrowr V/App﹕ onCreate App - before GoogleAnalytics.getInstance(this)
    07-19 14:18:24.527  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
    07-19 14:18:24.527  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ VFY: unable to resolve virtual method 245: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
    07-19 14:18:24.528  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ DexOpt: access denied from Lcom/google/android/gms/common/GooglePlayServicesUtil; to field Landroid/app/Notification;.extras
    07-19 14:18:24.528  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ VFY: unable to resolve instance field 18
    07-19 14:18:24.528  18930-18930/com.juliushuijnk.tools.ideagrowr E/dalvikvm﹕ Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
    07-19 14:18:24.528  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ VFY: unable to resolve check-cast 25 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/common/GooglePlayServicesUtil;
    07-19 14:18:24.530  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh
    07-19 14:18:24.530  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ VFY: unable to resolve virtual method 553: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
    07-19 14:18:24.534  18930-18930/com.juliushuijnk.tools.ideagrowr I/GAv4﹕ Google Analytics 7.5.71 is starting up. To enable debug logging on a device run:
        adb shell setprop log.tag.GAv4 DEBUG
        adb logcat -s GAv4
    07-19 14:18:24.538  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.MainActivity
    07-19 14:18:24.547  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.AllIdeasActivity
    07-19 14:18:24.548  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.AllNotesActivity
    07-19 14:18:24.548  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.CreateIdeaActivity
    07-19 14:18:24.548  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.CreateNoteActivity
    07-19 14:18:24.549  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.DeleteIdeaActivity
    07-19 14:18:24.549  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.OverviewActivity
    07-19 14:18:24.549  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.InfoActivity
    07-19 14:18:24.550  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.EditQsetActivity
    07-19 14:18:24.550  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.LikeActivity
    07-19 14:18:24.550  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.MigrateDatabaseActivity
    07-19 14:18:24.550  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.SettingsActivity
    07-19 14:18:24.551  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.UpdateCoreActivity
    07-19 14:18:24.553  18930-18930/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ Bool xml configuration name not recognized: ga_reportUncaughtExceptions
    07-19 14:18:24.573  18930-18930/com.juliushuijnk.tools.ideagrowr V/App﹕ onCreate App - after GA
    07-19 14:18:24.636  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/app/ActivityCompat21$SharedElementCallbackImpl; (54)
    07-19 14:18:24.636  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/app/ActivityCompat21$SharedElementCallbackImpl;' failed
    07-19 14:18:24.666  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/app/FragmentTransitionCompat21$1; (1697)
    07-19 14:18:24.666  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/app/FragmentTransitionCompat21$1;' failed
    07-19 14:18:24.667  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/app/FragmentTransitionCompat21$3; (1697)
    07-19 14:18:24.667  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/app/FragmentTransitionCompat21$3;' failed
    07-19 14:18:24.687  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/TransportMediatorJellybeanMR2$1; interface 1775 'Landroid/view/ViewTreeObserver$OnWindowAttachListener;'
    07-19 14:18:24.687  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/TransportMediatorJellybeanMR2$1;' failed
    07-19 14:18:24.688  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/TransportMediatorJellybeanMR2$2; interface 1776 'Landroid/view/ViewTreeObserver$OnWindowFocusChangeListener;'
    07-19 14:18:24.688  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/TransportMediatorJellybeanMR2$2;' failed
    07-19 14:18:24.689  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/TransportMediatorJellybeanMR2; interface 197 'Landroid/media/RemoteControlClient$OnGetPlaybackPositionListener;'
    07-19 14:18:24.689  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/TransportMediatorJellybeanMR2;' failed
    07-19 14:18:24.690  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/media/VolumeProviderCompatApi21$1; (202)
    07-19 14:18:24.690  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/VolumeProviderCompatApi21$1;' failed
    07-19 14:18:24.705  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/media/session/MediaControllerCompatApi21$CallbackProxy; (203)
    07-19 14:18:24.705  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/session/MediaControllerCompatApi21$CallbackProxy;' failed
    07-19 14:18:24.708  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/session/MediaSessionCompatApi18$OnPlaybackPositionUpdateListener; interface 199 'Landroid/media/RemoteControlClient$OnPlaybackPositionUpdateListener;'
    07-19 14:18:24.708  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/session/MediaSessionCompatApi18$OnPlaybackPositionUpdateListener;' failed
    07-19 14:18:24.709  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/media/session/MediaSessionCompatApi19$OnMetadataUpdateListener; interface 198 'Landroid/media/RemoteControlClient$OnMetadataUpdateListener;'
    07-19 14:18:24.709  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/session/MediaSessionCompatApi19$OnMetadataUpdateListener;' failed
    07-19 14:18:24.816  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/media/session/MediaSessionCompatApi21$CallbackProxy; (207)
    07-19 14:18:24.816  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/media/session/MediaSessionCompatApi21$CallbackProxy;' failed
    07-19 14:18:24.823  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/print/PrintHelperKitkat$1; (264)
    07-19 14:18:24.823  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/print/PrintHelperKitkat$1;' failed
    07-19 14:18:24.824  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Landroid/support/v4/print/PrintHelperKitkat$2; (264)
    07-19 14:18:24.824  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/print/PrintHelperKitkat$2;' failed
    07-19 14:18:24.847  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/view/ViewCompatLollipop$1; interface 1754 'Landroid/view/View$OnApplyWindowInsetsListener;'
    07-19 14:18:24.847  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/view/ViewCompatLollipop$1;' failed
    07-19 14:18:24.867  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Failed resolving Landroid/support/v4/widget/DrawerLayoutCompatApi21$InsetsListener; interface 1754 'Landroid/view/View$OnApplyWindowInsetsListener;'
    07-19 14:18:24.867  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Landroid/support/v4/widget/DrawerLayoutCompatApi21$InsetsListener;' failed
    07-19 14:18:24.904  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ method Landroid/support/v7/internal/widget/ListViewCompat;.lookForSelectablePosition incorrectly overrides package-private method with same name in Landroid/widget/ListView;
    07-19 14:18:25.319  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Luk/co/ribot/easyadapter/BaseEasyRecyclerAdapter$RecyclerViewHolder; (1642)
    07-19 14:18:25.319  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Luk/co/ribot/easyadapter/BaseEasyRecyclerAdapter$RecyclerViewHolder;' failed
    07-19 14:18:25.320  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Luk/co/ribot/easyadapter/BaseEasyRecyclerAdapter; (1641)
    07-19 14:18:25.320  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Luk/co/ribot/easyadapter/BaseEasyRecyclerAdapter;' failed
    07-19 14:18:25.680  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Luk/co/ribot/easyadapter/BaseEasyRecyclerAdapter; (1641)
    07-19 14:18:25.680  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Luk/co/ribot/easyadapter/BaseEasyRecyclerAdapter;' failed
    07-19 14:18:25.680  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Unable to resolve superclass of Luk/co/ribot/easyadapter/EasyRecyclerAdapter; (7387)
    07-19 14:18:25.680  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ Link of class 'Luk/co/ribot/easyadapter/EasyRecyclerAdapter;' failed
    07-19 14:18:26.240  18930-18930/com.juliushuijnk.tools.ideagrowr V/App﹕ onCreate App - after AA
    07-19 14:18:26.471  18930-18930/com.juliushuijnk.tools.ideagrowr V/App﹕ end of onCreate App
    07-19 14:18:26.559  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
    07-19 14:18:26.559  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ VFY: unable to resolve virtual method 630: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
    07-19 14:18:26.560  18930-18930/com.juliushuijnk.tools.ideagrowr I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
    07-19 14:18:26.560  18930-18930/com.juliushuijnk.tools.ideagrowr W/dalvikvm﹕ VFY: unable to resolve virtual method 652: Landroid/content/res/TypedArray;.getType (I)I
    07-19 14:18:26.822  18930-18930/com.juliushuijnk.tools.ideagrowr V/MainActivity﹕ called onCreate MainActivity

So something is going wrong with Google Analytics, but that's not the main thing slowing the app startup down. The main problem seems to be the lines like this one:

Unable to resolve superclass of Landroid/support/v4/app/ActivityCompat21$SharedElementCallbackImpl; (54)

I don't know how to tackle those, since other StackOverflow posts with these type of log messages assume that it's about a .jar library and that it's on Eclipse.

Like here: Android - Unable to resolve superclass Both do not apply to my problem (as I understand it).

On the Nexus 7 (2013) the startup of the app is also slow, but the logfile gives a different reading:

07-19 14:48:05.631  26840-26840/com.juliushuijnk.tools.ideagrowr V/App﹕ onCreate App - before GoogleAnalytics.getInstance(this)
07-19 14:48:05.640  26840-26840/com.juliushuijnk.tools.ideagrowr I/GAv4﹕ Google Analytics 7.5.71 is starting up. To enable debug logging on a device run:
    adb shell setprop log.tag.GAv4 DEBUG
    adb logcat -s GAv4
07-19 14:48:05.645  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.MainActivity
07-19 14:48:05.656  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.AllIdeasActivity
07-19 14:48:05.656  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.AllNotesActivity
07-19 14:48:05.656  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.CreateIdeaActivity
07-19 14:48:05.656  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.CreateNoteActivity
07-19 14:48:05.657  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.DeleteIdeaActivity
07-19 14:48:05.657  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.OverviewActivity
07-19 14:48:05.657  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.InfoActivity
07-19 14:48:05.658  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.EditQsetActivity
07-19 14:48:05.658  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.LikeActivity
07-19 14:48:05.658  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.MigrateDatabaseActivity
07-19 14:48:05.658  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.SettingsActivity
07-19 14:48:05.659  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.UpdateCoreActivity
07-19 14:48:05.659  26840-26840/com.juliushuijnk.tools.ideagrowr W/GAv4﹕ Bool xml configuration name not recognized: ga_reportUncaughtExceptions
07-19 14:48:05.689  26840-26840/com.juliushuijnk.tools.ideagrowr V/App﹕ onCreate App - after GA
07-19 14:48:06.082  26840-26840/com.juliushuijnk.tools.ideagrowr W/art﹕ Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
07-19 14:48:07.580  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.BaseEasyRecyclerAdapter$RecyclerViewHolder>
07-19 14:48:07.580  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.BaseEasyRecyclerAdapter$RecyclerViewHolder>
07-19 14:48:07.581  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.BaseEasyRecyclerAdapter>
07-19 14:48:07.581  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.BaseEasyRecyclerAdapter>
07-19 14:48:07.583  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.BaseEasyRecyclerAdapter>
07-19 14:48:07.583  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.EasyRecyclerAdapter>
07-19 14:48:07.583  26840-26840/com.juliushuijnk.tools.ideagrowr I/art﹕ Rejecting re-init on previously-failed class java.lang.Class<uk.co.ribot.easyadapter.EasyRecyclerAdapter>
07-19 14:48:07.592  26840-26840/com.juliushuijnk.tools.ideagrowr V/App﹕ onCreate App - after AA
07-19 14:48:07.606  26840-26840/com.juliushuijnk.tools.ideagrowr V/App﹕ end of onCreate App
07-19 14:48:07.690  26840-26840/com.juliushuijnk.tools.ideagrowr V/MainActivity﹕ called onCreate MainActivity

While most of it I don't fully understand, I think this is the strangest line:

Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView

If it helps, the start of the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.juliushuijnk.tools.ideagrowr"
    android:installLocation="auto" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.myTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Further context: I'm not a software developer by profession, this is a pet project. It would be great to also learn on how to approach a problem like this.

Community
  • 1
  • 1
Julius
  • 159
  • 1
  • 1
  • 13
  • In the LogCat... Try to get rid of all (as many as possible) lines that include `W/dalvikvm` and especially `E/dalvikvm`... like: `String xml configuration name not recognized: com.juliushuijnk.tools.ideagrowr.MainActivity ` – Danielson Jul 19 '15 at 14:21
  • Do you mean, to clean up this questions, or do you mean that I should focus my code on trying to get rid of those? – Julius Jul 19 '15 at 16:31
  • Measure how much time it takes to initialize each component in Application.onCreate(). Then you'll know which one is to blame. – BladeCoder Jul 19 '15 at 19:24
  • The latter one... warnings you get in your log are indicative of something suboptimal, such as extra conversions the compiler has to make to start your app... read the warnings carefully and try to spot the links to your code... – Danielson Jul 19 '15 at 19:31
  • Looking at the time on the left of the loglines, I can infer that the "ActiveAndroid.initialize(this);" is where a lot of time is lost. It might just be that ActiveAndroid is a slow library, but that would not explain all the errors. – Julius Jul 19 '15 at 21:04

3 Answers3

2

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 :).

Community
  • 1
  • 1
Julius
  • 159
  • 1
  • 1
  • 13
  • This is not fixing my issue. app start too much slow. Takes almost 10 to 15 seconds.. – Bilal Haider Apr 21 '16 at 11:11
  • @BilalHaider how did you fix ? – Zeeshan Apr 25 '16 at 21:52
  • For me its taking 20 seconds to start up first time. I am using AA_MODLES in manifest file. I don't know that its due to ActiveAndroid or somethings else problem – Zeeshan Apr 25 '16 at 23:29
  • @ShanXeeshi couldn't fix it still. Tried configuration thingy and also both manifest and configuration one. but no use. – Bilal Haider Apr 26 '16 at 06:18
  • This issue is only on real devices not on Genymotion Emulators. On real devices it takes 20 seconds but on Genymotion it run fast. May be this is due to different architecture – Zeeshan Apr 26 '16 at 19:56
1

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

Community
  • 1
  • 1
Danielson
  • 2,605
  • 2
  • 28
  • 51
  • The way I understand how Gradle works, and I could be mistaken, the dependencies make sure that these libraries are included. I can see on 'external libraries' folder that both support-v4-22.2.1 and appcompat-v7-22.2.1 are there with a classes.jar files inside. – Julius Jul 19 '15 at 20:41
  • Maybe I'm confused in that I thought that appcompat was the support library for version 7, since the app was working in essence. Now I start to think that appcompat and support are not the same thing.. I'll try to find a support v7 library. – Julius Jul 19 '15 at 20:47
  • I think they are the same (out of memory, just different kinds of names). I don't use gradle, yet, but I thought there was a difference between loading the jars into the workspace and compiling to the APK. at least I'm eclipse I had to do something like that. That also would make sense, why you don't have compile issues, only when you try to run – Danielson Jul 19 '15 at 20:52
  • "Start with Errors: Could not find class" The link you gave references Google Sign In, my app doesn't use that. Also, you can see in the gradle file and manifest in the question if there is something wrong with my API version. But I don't think so. "Warnings: String xml configuration name.." As I understand it, I have exact the same XML content as is needed. My filename is called global_tracker.xml (in the xml folder) and has values for ga_dryRun (true) and ga_logLevel (verbose). My guess is you are right about the v4 and v7 libraries, but I don't know how to change things for the better. – Julius Jul 19 '15 at 20:57
  • I don't have experience with gradle, so bear with me... in this link https://developer.android.com/tools/building/configuring-gradle.html#buildFileBasics you see that the support library is compiled and saved I'm the libs dir. You only compile to 'compile files('libs/activeandroid-3.0.jar')'... add like in the link to your gradle file – Danielson Jul 19 '15 at 21:04
  • Appreciate the effort. I actually had that other line in the gradle dependencies (compile fileTree(dir: 'libs', include: ['*.jar'])). But then I tried to add a .jar file separate, but deleted it later when that didn't help, but then forgot to change things back in the gradle file. Either way, I updated the question to include the gradle depencies I had in the beginning. Still, that didn't fix the problem. – Julius Jul 19 '15 at 21:33
0

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 .

impathuri
  • 574
  • 6
  • 21