4

I'm using Android Studio 2.1.2, debug device android 4.4.2 API19, build env:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
}

I have tried reopen the project, invalidate caches, disable instantRun, but I still keep getting those error as below:

06-24 01:15:08.302 27320-27320/org.linphone E/InstantRun: Could not find slices in APK; aborting.
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.322 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.332 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.332 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.332 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.342 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.342 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.352 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method org.linphone.LinphoneLauncherActivity.access$super
06-24 01:15:08.352 27320-27320/org.linphone E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method org.linphone.LinphoneLauncherActivity.access$super

Anyone could help me?

John Jang
  • 2,567
  • 24
  • 28
  • Thank you guys, I had disabled instantRun again to solve this problem, I'd appreciate your kindly help. – John Jang Oct 26 '16 at 16:01

2 Answers2

3

While reading through many similar problems, I found out it might be fixed by enabling Multidex, credits to this answer from Bharath Kumar. He also posted some useful links I reccomend to read. At least it worked for me (to be precise: I'm left with only 1 of those errors now, while it were hundreds before)!

In short: enabling multidex can be done by simply adding multiDexEnabled true in your gradle defaultConfig and adding this dependency compile 'com.android.support:multidex:1.0.1'. Finally, install Multidex by adding this piece of code to your Application class:

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

Of course another option is to prevent the 64K method limit, so you don't need MultiDex anymore. You can do this by decreasing the number of (unused) dependencies in your Gradle file, or use more specific dependencies (a nice example for google play-services is provided by wittyurchin in this answer).

However, if you DO need Multidex, then you might encounter some problems, like the ones I found:

1) Instant run is disabled while building to target API devices (you'll see the error message popping up when running your app from Android Studio).

2) If you're using Robolectric for unittesting, you'll probably won't be able to run the tests anymore. You can fix this problem by extending the MultiDex.install(this); code from earlier. Instead of explaining everything myself, it'll be easier to check the issue, and answer of sschuberth over here.

...

ps. it seems I don't necessarily need compile 'com.android.support:multidex:1.0.1' to have MultiDex working, however, I've seen many reccomendations that say it IS required. If anyone got more advice on this, be my guest!

Community
  • 1
  • 1
P Kuijpers
  • 1,593
  • 15
  • 27
1

I was facing the same issue with almost same config in question (and Android API19-4.4 debug device).

Outlining steps that fixed errors in my case. (Based on suggestion here, minification and proguard rule):

  1. Updated the gradle version (simply set default options at File->settings->Build,Execution, Deployment->Build Tools->Gradle ::(RightPanel) Project-level settings ->Use default gradle wrapper)

    if you have to use the particular version of gradle, you can try skipping this step

  2. Clean project + Rebuild Project (may be if you want to restart the Android Studio too)
  3. Remove dependency from module(app) build.gradle -- make sure to copy the dependency values to revert in next step
  4. Sync/Gradle build, to fetch errors (just a safe-guarding step, funny but sometime for some reason Android studio is on its own even if configs are changed)
  5. add the dependencies back as noted down in step 3 in the same module (app)build.gradle `

    well if you are wondering why steps 3,4,5-> someone pointed out here that gradle update after dependency inclusion might cause issues resulting into these errors`

  6. Final and most important: Shrink the code and use progaurd rules explained officially here

    As I am novice to Android Studio, felt that my project, though a very small app, might be inflated by multiple experimental library inclusions + so many comments(and inactive code inside) causing 64K?(nopeIguess),illegitimate references(possibly!); just a intuitive guess after reading answer by @PKuijpers(thanks!). And honestly I didn't wanted to include multiDex because after also reading official document, I was sure that my app is not PokemonGo or NFS or big enough to qualify for multidex.

Solved for me, phew! And I see a bit of better memory utilization in Android resource monitor too as a byproduct!

Community
  • 1
  • 1
JC_
  • 45
  • 3
  • 7