Recently I have updated my android studio v3.0 to v3.1.
in v3.0 when I click on Run button. It automatically complies builds apk and installs app on my phone.
But at newer version I have ti rebuild app each time before running application. Otherwise it installs previous compiled APK on my phone. Is their a way to do both at on button click.
because its frustrating.
I have searched in settings but no option found.
I had the same problem. I fixed the problem provisionally, adding the task 'app: clean' in the Run / Debug Configuratrions before the app is "made". It takes much longer to compile and build the app than before, but it will always install the latest version, at least for me.
Open the Run / Debug Configurations. Can be found to the left of the Run Button.
Run / Debug Configurations
In the configurations you will find at the bottom the section "Before launch". There, you are leaving out "Run Gradle Task".
Adding Run Gradle Task
Under Project you choose your current project and at Task you choose clean.
Select settings
Importantly, the Gradle Task is at the top of the list!
mind the order
Run project
Hope I could help you with that
Related
I updated my mac Android studio to version "Electric Eel"
When I just try to generate the APK using "Build APK" option, then it automatically starts running the test cases, which is unnecessarily causing me further issues and slowing down the process.
"I want to know if there is any option available, where I can disable running the test cases while just building the APK.?"
PS:
I have explored it at many places but not getting exact option to configure it.
I am only able to generate the APK using command ./gradlew assemblePreProdDebug (PreProd is flavour), it works without the test cases being executed.
When I select the device and run the build, it works fine, it runs without the test cases being executed.
You can use gradle panel to launch the task you want.In order to make your build task appear you will have to:
go to the Prefrences > Experimental
In gradle section uncheck "Only include test tasks in the Gradle task list generated during Gradle Sync" (pay attention that may have an impact on gradle sync task execution time depending on the complexity of your project).
Apply change then click on gradle sync button
Then you should be able to see the assemble tasks in the gradle side panel.
I recently built a release apk for the first time to put my app in the app store. Now that I've done that I've switched back to a debug build variant to continue working on the app. However, now when I try to run on my device nothing happens. The app does not open like it used to and when I open it I can see it has not been updated. If I try to run again, android studio says the app is still running and I have to restart it, but I can not see where it is running? The gradle build says:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
and that the build was successful, but I can't figure out how to get it on my phone.
I'm wondering if I accidentally altered a required setting when trying to get my release apk? (I didn't know how to do it at first so may have clicked the wrong thing at some point.) If anyone knows what setting I may have changed and how to switch it back that will be much appreciated. I'm running Android Studio 3.0.1
Edit: It used to say "Gradle build running" first when I ran the app and now it says "Gradle build using tasks"
When you start release APK build process in Android Studio, it makes some configuration changes. In that one is Build Variant of APK from debug to release. Like below
Maybe you forgot to change it back when start application in debug mode. Just change build variant from release to debug when you want test/update application in debug mode.
Above option can be found on bottom left hand side of Android Studio.
PS: When you start/use app in debug mode, uninstall release APK from your phone (if any).
Last night, I clicked "run" button and Android Studio built my app.
But after completing the build task, it did not work on my device anymore.
How to fix that? Do I have to set the auto run option?
I checked the application installation on my device.
My issue is that "autorun on device" does not work.
Open the Gradle tab that is on the right side of the Android Studio UI.
Find the installDebug option, and the Run button will use that as the "last ran" command.
If you are otherwise unable to run the app, then you may have a compilation issue
Xamarin.Forms PCL android project has been working fine and I was deploying to emulator to debug successfully. Now it fails to build and I get an "Unexpected error...Reason: An item with the same key has already been added"
When I just build the project, it builds successfully, but when I build by trying to deploy to an emulator, it fails.
This started happening right after I installed a bunch of Android SDK updates to I could test against the newer Android versions. Also installed the HAXM drivers to try and run a faster emulator. Also did some consolidating and updating of NuGet packages. Also changed target from .NET 4.0 to 4.5.
I can successfully start both the older emulator that I was debugging on previously as well as the new one I've added.
Lots of recent changes so I'm not sure which one is the culprit. I need to know how to get some more detailed logging of why the build failed so I can fix it.
Currently the Build Log is set to Diagnostic, but I don't see any specific reason it's failing to build.
I found the culprit in the Android Options page in the Project Properties.
Under the "Packaging" tab, the "Use Shared Runtime" option was unchecked. As soon as I re-checked this option, I was able to successfully build and deploy again.
At this point, Im using Android Studio 2.1.2. When I changed the code or without changed the code, the app is always kill and restart the session when I want to run the app.
Run App
So how to run the app without kill and restart the session?
You are wondering about Instant Run facility added in most latest versions of android studio. To use it please Make sure you have up to date Gradle plug-ins and builds because it's not only enough that having latest version of Android studio will support Instant Run it also required all stuff up-to-date so Please first check it out.
To check it out if it is disable follow this steps
1) Go to File -> Settings
2) Go to Build,Execution,Deployment -> Instant Run
By default It is enabled if everything is up to date. If not you can.
Go read this for depth understanding : https://medium.com/google-developers/instant-run-how-does-it-work-294a1633367f#.mqwx46kn6
And what is supported under instant run is given here.
https://stackoverflow.com/a/33905037/5476209
You need the latest Gradle build in your project for the same And also you need to run the same app in your phone so that the patch will be installed and activity will be restarted.
Please not that every time you hit an error in run time the quick launch will get disabled and you will have to rebuild the whole project to Instant run again.
Reference :http://tools.android.com/tech-docs/instant-run