Debugging in Android Studio doesn't work because INSTALL_FAILED_DEXOPT - android-studio

After connecting a real device and debugging the virtual device stopped working.
So I deleted the virtual device and create a new one.
But now when I click either Run or Debug it comes up with this warning
so I click "OK" and then nothing happens but this appears:
06/05 11:18:19: Launching 'app' on Nexus 7 API 22.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_DEXOPT
The device might have stale dexed jars that don't match the current version (dexopt error).
Retry
Can I ever debug on a virtual device ever again? How?

This looks like an issue of reading the latest emulator state or something similar.
I've been able to fix that by wiping data from a selected emulator and cold booting it.
Open AVD Manager by clicking on it's icon:
or by double-clicking Shift key, typing in AVD Manager and clicking on desired option:
From a list of emulators you have find the one that is causing you trouble. On the end right side find arrow pointing down. Click on it and select Wipe Data:
Click the same arrow and click Cold Boot Now.
From now on your emulator should work fine.

Related

Android Emulator got stuck at "shutting down"

The emulator in my android studio keeps showing "shutting down". I try closing it and run again, restarting my mac, but nothing worked, each time I run it, it shows "shutting down" again. even though I can see actions running below (very blur)
Click on Tools
Click on AVD Manager
Click on the dropdown arrow next to the AVD which is stuck
Click on cold boot now
This issue occurs when we forcibly exit an unresponsive/stuck AVD. AVD manager saves the state before it is forcibly exited and on the next start it continues from the unresponsive/stuck state. This is useful when we need the AVD to boot up quickly, however if you want to disable this feature entirely then follow the steps below:
In the AVD manager, click on the pencil icon
A new window will pop up. Click on show advanced settings
Scroll down to the emulated performance section
Next to boot option, select cold boot
open AVD Manager Dialog from top right corner
go to your emulator
click on the last icon on the right which is a drop down button
Click wipe data
Important Note: this will delete all data on that emulator and give it a fresh install again and might solve your problem
If that didn't work then check that you have enough rams to run both the emulator and the android studio.
I run my emulator with cold boot by command line
cd C:\Users\<your_user_name>\AppData\Local\Android\Sdk\emulator
emulator -list-avds
emulator -avd <your_adb_name> -no-snapshot-load
If the cold boot or wipe data does not work, you can try deleting the lock file. Then quit the emulator, and restart it.
In my case, AVD Manager prompted me to delete the following files, I did it, and the problem was solved.
If it shows "AVD *** is already running etc." then just connect any mobile device that after enabling debugging mode and run your app in a physical device instead of an emulator then
Click on Tools
Click on AVD Manager
Click on the dropdown arrow next to the AVD which is stuck
Click on cold boot now
First of all:
You have to close the window, or tab of your Virtual Appliance.
With this you get Android Studio to standby the Device and unlock the ADV (Android Virtual Device) files, so you can manipulate the virtualization.
Maybe you have to wait until Android Studio kill the process. If Android doesn't do this automatic, you will have to close Android Studio and delete C:\Users{YOUR_USER}.android\avd{YOUR_DEVICE_NAME}.avd and within this folder delete all files and folders with extension .lock to stay secure before start again Android Studio.
After that:
Just open the Device Manager, and click on the down arrow in the Actions section for your device, and select Cold Boot Now. This reload the Virtual Device without start or open any program.
Finally:
If Cold Boot Now worked fine, now you can run or debug your application to check that it functions perfectly. Without the device continuing with the problem that the system is still stuck/frozen.
And also you do not need to do a Wipe Data, so you do not delete the data of your application, since you can have any internal database in SQLite, which has the changes and advances that you have been implementing or creating during the development of your application for its operation.

Android Studio guest hasn't come online in 7 seconds

When I first start the emulator in Android Studio I get an information message,
guest hasn't come online in 7 seconds retrying
I am curious as to how to stop this because while it is on my screen for about 40 seconds I cannot do anything in the emulator.
Actually 'Cold Boot Now' may work in this situation
I had the same problem. Selecting Cold Boot Now in AVD manager solves the problem.
But I have to open AVD manager each time when I want to launch Emulator and I just want to click on Run app button and select device, without opening AVD manager.
To solve this: open AVD manager -> Edit device -> Show Advanced Settings -> Boot option -> select Cold Boot instead of Quick boot.
tools->Android->AVD Manager
Choose the device then Cold Boot Now
maybe it's bug from intel haxm 6.2.1, because after i update i got same problem.
I solved by recreate emulator and testing again
I managed to solve this issue by updating the .ini file manually. (I was not able to find a corresponding setting in the GUI.)
The location of the .ini file, relative to your home directory, is:
~/.android/avd/MyDevice.avd/config.ini
where MyDevice refers to the configured device name.
Depending on your operating system, you may find your home directory according https://en.wikipedia.org/wiki/Home_directory.
Change the entry within config.ini from no to yes:
fastboot.forceColdBoot=yes
I specified AVD memory 2048 Mbyte instead of 1536 Mbyte. Things
started to work again. (I'm developing on macbook.)
I tried "Kuldeep Chandel" solution which is to duplicate AVD and my app runs again too. Because of that I specified RAM again as 1536
Mbyte. Guess what... It worked...
I think AVD confuses to handle things and we need to duplicate the current AVD, and use it instead of the problematic one.
In "Your Virual Device" - Click on Duplicate OR Duplicate your Device. It will work like Charm.
I faced this issue on using Android API 28 emulator with Android Studio 3.0.1. Android API 28 requires Studio 3.1 and above. Once I updated Studio to 3.1.4 and Android Emulator to the latest version, it worked.
Seting default settings for problem device from Android Device Manager resolved issue for me.

Android Studio 2.0 launch APK on another device

Since Android Studio 2.0 and its reworked "build / run" mechanism, I can't "launch" an APK on a second device anymore. Once the APK has been loaded on the first device, I can't choose to launch a build to another device.
"Run" will target the current device
"Re-run" will stop the application running on the current device and upload it to the "second" device.
So my question is : "How can I launch a "second" build targeting a different device than the first device I builded on without terminating the first process ?"
Sorry for my bad english, this is not my native language.
If you click the stop button (Red Square), the Instant Run is deactivated. Then click the Run button the list of devices appears again.
The drawback is that when you click on the stop button the application is killed on the current running device.
We need a way or a shortcut to bypass Instant Run
Disconnect the device, click on the "play" button. Android Studio ask you now where to run the app.
Connect your device and select it.
On of the helpful method I found through which at-least you don't have to disconnect your already connected device to run the app on another device.
Click on the arrow down icon near to run option and select Edit Configuration.
It will open Run/Debug configuration dialog box, uncheck the checkbox "Use same device for future launches".
Next time when you will hit the run button, Android Studio will ask you to select the device.
When you deploy to your first device, make sure you have not selected to launch on the same device for future launches. Untick in your case.
Should you have already had this option on, and it is running on the same device, then unplug the device it is launching on, or turn off the emulator.. and it will ask you which device you now want to launch on.

Android Studio won't run application from studio ide?

I've got an application I've been working on and am having an issue with android studio. When I click "build->run" and then select my device, the application never runs on my phone (and the log in android-studio that automatically comes up does not have anything, whereas in the past when I have used this feature it usually says something like, "waiting for phone..." and then the application pops up and automatically opens on the phone and you get some other pertinent information). I have the phone already in developer mode with the install from unknown sources set to on. When I manually move the application from its gradle build location to the phone and then install it manually in file explorer, all is well and the application performs as expected. As I need to debug, however, this is not a very viable solution. Anybody have any advice as to how to get it to run from the IDE? I have tried rebuilding and invalidating the cache/restarting android studio, to no avail.
When I click the run tab at the bottom I have an empty window. When I click the debug tab, I see:
Waiting for device.
Target device: samsung-samsung_sm_g920a-randomIntegerId
Uploading file
local path: /home/eric/Documents/class/OOSE/final_project/2015-group-17/project_code/android/Place2B/app/build/outputs/apk/app-debug.apk
remote path: /data/local/tmp/oose2017.myApp
Note: I am building the application on a LUbuntu 15.04 VM on a windows 8 host, and am using the latest version of android studio.
EDIT: gradle console indicates a successful build as well (obviously since moving the .apk manually to the device works properly).
Open 'Run->Edit Configurations...', and look for your app module in the column on the left-hand side.
Select it, then go to the 'General' tab.
Under the 'Activity' section, there are a couple of radio buttons. Make sure that 'Launch default activity' is selected.

Issue with geny motion in android studio. can't get Virtual device to appear in AVD manager

first I create Motorola moto X vitual device tageting API 4.2.2 in android. this device was created successfully in geny motion. I then run this virtual device to see if it is operating correctly. Once started I keep getting this error message regardless of what i do
"Genymotion version and virtual device version do not match
Genmotion 2.2.2
Virtual Device 1.0.0
you should update you virtual device or create a new one to enjoy the new features"???
I dont have a clue how to update the virtual device? moreover I wasn't given the option to set the device when creating the device. just to choose target version of android. Can anybody guide me through how to do this? Also the UPDATE button cant be selected so i have to just select continue.
After this I change settings/ADB on the virtual device to point to the android sdk located at "C:/Program Files (x86)/Android/android-studio/sdk".
then I app the genymotion plugin to the list of plugins in settings. and following this I add the path location of the genymotion folder also in settings under IDE settings/ Genymotion and the path being "C:\Program Files\Genymobile\Genymotion"
When I open AVD manager the genymotion emulator is not visible so I cant select it to run my applications. I have tried setting "show chooser Dialog" in Run/debug configuration and also setting the correct sdk for the virtual device like I said earlier. If anyone can help me out with this I would be grateful otherwise It looks like i will have to use the standard emulator which is SH*t :) .hopefully this question can help someone in the future also. thanks in advance!
It seems your virtual device is very old.
If you use the free license you need to remove this old device and create a new one thanks to the "add" button on the Genymotion program.
Then launch the newly created virtual device, you should not see the Genymotion version and virtual device version do not match popup any more.
If it still chows up, send a report to the Genymotion support.
Concerning the AVD manager problem. Genymotion devices are not supposed to be added to this interface. To launch a Genymotion virtual device you can whether:
Open the Eclipse Genymotion plugin you already installed and configure (the small pink genymotion icon on the tool bar)
Or open the Genymotion program that will show you all the devices you already created. And where you can create new virtual devices.
When a device is launched, you can then debug on it easily, it is considered as any device connected to ADB like a physical device you plug on your computer.
One of the craziest tricks I've seen work (I know it sounds crazy but try it) is to stretch the columns in the device column when you go to run and it shows you no devices, device magically appears in list.

Resources