Android studio always rebuilds application - android

I'm working on 2 applications.
One is a bootloader for another which is a main app.
They both have technically the same gradle settings (except package names).
The problem I have is that Android studio always rebuilds entire application for main, but for bootloader app, it just makes changes.
For example:
When I press run on main application, these tasks gets executed (these tasks gets executed even if I don't edit anything):
Executing tasks: [:app:clean, :app:generateMesiDebugDebugSources, :app:generateMesiDebugDebugAndroidTestSources, :app:prepareMesiDebugDebugUnitTestDependencies, :app:mockableAndroidJar, :app:assembleDebugDebug]
While on bootloader app, these tasks gets executed:
Executing tasks: [:app:incrementalDebugSupportDex]
I'm sure I had changed something in my first app in settings but I can't figure out why. Each rebuild on main app takes about 2.5 min while executing small task on bootloader app takes about 2 seconds only, even if I make small changes (view changes, small activity changes).
I'm using Android Studio 2.1 (updated today), but these happens to me about 2-3 days ago.
My gradle version is 2.1.
Hope someone knows how to force Android studio to only compile and build changes in code, not entire app.
Thanks for answers.
Edit: Instant run command is enabled.

I think "Instant Run" setting is not enabled in your first application.
Mac
Go to Android Studio->Preferences->Build, Execution, Deployment->Instant Run->Select the Enable Instant Run check box
Windows Use the settings dialog and do the same procedure mentioned above

Related

Can't Stop Gradle Build

Android Studio 2.2.2. Did a build of my project and after several minutes I noticed that it still hadn't completed and at the bottom of my screen Android Studio said I had a process running. When I clicked on it it said it was the Gradle Build so I clicked to stop it. The display changed to
Stopping - Gradle Build Running
But it never seems to stop. If I restart the build that whole sequence repeats itself so now I have TWO
Stopping - Gradle Build Running
dialogs. But they never actually stop, even after 15+ minutes! If I try to shut down Android Studio it puts up an "Are You Sure?" dialog warning me I have background tasks running.
What's the right way to shut these down cleanly and how do I prevent this from happening?
Run the following in a terminal:
./gradlew --stop
It kills all the gradle processes.
Sometime it happens, Due to many reasons like your system Ram or memory. Just try to close everything and restart it again. It happened with me somedays back. I did the same process and after this, it works fine in my system.
On Mac, it returned to normal only after restarting the machine.
Some of the cached temporary files seem to have caused the problem.

Android studio "Your app does not have the latest code changes.."

I tried to run app from Android studio, and it worked. But after stopping and starting few times this message appears.
Uninstalling and installing over again works, but as soon I restart the program the same message reappears.
"Your app does not have the latest code changes because it was restarted manually. Please run from IDE instead."
I am running everything from IDE. Nothing it done through the phone itself.
For me even killing the app and running from Android Studio still appeared the same sentence "Your app does not have the latest.."
What always works is Run > Computer > Clean and Rerun 'app'
You saw this message because you killed and restarted your app manually after "Instant Run" applied changes to your app.
In Android Studio 2.0, a new feature was added called "Instant Run".
Instant Run is described in the Android Studio Project Suite:
Introduced in Android Studio 2.0, Instant Run is a behavior for the Run and Debug commands that significantly reduces the time between updates to your app. Instant Run pushes changes to methods and existing app resources without building a new APK, so code changes are visible almost instantly.
A demo of Instant Run can be seen in this video.
If you make a small change or changes, those changes will be implemented via Instant Run. However, since it did not build a new APK, killing that running instance of your app will discard those changes from the app installed on your device.
From the Developer site:
Note: If you need to restart your app after a crash, do not launch it from your target device. Restarting your app from your target device does not apply any of your code changes since the last cold swap or incremental build. To launch your app with all your recent changes, click Run (or Debug ) from Android Studio.
To have the changes permanently implemented to your app, kill it (actually make sure it gets killed, don't just hit the home button), and then build and run it again from Android Studio.
well if that message appears you don't need to uninstall the app
Just press the red button highlighted in the pic
it will stop your app and then if you run it again then it will run fine with latest code.
NOTE: you can press red stop button only if the app is running and your device is connected to the android studio, it will kill the app process and when you re-run it it will have the latest changes.
if this doesn't solve your problem then you can go to Run>Clean & Re-Run.
Hope it helps
Use Rerun
When pushing code changes that affect certain initializers, such as changes to an app's onCreate() method, you need to restart your app for the changes to take effect. To perform an incremental build and restart the app, click Rerun .
If you need to deploy a clean build, select Run > Clean and Rerun 'app' from the main menu, or hold down the Shift key while clicking Rerun . This action stops the running app, performs a full clean build, and deploys the new APK to your target device.
I tested the way of Shifting key while clicking Rerun, it works fine.
Link : https://developer.android.com/studio/run/index.html

Android studio build fast but run wrong in emulator

Exactly my problem, if I have small change in app about display UI (modify activity code or resource layout), Android studio build very fast and then run my app in emulator without kill "previous version" process (running in emulator), sometime it's run and display correct, but sometime it doesn't run correct what I want, I must kill process manual and rebuild project, it takes a lot of time, and makes me confused because I don't know where go wrong,
I thought this is my bug.
It happen recently when I update Android studio, I think this feature is very powerful and helpful, application mustn't rerun from the beginning whenever build new version.
But how to enabled/disabled "fast build", sometime I want Android studio build my project normally.
You have 2 solution:
1)You can also disable Instant Run from Settings > Build,Execution,Deployment > Instant Run - and disable it
2)Clean Project when studio doesn't build properly
Press the stop button before running the app and then run the app so dialog will be displayed to choose the emulator.

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)

AIDE Won't Build App Stuck on "Running AADT" Stage

I've moved an app to mmy device so that AIDE can build it and so I can install but it is stuck at the AAPT stage. Any suggestions?
Look at [Menu] -> More -> Settings -> Build & Run -> Dexer Optimizations. If it is checked, it can take a lot longer, I believe. I tried building the HelloWorld app template and I just forced it to quit building afer waiting several minutes. After I unchecked Dexer Optimizations, it only took a few seconds to build. FYI I'm using an 800MHz Android 2.3.6 phone.

Categories

Resources