First launch take long time (ClassLoader referenced unknown path)
Asked Answered
S

5

19

After updating my Android studio to 2.0 and gradle to 2.0.0 and SDK-Platform to 23.0.3 When I want to launch application it take too much time (about 2-3 second) and following warning appears in Android Monitor :

W/System: ClassLoader referenced unknown path: /data/app/net.hadifar.test-1/lib/arm
W/System: ClassLoader referenced unknown path: /data/app/net.hadifar.test-1/lib/arm
 W/art: Suspending all threads took: 5.439ms
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
W/art: Suspending all threads took: 6.808ms

But second time I launch application it's run as usual. Can any body knows what's the issue ?

Soissons answered 14/4, 2016 at 13:0 Comment(4)
I think instant-run in enabled.. which always taken more time at first run...Riesling
Yes ! Thanks. I disable instant run and issue fixed. for disable instant run go to Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.Soissons
what does it means? (what if i'm setting checked and what if i'm setting unchecked?)Pragmaticism
@Kuriel see my answer https://mcmap.net/q/103268/-first-launch-take-long-time-classloader-referenced-unknown-pathSoissons
M
10

In version 2.0 a new feature was added instant-run.

To enable this feature tool adds a lots of meta information, so the first build and upload takes more time.

Be aware about

Here we can write (or vote) issues (report to make the better tool).

Mandi answered 14/4, 2016 at 14:5 Comment(5)
I have also experienced this issue and in my case the first run time improves significaltly using Instant Run if I set the minSdkVersion to 21 as stated here: developer.android.com/intl/es/tools/building/…Momently
@antonio, are you serious? How many percent of devices can install your application?Flunk
@CoolMind, maybe I have misexplained it, I mean setting it to 21 only during the development process and as a workaround until the issue is solvedMomently
@antonio, I have just checked it, nothing had changed after upgrading to 21 version. Still very slow first run.Flunk
@Flunk There are too many variables, only profiling in your concrete case can show improvements, if any, even with some projects it doesn't work at all. Check limitations.Mandi
S
3

There is a strange behaviour in newly released A.S 2.0 (or 2.1) and screen turns to black (or Activity pause) for seconds. As doc explained first build may take longer in A.S 2.0 But this issue happen in Runtime.

A quick fix based on @Skadoosh comment's would be disable instant Run:

Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run

More info:

When you deploy a clean build, Android Studio instruments your app to allow Instant Run to push code and resource updates. Although updating the running app happens much more quickly, the first build may take longer to complete. You can improve the build process by configuring a few DexOptions settings:

android {
  ...
  dexOptions {
    maxProcessCount 4 // this is the default value
    javaMaxHeapSize "2g"
  }
}

Also for warning Before Android 4.1. it says :

Instant Run is supported only when you deploy the debug build variant, use Android Plugin for Gradle version 2.0.0 or higher, and set minSdkVersion to 15 or higher in your app's module-level build.gradle file. For the best performance, set minSdkVersion to 21 or higher.

Seeing this video from Googler may help you understand a bit about Instant Run.

Soissons answered 29/5, 2016 at 16:42 Comment(0)
F
1

I met the same problem, when update Andoid gradle plugin 2.4 to 2.10 & I solved it's by using below instruction

Go to Android studio File->Settings → Build, Execution, Deployment → Instant Run and uncheck all CheckBox

Forrest answered 14/8, 2016 at 4:31 Comment(0)
K
0

I met the same problem, use low version gradle can be solved.

build.gradle: classpath 'com.android.tools.build:gradle:1.3.0'

gradle-wrapper.properties: distributionUrl=https://services.gradle.org/distributions/gradle-2.4-all.zip

Knowing answered 8/6, 2016 at 8:38 Comment(1)
Bad advice. A compilation time is back long, also an instant run must be disabled in settings. Also a size of application is again big.Flunk
G
0

no need to disable instant run ,but follow my step ,use gradle plugin v2.3.2 and use gradle v3.5 can solve it , enjoy , anyway I solve the problem on my project.

Gid answered 8/6, 2017 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.