Android Studio avoid "make" while running - android-studio

When you press the run button in Android Studio the project is buit again, and as you know this always take long, if e.g. I select Build -> Make Project and then "Run" the make process runs again, I don't understand why? I would expect that it only installs the APK that is already generated. Is there a way I can achieve this, is my expectation funded or am I thinking wrong?

I've used the approach described here to speedup my build.
Building and running app via Gradle and Android Studio is slower than via Eclipse
At the same time i've disabled "make project automatically" because sometime it produces old code.

Related

KMM Project Build for iOS Without Running

Maybe I'm just missing something but is there a way to trigger the iOS build in Android Studio for a KMM project that doesn't launch the simulator once the build is done?
When looking at the iosApp run configuration I see it has "Build iOS application" listed under "Before Launch" which makes me suspect this is possible but I didn't see it listed as a gradle task or anywhere else I could think of.
I've been doing the iOS work in Xcode and when I make changes to the shared code I want to rebuild it without running the app (which I've been doing from inside Xcode).
Not exactly a solution, but I found that when you hit build in Xcode it builds the Kotlin code so any changes to the shared module are included automatically. No need to do iOS builds from Android Studio.

Android Studio 2020.3.1 - Run very slow, always re-build

I'm using latest AS, version 2020.3.1. Every time I change the code and run it again, AS run very slow, always re-build project (take about 10 minutes). My project is also quite large, using many libraries.
How to make AS run faster?
Please help me. Thanks.
It all depends on your system configurations. It does not matter which android studio version you are using. Try upgrading your machine or prevent using inbuilt AVD of android studio rather use your own mobile for testing. This could make Your AS run a bit faster.
Here is the link to know how it is done
https://developer.android.com/studio/run/device

Android Studio 3.0 VERY VERY VERY slow on run

I have a very big problem using Android Studio.
Every time I make a code changing, I have to check if all has gone well launching my app; but as soon as I click the "Run app" or the "Apply changes", it's the end: it starts the Gradle build process, which take even 30 minutes to complete, and furthermore Android Studio take the full control of my computer, not allowing to do nothing anymore (like open the browser, open notepad++, and so on...).
Can anyone help me?
Thanks
If you use Eclipse you won't have this problem anymore. but if you want to stick with android studio and gradle you can run your emulator and gradle once and whenever you want to compile your code run it on the already built gradle. this means that do not close the emulator and run your program on it again and again. this way you will not have to spent alot of time on loading the emulator and gradle
Android Studio is not a very light software.It uses a lot of your system RAM and CPU power.So if you are using an old system then it is obvious that android studio will run slow.If possible then upgrade your system.
And one more thing it's better to use actual device rather than Virtual Emulator for our application working test.

Why starting project (Run) in Android Studio triggers APK rebuild even if no changes were made?

I mean, we are in 2016 and this is not a Borland compiler.
The point of Run operation is to start the package on device. If no changes are made since last run, just run the APK, but this Gradle thing cannot manage it and runs in whole project compile each time (2-3 minutes). Components are not recompiled, but the whole package construction takes that time.
I wonder how the whole world of Android developers tolerates this (and other quirks of gradle). I searched in Google and found no solution. Any hints to make it better?
You can't do anything about it; Android Studio just has to rebuild every time. But in the newer versions of Android Studio, you can use Instant Run. This runs/debugs your applications by using a simpler Gradle build in a very fast matter.
Also, take a look at this , which previously helped me to reduce my Gradle build from 45 to 7 seconds.

Android Studio is installing old apk on device

I am developing an Android app using Android Studio (0.89 Build #AI-135.1404660, Built on Sept 3,2014) using both emulator and Nexus 4 device.
I had the same issue with a version prior to that.
The problem is that after I changed my code and resource files, I still get the old apk installed on the device or emulator.
What do I need to do to get it to run current code? Is it a building config?
Is it a known issue with Android Studio?
Or with a Nexus 4 device?
This is the second time it has happened, and I resolved it(then) after trying one of the steps below. They have not worked for me again.
Here is what I've tried
Build > Clean Project > Restart Android Studio > Run
Build > Rebuild Project > Run
Step 1 plus Uninstalling of apk on device
Step 2 plus Unistalling of apk on device
Adding erroneous resource entry then running.
I have read the following:
Android apk install: How to clear files from old version?
adb - How to reinstall an app, without retaining the data?
Device still has the old apk
Android build doesn't update code base or resources for target .apk on device
None has worked so far.
I had the same problem. After trying numerous methods that didn't work, I realized that I had accidentally changed an option in my "Run Configuration". Here's exactly what I did to fix the issue.
Run --> Edit Configurations
With your configuration selected on the left panel (mine says "app"), in the General tab on the right panel, there is a section called "Before launch". This section should have an option added called "Gradle-aware Make", but I had accidentally removed it.
I re-added it by pressing the "+", then clicking OK in the popup (leave the input box in the popup blank).
Click apply.
This fixed the problem immediately. Hope this helps someone!
Run / Debug Configurations / Miscellaneous TAB
[] Uncheck: Skip installation if APK has not changed
Android Studio doesn't always detect small changes in code.
The behaviour is erratic. I solved it by reviewing my code.It turned out that there was a resource file that was invalid. Try reverting back to the last working version of your code before the current changes... Probably a known issue that will be/was resolved out of Beta
Google thinks it is a feature, not a bug
https://code.google.com/p/android/issues/detail?id=156263
Their proposed solution is to copy the apk(s) instead of manipulating the filename, as in e.g.
Copying APK file in Android Gradle project
I've spent way too many hours to keep this to myself. The way I fixed it was that I noticed some hours later that I was using different layout version in res/ .... I have actually two versions of layout (layout-v26) and (layout). All this time I was modifying the other one and uploading different one. Maybe its just a newbie mistake but I hope somebody will find it useful.
The reason why there are 2 version was because of " autofillHints="" -> quickfix -> create new version of layout "
image of my tree
I am using android studio for building flutter app, I was facing the same issue untill I did the following:
From Android Studio, go to Tools-Flutter-FlutterClean
It resolved my problem as of now.
Check Your Layout Files.
I ran into the same problem and I realized, it gives some problem if you have same layout in multiple orientations(portrait and landscape). If one is changed other remains unchanged and then it creates a conflict. So android studio installs the one with the previous layout
PS: This was happening in my case.
The problem occurred on my Android 11 devices. I guess ART ran old code dex2oated.
Solution:
Run / Debug Configurations - General - Always install with package manager (disable deploy optimization on Android 11 and later), and check the option.
I was also facing this issue and get solution by deleting build folder manually because some time ide cannot be able to delete this. So go to the app folder and find build folder delete this and after clean and build project and run again.
projectname->app->build
You should select "Deploy default APK" option in Run/Debug Configurations. After that Android Studio will upload and install new apk to your emulator/device when you run application.
In android studio. at right side. see gradle option. click it. and then press circular arrows button shown in red square.
Same problem, none of the solutions mentioned here had any effect. I had to disable the "Allow parallel run" in "Menu > Run > Edit configurations...".
You can read more about this option here: How to run the same project multiple times in IntelliJ IDEA?
The solution to this issue is actually very simple.
Android studio is actually not detecting some small changes that you have made to the application. That is why it is installing the previous builds.
The solution is easy -> Remove the previous builds.
In the right side, go to gradle tab.
Expand Tasks. Find "clean" or "cleanCache" task or any task that starts with "clean". Double click to run that task.
Expand "app". and do the same.
Then File> Invalidate cache and restart.
Enjoy!! Your problem is solved...
My devices also ran old states - dont know from where in my git it has taken these.
I created a new configuration (default is "app") and it worked.

Resources