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 ?

Amir
  • 16,067
  • 10
  • 80
  • 119
  • 1
    I think `instant-run` in enabled.. which always taken more time at first run... – Bharatesh Apr 14 '16 at 13:43
  • 2
    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. – Amir Apr 14 '16 at 13:58
  • what does it means? (what if i'm setting checked and what if i'm setting unchecked?) – Ninja Coding Aug 09 '16 at 17:49
  • @Kuriel see my answer http://stackoverflow.com/a/37512413/1462770 – Amir Aug 09 '16 at 17:52

5 Answers5

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

Community
  • 1
  • 1
Maxim G
  • 1,479
  • 1
  • 15
  • 23
  • 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: http://developer.android.com/intl/es/tools/building/building-studio.html#instant-run – antonio Apr 28 '16 at 09:27
  • @antonio, are you serious? How many percent of devices can install your application? – CoolMind Jul 13 '16 at 13:26
  • @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 solved – antonio Jul 13 '16 at 13:37
  • @antonio, I have just checked it, nothing had changed after upgrading to 21 version. Still very slow first run. – CoolMind Jul 13 '16 at 13:56
  • 1
    @CoolMind 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](https://developer.android.com/studio/run/index.html#ir-limitations). – Maxim G Jul 13 '16 at 14:10
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.

Amir
  • 16,067
  • 10
  • 80
  • 119
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

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

  • 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. – CoolMind Jul 13 '16 at 13:41
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.

dukeking
  • 3,643
  • 2
  • 9
  • 5