Android studio: debug application on device - java

I have difficulties with with debugging at Android Studio. After trying to launch application in debug mode device show alert with "Waiting For Debugger" title that never disappear. Also I have android:debuggable="true" in my manifest file and seems like device connected correctly, because I can simply run my application without any problem. What I'm doing wrong?

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.
Then try in this way:
1 - close Android Studio and any other IDE you have opened (maybe you have Eclipse also running?) and emulator instances;
2 - 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;

also try restarting the device - that worked for me when I had the same issue

I have similar issue (running Android Studio on Ubuntu)
What I do:
Close Android Studio (and Emulator(s) if running)
Go to adb folder (/wherever_location_is/sdk/platform-tools) and run command:
./adb kill-server
Open Android Studio.
Now Logcat messages appear again.

Remove those lines related to debugging. When you launch an application from Android Studio it is signed with a debug key. Any debugging information you need can be viewed in logcat from Android Studio. Also make sure you are running the latest version (help -> check for updates) I think that's where its at.

I'm struggling with similar issue every day and as restarting the studio or the device is pretty time consuming (and sometimes even does not work), I was trying many things and by coincidence I found an awkward (but working) solution.
When you are in the situation when you hit debug button in Android Studio, the studio says it's connected and the device says: Waiting for Debugger, but the device waits forever, do this:
In Android Studio, hit the 'Edit Configurations' pop-up button
Once the Run/Debug Configurations dialog opens, the debug process starts!
Works like a miracle!

Try this way - it works for me:
open
Run
run/debug configuration
Android app
app
Debugger
Debug type
set Auto

I had the same problem when i enabled the Proguard for debug!, Please disable it and try !!!

I think this might help. After launching application, click on Run and find Attach Debugger to Android Process
[

Check in gradle. if you apply proguard for debug then dubugging process not applicable to app.Make sure minifyEnabled false in debug.

Related

INSTALL_FAILED_SHARED_USER_INCOMPATIBLE android [duplicate]

I am working on Android application which will share the database. For that, I'm using android:sharedUserId in both application's Manifest file. When I am trying to run the application after adding that sharedUserId it shows me following errors in console.
[2013-03-04 19:37:32 - MainActivity] Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
[2013-03-04 19:37:32 - MainActivity] Please check logcat output for more details.
[2013-03-04 19:37:32 - MainActivity] Launch canceled!
Please help me to resolve this problem.
Follow these steps to fix the INSTALL_FAILED_SHARED_USER_INCOMPATIBLE error:
Remove the existing application (if it was already installed)
Remove the sharedUserId from AndroidManifest.xml
Rebuild the application
Reenter the sharedUserId to AndroidManifest.xml
Rebuild the application (one more time)
This means something about your app was not correctly uninstalled. This steps help to force uninstall from internal commands:
Connect your phone to PC with usb
From your shell launch:
$ adb shell
shell#android:/ $ su
shell#android:/ # pm list packages | grep <part of package>
package:com.android.providers.applications
package:com.android.providers.calendar
package:com.android.providers.contacts
package:com.android.providers.downloads
...
shell#android:/ # pm uninstall <package>
shell#android:/ # exit
shell#android:/ $ exit
$
Basically, you log into android shell, become superuser, find problematic packages, and uninstall it
In my case, the two app was signed with differents signatures. Using the same signature fix my problem
The solution for me was to select the "Build > Clean Project" menu option. It took a long time but the application deployed once it was complete.
Although you have accepted answer, I also want talk my situation which I met this error. My project is a Launcher which just happen to use some system grant like, Manifest.xml have two item:
<uses-permission android:name="android.permission.STATUS_BAR" />
or
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
and console log out:
Error using StatusBarManagerService - java.lang.SecurityException on android.permission.STATUS_BAR
Lastly, my colleague give me a hint using "platform debug key", I am not sure this will be suitable for you, but for another guys possibility for this kind question.
The below picture is my solution:
screenshot from project structure
you might also notice 'Signing Config' of "Flavors" and "Build Types", you might choose 'Name:' of "Signing".
Simply delete the existing application from mobile and reinstall using run.
my issue was having a second instance of the app installed via Samsung Secure Folder! One I uninstalled it there too, my issue went away.
In my case, I had two build variants (one specific for a device, and one general).
I was running the device-specific build on an emulator when this error showed up.
I did a slightly different approach.
My work involves using a modified Android OS along with a modified adb tool. The app (app1) I am working on "shares a user" with another app (app2) by another team. In order for me to get the Android Studio debugger to work, I had to follow these steps in order:
use the Build (from Android Studio Menu) -> Generate Signed APK
build a debug version of apk (app1) with the key store information used by (app1 and app2)
use adb to uninstall the previous apk
use adb to install the signed debug-apk
use adb to launch the app in debug mode
connect the Android Studio debugger to the app
I have encountered the same problem. I tried out everything, but unfortunately, nothing works for me. As it's a testing device no hesitated to do a factory reset. Oops. sucks didn't work either. Invalidate Cache/ Restart did the trick eventually. Looks like it's an Android Studio 3.5 bug.
Thanks.
I was using Emulator and the solution for me was to select the "AVD Manager" and Wipe all data from my Emulator device. After that application was installed.

How do I fix "Could not connect to remote process" while trying to debug the application?

I am making a android studio project and I try to debug my application.
Running the application works fine, but when I try to debug it I get this error:
Could not connect to remote process. Aborting debug session.
What can I do to fix the issue?
You need to restart the ADB.
kill adb.exe process.
how to restart ADB manually from Android Studio
Sometimes this happens when two Android-capable IDEs are opened, e.g. Android Studio and IDEA. Shutdown one of the two (or disable Android plugin in IDEA) helps.
In My case,
For some reason I disabled Instant run and it has changed the Launch value from "Default Activity" to "Nothing" in "Run/Debug configurations". So always it says "Could not connect to remote process. Aborting debug session" and I was not able to debug. I enabled Instant and changed the Launch value from "Nothing" to "Default Activity" in "Run/Debug configurations" and it worked. Hope this will help some one.
(to get Run/Debug configurations, click "app" drop down and click Edit Configurations)
Check if you have selected the right Build Variant, usually "release" comes with debuggable false
Example:
buildTypes {
release {
debuggable false
....
}
}
is not recommendable change release to debuggable true, just change the right variant
debug {
debuggable true
....
}
Verify on AndroidManifest that your LAUNCHER activity has:
android:exported="true"
I try invalidate cache / restart and it's work
In command line :
adb kill-server && adb start-server
This command will restart ADB
+1 to Kuzneц's answer.
When Intellij and Android Studio are both open, apparently the Android plugin in Intellij needs to be disabled. This wasn't always the case but it resolve the issue for me.
Mac OSX 12.2.1
IntelliJ 2021.3.1
Android Studio 2021.1.1 Patch 2
By default Android Studio builds the debug version of the application. However, during the publishing phase you may have switched to the release one as the tutorial suggests.
ADB won't be able to attach to the application unless you revert to the debug configuration or you allow to the debug the release one.
If nothing of this works, you may resort in restarting ADB as explianed in How to restart ADB manually from Android Studio
Revert to debug configuration
Choose Build->Select Build Variant
Pick up debug in the second column
Deploy the application again
Allow the release version to be debugged
Select your application node in the tree
Right click and choose Open Module Settings (or hit F4)
Select Build Variants on the left
Choose release on the right
Set debuggable to true
Apply and deploy the application
Keep in mind that your life won't be easy as your application may be optimized and therefore not debugger friendly (e.g. you might not be able to step in certain methods, or view some local variables).
Restarted the ABD server. First the device had to be connected. Look for the "Assistant" tab in android studio (on the right side it usually is), and press next until you see the option to reset the ABD server.
I did
--->adb kill-server && adb start-server
--->invalidate cache / restart
but not work yet
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Waiting for application to come online: com.example.distribution_system | com.example.distribution_system.test
Could not connect to remote process. Aborting debug session.
image1:--> [1]: https://i.stack.imgur.com/HZF5D.png
image2:--> [2]: https://i.stack.imgur.com/hrE4a.png
I got this error message when the phone was connected both via wi-fi (using "adb tcpip 5555" and "adb connect 192.168.0.100:5555" commands) and via a usb cable. Disconnecting the USB cable resolved the issue.
The other solutions posted here did not help me. I eventually discovered that creating a new simulator instance (tools->AVD Manager->Create virtual device) solved my problem. I was unable to get the previous simulator working again.
I followed all the recommendations above, but the problem was solved only after I used the Generate Signed Bundle and selected the desired flavor
For me the problem was a wrong launch flag set in the Run/Debug Configurations. I found out about this by taking the adb command that is executed to launch the app, which can be found in the "Run" tab. The command looks like this:
adb shell am start -n "com.your.package...." -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
By executing the command manually in the terminal, i got an error message which pointed me to the problem.
All solution didn't fix my issue, If you face it same me try that solution
enter link description here

Error while starting ADB in Eclipse

This is certainly a repeated question, I have seen and tried many answers. When I try to deploy an android application, I am getting error as -
------------------------------
Android Launch!
The connection to adb is down, and a severe error has occured.
You must restart adb and Eclipse.
Please ensure that adb is correctly located at 'D:\Android SDK 22.6.2\sdk\platform-tools\adb.exe' and can be executed.
I tried -
adb kill-server
restart eclipse
adb start-server
Checked adb is located in platform-tools and same path is updated in eclipse SDK location also
Started adb.exe from cmd to run adb devices where I can see my devices (they are offline)
Went to windows task manager and killed adb.exe process and restarted eclipse again.
Even after all these steps, I am unable to start adb from eclipse. In run configurations also, I have launch configuration with actual package name.
I can start the Emulator separately from ADB Devices dialog in eclipse, but the device is always offline. I am not sure where I am going wrong in this part. Can any one please help me out of this?
Please let me know in case of any additional details required.
Finally, after installing Android Studio, the problem was solved. Thanks #An-driod

I am getting this error in android studio while running my app

ADB not responding. If you'd like to retry, then please manually kill "adb.exe" and click 'Restart'
I have been getting this error for a while now and its really bugging me. every time I hook up my phone and try to run my app, this error pops up.
I am new to android studio and I was doing my first ever project in it. I looked around a bit on the internet and found out to go to task manager and kill adb server but it did not help. If anyone can help me I would really appreciate it.
I often run this batch file to get my ADB connection to work:
rem kill/start server
Set ADBPath=D:\AndroidDevelopment\adt-bundle-windows-x86-20130522\sdk\platform-tools\
#REM set ADB_TRACE=1
%ADBPath%adb devices
%AdBPath%adb.exe kill-server
%AdBPath%adb start-server
MORE

Adb connection Error:EOF (new in android )

and trying to make a project in which my app will be connected to the database and will fetch the required values as I command it to do.
I just made the designing part and tried to run it and see it.
But its giving an error: Adb connection Error:EOF
please help me to solve it
My Android Console shows:
[2014-01-14 12:30:33 - Emulator] error libGL.so: cannot open shared object file: No such file or directory
[2014-01-14 12:30:33 - Emulator] Failed to load libGL.so
[2014-01-14 12:30:33 - Emulator] error libGL.so: cannot open shared object file: No such file or directory
Well you could try this out:
Open your cmd .Go to Platform-tools/ path
Run the cmd like : adb kill-server
Then : adb start-server
Restart the Eclipse
Also Delete the AVD and Create the New One if above don't Work
Hope this could help...
ok, i have seen all people answer such question under eclipse, but actually i met it in android studio. Here is my working out step:
open android device monitor and watch system output, error like above
open the terminal button in android studio where you can find it in left bottom and click the button then find the terminal.
adb kill-server
adb devices(here is the success status output)
daemon not running. starting it now on port 5037 *
daemon started successfully *
Attention:if you do such behavior in your mac terminal or windows cmd.it's useless, i have tried that way and restart android studio finally failed.
Please setting up the development mode for your test-device-phone .if it is not work, your could try restart your eclipse
simply go to your cmd terminal and type.
adb kill-server
adb start-server
and then rebuild your project

Categories