Android Studio 2.2.3 Instant Run is not an Option - android

I have a new install of Android Studio and I'm starting my first project. I was looking for ways to speed up my deploy/test development cycle when I read that I already should have the Instant Run feature enabled.
I double checked a few settings:
Tools->Android->Enable ADB Integration is checked
File->Settings->Build, Execution, Deployment->Instant Run Enable Instant Run... is checked, along with Restart activity on code changes and Show Toasts in the running app...
My emulator is a Nexus 5, API 24
The Android gradle plugin is defined as: classpath 'com.android.tools.build:gradle:2.2.3'
The project minSdkVersion is 16 and targetSdkVersion is 25
And yet, the Instant Run icons do not appear on my Run configurations and redeploying involves restarting the whole app and takes about a minute. Some possibilities for the error:
I read that DDMS must be disabled for Instant Run to work in another question. I don't know if that's true since I don't see it mentioned in the official documentation, but if I go to the Android Device Monitor I see a DDMS button that cannot be uncheked.
Anticipating a future integration, I enabled this project to allow for C++ code to be integrated. I'm not sure if that plays a part.

Check if minSdkVersion is set to at least 15 and Android plugin for Gradle version at least to 2.0.0.
You can check all the details here
https://developer.android.com/studio/run/index.html#instant-run

I was stopped on two different fronts.
I anticipated using a C++ library in the future for this project and created with C support setup. Use of this type of native library will prevent Instant Run from working.
I wanted to take advantage of the latest Java 8 features, in this case Lambda expressions and Streams. Unfortunately this requires use of the jacktoolchain option which will prevent Instant Run from working. In general, I found these features to be buggy anyways so I opted to return Java 1.7 (insert sad-face here) and gain the benefit of being able to do rapid-deployments.
Because the new features of Java 8 are so powerful, I hope they are made available to developers sooner rather than later. One option that I have not explored is using Zero Turnaround's hot swap system with Java 8 and I will look into that.
For those that are coming here to diagnose Instant Run problems, know that checking the "Show Instant Run status notifications" in Settings -> Build, Execution, Deployment -> Instant Run might provide valuable clues as to problems with this feature (Android Studio 2.2)

Related

no changes to deploy android studio 2.1

Android Studio 2.1 instant run is not updating the app on the device
I observed an issue with AndroidStudio 2.1. When I run the app with small java code changes, it doesn't update app on the device sometimes. Instead it shows a message
No changes to deploy // (Don't show again)
Am I missing any thing here?
As a work around I do clean build every time in order to reflect the changes in app.
Upgrade Android studio version to 3 or more. this bug is resolved.
This was a bug on version 2.0 instant run and issues were reported check these links
https://code.google.com/p/android/issues/detail?id=199884 https://code.google.com/p/android/issues/detail?id=195062
https://code.google.com/p/android/issues/detail?id=206698
https://code.google.com/p/android/issues/detail?id=209413
https://code.google.com/p/android/issues/detail?id=206627
thing to do would be to disable Instant Run entirely by
Settings > Build, Execution, Deployment > Instant Run > Enable
Instant Run
You can file a bug at this link: Google Issue Tracker
please check this answer https://stackoverflow.com/a/35169716/2826147 to turn it off.
Thats a bug in Android Studio, I noticed it in build 2.0 sometimes it failed to update, so what i do is I rebuild the entire project, one more thing, if you have multidex enabled and your device is not running 5 <it will not work, make sure its disabled and rebuild your project.
I have just noticed that whenever i closed my app and then run it worked. See my post here.
https://stackoverflow.com/a/37357665/5923606

Launching application in Debug mode takes a lot of time for the first time

When I install my application in debug mode, and open it for the first time it takes a lot of time (nearly 20-30 seconds). I guess it is due to multi dex enabled. It is happening after updating my Android Studio to version 2.0 and upgrding the android gradle plugin to version '2.0.0'. What is the reason for this behaviour? Is somebody else also facing similar issues?
I have been testing on Moto G3 with android marshmallow.
This happens most of the time because of the prolonged time needed to build the solution. The time needed to build a solution is mostly dependent on the number of libraries you are referencing, and the complexity of your code.
Remember that it is the first time you are building the app, so Android Studio has no record of the solution in its cache, hence it has to build everything from scratch.
Android Studio 2.0 also has the instant run feature, so it takes longer to run the first time, so that you can then debug instantly in the subsequent runs.
Hope this helps :)
I think is because of the new Instant Run feature. The first time takes a lot of time, but after that new changes are visible almost at the same time in your device.
In any case you can disable Instant Run in: File->Settings->Build,Execution,Deployment->Instant Run
There is an issue with multidex and API level 21+, relative to Instant Run. The documentation only mentions it without explanation though.
Instant Run
Settings/Preferences(Mac) → Build, Execution, Deployment → Instant Run and uncheck Instant Run
I was also facing the same problem and finally i fixed this.
note: 1) before generating an apk file unchecked all these option to resolve delay issue from your production build.
2) while you are developing or adding new features then keep it as default setting(instant run) to make development faster.
I hope this will resolve your issue.

Taking a lot of time to build gradle

I'm doing a project in my office in Android Studio, it was working fine there.
But when I open the same project in my personal laptop in Android Studio it's taking a lot of time to build gradle.
Please, does anyone have a solution?
I have also face same problem, actually your personal laptop not compatible to run android studio, in the documentation of android they mentioned that 4 GB RAM is sufficient but my personal experience said that RAM should be 8 GB, its also depend on your operating system in MAC os android studios running smoothly then in Linux its also give good performance but in Windows its creating a problem, i think you need to upgrade your RAM.
Add this line to the file:
org.gradle.daemon=true
From now on Gradle will use a daemon to build, whether you are using Gradle from command line or building in Android Studio. You could also place the gradle.properties file to the root directory of your project and commit it to your SCM system. But you would have to do this, for every project (if you want to use the daemon in every project).
Note: If you don’t build anything with Gradle for some time (currently 3 hours), it will stop the daemon, so that you will experience a long start-up time at the next build.
Note: Performance improvements are one of the great tasks in the Gradle roadmap for 2014 (and reaching into 2015). So I hope, we’ll see the general performance increasing within these years.
Note: This does only affect console builds. Android Studio always uses a Gradle daemon (and depending on your settings some other optimizations).
Found the reason!! If Android Studio has a proxy server setting and can't reach the server then it takes a long time to build, probably its trying to reach the proxy server and waiting for a timeout. When I removed the proxy server setting its working fine.
On Windows File > Settings > Appearance & Behavior > System settings > HTTP Proxy

How to prevent Android Studio 2.0 from doing a complete clean build after uninstalling app from device?

I've been using Android Studio 2.0 Beta 5 with Gradle plugin 2.0.0-beta5. I've had Instant Run feature enabled, which is very useful when I want to do a quick change-and-test. Because it usually needs 50 seconds for my project to do a complete :assembleDebug. With Instant Run, I've been able to get my changed code running on device within about 10 seconds.
However, when I need to remove the app from the test device and have a complete new install. Android Studio always do the following thing when I click the "Run" button for the next time:
:clean, :generateDebugSources, :generateDebugAndroidTestSources, :prepareDebugUnitTestDependencies, :mockableAndroidJar, :assembleDebug
This is very slow. It takes up about 2 minutes for my project.
Is there a way to disable this behaviour? Or why is it not possible?
The instant run, in order to be faster only target the API of the selected device.
Instant run uses different techniques to perform hot, warm, and cold swaps that
are specific to the API level of the target device
Instant run ref.
But if you just need to push the apk again, you can use the gradle task install... (in general install+Flavor+Type i.e.:installProdRelease installPaidDebug) or use ADB to install your APK manually.
Got the same problem.
Fixed by turning off Instant Run
(File -> Settings -> Build, Execution, Deployment -> Instant Run)

How can the "Language Level" option be set to 7.0 and still produce an app that doesn't crash on startup

Since Android Studio v0.32, there's a "Language level" option, which allows some java 7 features to be used. The problem is that I can't get any app to run correctly if the language level is set to 7.0
As a simple test, I made a new project using all the default options, except changing the language level to 7.0. The result, depending on which jdk is used when building is as follows:
with jdk-6:
The app doesn't build. Gradle returns "invalid source release: 1.7"
with jdk-7:
An apk is built. However, when gradle reaches the "dexDebug" step, the gradle console is flooded with "bad class file magic (cafebabe) or version (0033.0000)". None of the app classes are actually put into the apk, which leads to an java.lang.ClassNotFoundException on start.
So am I missing something here, or is there really no way to actually use the features that are advertised here: http://tools.android.com/recent/androidstudio032released
To answer my own question. Be mindful if there are multiple instances of the sdk installed. One of them might not be kept up-to-date, yet be the currently default one in android studio.
This was my case. The offending sdk didn't have version 19 of the build tools.

Categories

Resources