Android Studio does not install latest application on device - android

I'm following some tutorials about building apps in Android Studio, but for some reason it's not launching/installing the latest version of my app when I click 'run'. I have to manually uninstall the app on the phone and then click run after making changes in Android Studio for the app to get updated. Any ideas?
Here is the console output:
Waiting for device.
Target device: htc-htc_one_m8
Uploading file
local path: /home/brandon/AndroidStudioProjects/JustJava/app/build/outputs/apk/app-debug.apk
remote path: /data/local/tmp/com.example.android.justjava
No apk changes detected. Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop com.example.android.justjava
Launching application: com.example.android.justjava/com.example.android.justjava.MainActivity.
DEVICE SHELL COMMAND: am start -D -n "com.example.android.justjava/com.example.android.justjava.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.justjava/.MainActivity }
Waiting for process: com.example.android.justjava
Connected to the target VM, address: 'localhost:8638', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8638', transport: 'socket'

No apk changes detected. Skipping file upload, force stopping package instead.
Android Studio thinks that there are no changes and doesn't install the new APK. A workaround is to disable the "Skip installation if APK has not changed" option in Run > Edit Configurations.
I'm using Android Studio 1.4
Source: https://code.google.com/p/android/issues/detail?id=160901

Android Studio thinks that there are no changes and doesn't install the new APK. A workaround is to disable the "Skip installation if APK has not changed" option in Run > Edit Configurations >Android Application > app >Miscellaneous .
Then uncheck "Skip installation if APK has not changed".
Another problem like this is instant Run you can manage it by :- Just go to "File -> Settings -> Build, Execution, Deployement -> Instant Run" and just disable it. With this Android Studio builds from scratch each time but it's better than not building it right.

This is actually a bug
you can find more info Android Open Source Project - Issue Tracker
Disabling instant run option in edit configuration and adding -r flag to the install flags is best work around for now.!

option in Run > Edit Configurations >Android Application > app >Miscellaneous . Then uncheck "Skip installation if APK has not changed".
THEN --> option in Build > clean project and rebuild project
and reinstall APK in your device.
THIS WORKS FINE FOR ME, HOPE THIS HELP OTHER ALSO

Another reason why the app might fail to install/start is if you've set up a "work profile".
The app might still be installed in your "work" profile and thus won't be re-installed nor uninstalled when starting through Android Studio. The "main"-profile portion of the app is "disabled" though and thus the activity can't be started.
Solution: manually uninstall the work-app, then redeploy from Android Studio.

Sometimes when I get this I just kill the app on the device, then run it. Throw in a log statement to clarify you're on the right build, just something that you know you changed for this build.

I have tried all of above solution but didn't work for me.
I solved by Opening a new project or some other existing project (being in current project) in a new window and then I closed the previous one..
I opened again the previous one and clicked on run and it worked for me like a charm..:)

Run on a Phone
Set up your device as follows:
Connect your device to your development machine with a USB cable. If you're developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the OEM USB Drivers document.
Enable USB debugging on your device by going to Settings > Developer options.
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
Run the app from Android Studio as follows:
In Android Studio, click the app module in the Project window and then select Run > Run (or click Run in the toolbar).
In the Select Deployment Target window, select your device, and click OK.
Please refer the link

Related

Installation did not succeed. The application could not be installed. Installation failed due to:

I am trying to run my app on Android Studio 3.5. It throws an error while installing the app on the phone.
Installation did not succeed.
The application could not be installed.
Installation failed due to: ''cmd package install-create -r -t --full -S 2164012' returns error 'Unknown failure: cmd: Failure calling service package: Failed transaction (2147483646)''
Retry
Close emulator
Wipe data in AVD Manager for a particular emulator.
Since there can be multiple reasons why it occurred, please try the following - one should work:
Execute Build > Clean project. Then, again Build > Rebuild Project.
If still the error persists, Build > Make Project
Check if Instant Run is enabled on the Android Studio. If so, disable it by navigating to:
Preferences > Build, Execution, Deployment > Instant Run
Check if the phone storage is running low. If not, uninstall the previously installed app, run adb uninstall <package_name> command from the terminal to ensure uninstalling & try installing again
Check if USB Debugging is enabled in Developer options, if not - enable it.
For Huawei devices, after executing Clean Project, navigate to Phone Manager > Cleanup and Optimize - it also worked for me on 2 Huawei devices
For Xiaomi phones, turning Off MIUI optimization has always worked for me for all Xiaomi devices. Go to Settings, find Developer Options and tap on Turn Off MIUI optimization
Please note that I was getting this error when I had emulator-5554 (minSdk(API28)) selected as the deployment target, but it went away when I changed that to Pixel_3a_API_30_x86.

Android Studio after deploying app not launching on Phone

Got a new computer installed android studio. Created a test app (default) - No coding. I compiled and clicked the run and installed the app to the device (1+6). The app is installed but doesn't launch automatically.
I checked the configuration shows launch default activity.
What could be wrong?
Also another strange thing: I get emulator-5556 [OFFLINE] - blinking always in select deployment target.
Can someone help me fix this?
Thanks!
I had the same problem and was able to solve it. The problem seems to be the result of another program using the same port 5556.
In my case it was Videostream.Videostream tasks
After ending the tasks related to Videostream the blinking stopped and apps were deployed normally.
In such a case, you can do as follows
adb kill-server
adb reconnect
You should see online after above command & select this emulator from
- Run > Edit Configurations > Target
In General Tabarea choose
- Target: Emulator
- Android Virtual Device: <your emulator>
Check launch options from Run/Debug Configuration.
Lunch options > Launch > select as default Activity
Happy coding !!!
You need to select an emulator under Deployment Target Options -> Target:.

Android Studio can not install the app

I'm trying to create my first android application. For this purposes I use Android Studio 2.2.3. I have created the simple app with the single activity and which does nothing, just empty screen and no more else.
I'm developing on Meizu MX6 and I switched ON the next options:
Security App -> USB installation monitor
Settings -> Fingerprint and securiry -> Unknown sources
Settings -> Accessibility -> Developer Options -> USB debugging
Also have configured udev rules.
When I press the Run button I see this message:
Installation failed with message INSTALL_FAILED_USER_RESTRICTED.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
And after pressing OK this log appears in the console output:
$ adb push /home/***/dev/android/HelloAndroid/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.android.hello.helloandroid
$ adb shell pm install -r "/data/local/tmp/com.android.hello.helloandroid"
pkg: /data/local/tmp/com.android.hello.helloandroid
Failure [INSTALL_FAILED_USER_RESTRICTED]
$ adb shell pm uninstall com.android.hello.helloandroid
DELETE_FAILED_INTERNAL_ERROR
Error while Installing APK
Can somebody explain how to fix this?
Check if current user have root access. And enable developer mode if you didn't do this yet.
Please build once again, after clearing temp folder and remove build directory in project.

Not able to debug app on android device - Android Studio 2.0

I am not able to debug an app on my device (Asus Zenphone 2) after I updated android studio to 2.0. I keep seeing below message in debug tab right after I click on debug icon in Android studio.
Message in debug tab in Android Studio UI
---------------------------------------------------------------
Waiting for application to come online: packagename
Waiting for application to come online: packagename
Waiting for application to come online: packagename
Waiting for application to come online: packagename
I keep seeing Alert Dialog with the title "Waiting for Debugger" and Force close button all the time.
I searched but it seems only two results from google for that message.
I restarted Android studio, checked developer settings on phone...
Have anyone faced with this issue. Please help me. I cannot run the emulator, because my mac will be too lag. Thank you in advance.
The problem is that after installing and starting to launch the app, that debugger client that AndroidStudio starts is unable to connect to the debugger server on the device. This can have many causes, see this answer and the other answer shown on this page and see if one solves the problem for you
To help figure out the problem, look at the 'Console' tab of the 'Debugger' window in AS. One of the first few lines should look like this:
$ adb shell am start -n "com.acme.audtest/com.acme.AudTest" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Cut and paste that line into a command prompt, REMOVE THE '-D', and execute it.
It your app ('AudTest') comes up without error, the problem is in AS, is communication to the device, or the configuration of the device. If the app doesn't start, it is in the .apk. (Not the complete solution, but starts to point you in the right direction -- for which of the solutions below applies to your situation.)
First I select the second option, and it worked fine. But then don't know why I change to select first option. So, the debugger shows the message Waiting for application to come online forever. And I did not notice that, just thought another app prevent me debug or that was an issue with Android Studio 2.0.
So, just check to second option will solve my issue. Thank all.
Restarting Android Studios (2.1.1) resolved this for me.
There are two possibilities:
1.USB Debugging off :
Start Developer Option of your devices
Switch On USB Debugging
2.In Android-Studio : File -> Invalidate Caches / Restart
anyone can be useful for you.Try it
The correct answer is close your Android Device Manager.
None of these suggestions worked for me till I closed it.
For me the problem was in "Android Studio" + "Intellij IDEA" running side-by-side. Was fixed by disabling bundled "Android plugin" in "Intellij IDEA".
(Note: problem appeared only with some later versions of these IDEs)
Nothing worked for me except one solution...
Clearing the Intellij IDEA (Android Studio) .idea directory which contains configuration information worked for me:
Exit Android Studio
Navigate to the project you are trying to debug
Backup any files inside .idea that you modified (if your project checks any of these into VCS)
Delete .idea directory
Open the project in Android Studio
I had to remove the parameter
android:exported = "false"
from the main activity.
if you get this problem on the emulator, running adb reconnect worked for me. there is a similar command for devices adb reconnect device
**
This answer might help for those Who have successfully connected their
device along netbeans NB Android but on debug there's no application
being appear on device.
**
Ok so solution is check your android device version in mobile setting click on about device at last: you will know your android version there.
Now choose the same version for your netbeans android project.
Right click on project name click on properties and then change target with same as your android device.
(In my case android version was 4.4.2 so I selected the same for my project target)
Before to go ahead click on service tab next to project tab in netbeans then right click on Android device and click on restart ADB.
Finally you need to right click on project again and click on clear and build.
Now you can run with hope to get result.
I just wanted to share my experience as I had the same error and there was no way to solve it using all the solutions you guys posted. I even deleted several times my virtual device, no way to make it work again.
In my App I have a custom permission com.example.CUSTOM_PERMISSION and I wanted to use it to protect my Main Activty from a confused deputy attack.
<permission android:name="com.example.CUSTOM_PERMISSION"
android:label="#string/permlab_deadlyActivity"
android:description="#string/permdesc_deadlyActivity"
android:permissionGroup="android.permission-group.COST_MONEY"
android:protectionLevel="dangerous" />
.
.
.
<activity
android:permission="com.example.CUSTOM_PERMISSION"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Somehow that property android:permission was preventing my app to install and run on the virtual device, even though it could be compiled and build with Gradle successfully.
Just after removing it, everything is fine again
I am not sure the app is protected this way, I'm building another test app to try performing a confuse deputy and see if the declaration of the custom is just enough.
Hope this can help somebody that was getting mad like me!
I had this problem in the Android emulator, and it was solved by going to Tools->AVD Manager, selecting the device, right click "Cold Boot Now".
The solution which helped me is to click on attach the debugger to android Process and set debugger to java.
Just throwing my experience in as this just started happening. With regards to all these answers, I tried a few of them and none seemed to work. So I started from scratch:
Initial setup:
- USB Debugging ENABLED
- Always prompt when connecting to USB (I usually only connect in charge mode)
- Allow ADB debugging in charge only mode ENABLED
- Wait for debugger DISABLED
- Verify apps over USB ENABLED
The steps I took to get debugging back:
Close down Android Studio - I didn't go so far as to delete the .idea folder as discussed, but I'm sure it couldn't hurt.
DISABLE USB Debugging
Revoke USB debugging authorizations
Reconnect Device
$ adb devices
> <Device Id> unauthorized
ENABLED USB Debugging
Reconnect Device
When prompted select ALLOW (I clicked always allow)
$ adb devices
> <Device Id> device
Open Android Studio and hit debug - Application started successfully, I was still getting 5-6 of these messages but then it worked:
$ adb shell am start -n "com.exampleapp/com.exampleapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Connecting to com.exampleapp
Connected to the target VM, address: 'localhost:8600', transport: 'socket'
React Native
As a side note - this happens every so often, I'm not sure whether it's from switching back and forth between running from react-native run-android or debugging in Android Studio, but regardless I've had to do this a couple times (finally decided to document).
Also remember
$ adb reverse tcp:8081 tcp:8081
and to start the packager when debugging (I tend to forget).
Try to restart ADB. Execute terminal commands:
adb kill-server
adb start-server
I had this problem and none of the solutions provided worked for me.
I you had the same issue, you can also try this:
Edit Run/Debug configurations
Select the 'app' or other name's configuration
At the launch Options, change Launch "Nothing" to "Default Activity".
Steps

My Application can't start debug mode in Android Stduio

The logcat show:
Waiting for device.
Target device: lge-nexus_4-01aa55d2b923e7a9
Uploading file local path:
C:\Users\HOXCN\AndroidStudioProjects\Horcrux\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.hoxcn.horcrux
No apk changes detected.
Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND:
am force-stop com.hoxcn.horcrux
Launching
application:com.hoxcn.horcrux/com.hoxcn.horcrux.ui.activity.SplashActivity.
DEVICE SHELL COMMAND:
am start -D -n
com.hoxcn.horcrux/com.hoxcn.horcrux.ui.activity.SplashActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
cmp=com.hoxcn.horcrux/.ui.activity.SplashActivity }
Warning:
debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
Restart ADB integration and try again(PS: I restart the adb with adb kill-server, don't work)
Waiting for process: com.hoxcn.horcrux
If i create a application with a default, the debug mode can run.
If i click run 'app', it work; if i click debug 'app', it show the message above and the screen show the dialog "Waiting for debugger" all the time
You hava to remove android:debuggable="true", because when you run/debug an application in Android Studio is signed with a debug certificate so that setting is not mandatory.Then check from console if the device is correctly attached with an adb devices. You should see it listed.
Below steps follow:
close Android Studio and any other IDE you have opened (maybe you have Eclipse also running?) and emulator instances;
Remove USB cable from PC;
3 . Run adb kill-server from console;
4 .Open Android Studio;
5 . Click on run/debug;
6 . when the window to select the device appears, attach your device to USB and USB to your computer;
enter link description here
Ok, this has happened to me. This usually occurs if you already have an apk with the same package name but different signature installed in your device. So the way to fix this is to uninstalll any existing apk's in your device.
Now in some android phones there are options for multiple user accounts and as such if an app is uninstalled it sometimes remains there for the other users. So you should go to the app options in the settings and scroll down to the very bottom. It might show your app at the bottom. Uninstall it from there too and it would work.
There is a Debug icon on the toolbar. It is located right next to the Run icon. Try to launch the app with that.
There is also a debug flag in the AndroidManifest.xml file. It is located under the application tag, and should be set to "true", as follows:
<application android:debuggable="true"> </application>
OR
Go to Tools => Android => disable adb integration and again enable it
after, Unplugged USB from device and again plugged in. Then press shift + F9
on Mac, I had the same problem.
I had an application to transfer files from my android device, this application causing the problem. All I had to do was to uninstall the androidFileTransfer application and install it again.
Good luck!
You can try to Restart your android studio and Reconnect your device..Its worked for me
Thank you

Categories

Resources