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).
Related
I built a .NET MAUI project and want to install this on my local device (Android 9). When i start directly out of VisualStudio as Debug build everything works well. When i change build type to Release, the splash screen is visible for a second and after that, the app closed directly.
I have no clue what the problem is. Is there an opportunity to debug release build or have a log view, why the app crashes instantly?
Thank you and best regards!
Im trying to generate an APK to test my android build, it used to work before, i dont know what went wrong that it stopped working, whenever i try to run on device either on android studio or my own device, it does not build even though its error clean. App actually installs, but when its about to run it closes down and this message appears
Heres what i got from checking the logcat on Android Studio: https://imgur.com/a/FdE4WMo
Try uninstalling the app from the device and then run it again.
The dev / debug build uses an encryption key that's specific to the machine so I think that maybe you are trying to install a different app over the original one?
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
What is the major difference between
Run app and Apply changes?
What could be the best scenario to use each?
Thanks.
"Apply changes" will be enabled if you have "instant run" enabled and to disable instant run check https://stackoverflow.com/a/35169716/2826147
From the Android documentation: https://developer.android.com/studio/run/index.html
Apply Changes button provides a faster workflow for most incremental changes to your app. [...]
You can clickApply Changes to push certain code and resource changes to your
running app without building a new APKāand, in some cases, without
even restarting the current activity. [...]
Clicking Run (or Debug ) forces a cold swap and an app restart.
If you make a change to the app manifest or a resource referenced by
the manifest, Android Studio always pushes your changes with a full
APK reinstall. [...]
Apply Changes action is available only when you meet the following conditions:
Build your app using a debug build variant.
Use Android plugin for Gradle version 2.3.0 or higher.
Set minSdkVersion to 15 or higher in your app's module-level
build.gradle file.
Deploy your app to a target device running Android 5.0 (API level 21)
and higher.
When you click "Run" App icon, it will uninstall existing build and install build every time.
"Apply Changes" option will be available only if you enable "Instant Run" feature in android studio. It will swap changes to existing build and run your build. Your existing build will not get uninstalled when you do this.
The Instant Run / Apply Changes feature will try to push your changes without building and deploying a full APK, and if possible without restarting the application or even the current activity. It will resort to a full reinstall if needed. More details here.
Before Android Studio 2.3, the Instant Run feature was available through the Run (or Debug) button, as long as certain conditions were met. Starting with Studio 2.3 we have a dedicated button for Instant Run, which is the Apply Changes button. It is only available when Instant Run is possible. The Run and Debug button now always restart the app.
From the Release Notes:
A separate button to push changes with Instant Run: After deploying your app, you now click Apply Changes to quickly push incremental changes to your running app using Instant Run. The Run and Debug buttons are always available to you when you want to reliably push your changes and force an app restart
for Android Studio 3.5 and higher
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