i connect android studio to my phone via usb.
my android project will be work correctly when i debug it.
but when I'm clicking on apk file for installing it quickly stops and
i will receive "unfortunately has stopped" .
and there is no issue on logcat.
If you have the same project syncd on your android studio with same package name on your Android phone you will be able to debug it.
Be careful that this DOES NOT guarantee that you have the same code version on your IDE and in your device.
and there is no issue on logcat
This is highly unlikely.
Please, proceed with these comands on your prompt/bash/terminal:
adb kill-server
adb start-server
adb logcat -c
adb logcat (and press "play" button)
See logs.
Related
I'm working on a project for my Android class using the latest version of Android Studio (3.4.1) and my app isn't working right. I can't see what's going wrong because nothing shows up in the Logcat.
I'm running my app on a physical phone since Android Studio doesn't like AMD. I have "Show only selected application" selected and it shows my phone is connected. I tried restarting Logcat, but that didn't do anything.
screenshot to show my issue
Just try ,Invalidate and Restart Android Studio or Restart Android Studio.
Keep the device connected. Open terminal from below. Type following command to kill and start adb.
adb kill-server && sudo adb start-server
If the command doesn't work, you will need to fire it from /sdk/platform tools/
Android studio giving error
"com.android.ddmlib.AdbCommandRejectedException: device offline
Error while Installing APK" even though android device is connected.
I tried by adb kill-server and adb start-server but after this kill and start process first time code runs properly but second time again gives the same error.
Please If anyone knows the solution share , Thank you.
WhenI run a project in android studio, I get this error - I/O Error: Connection refused
The emulator starts fine but doesn't pull in/reflect my project
Device connected: emulator-5554
Device is online: emulator-5554
Target device: Nexus4 [emulator-5554]
Uploading file
local path: /Users/martinsjolte/AndroidStudioProjects/FirstAPP1/Firstapp1/build/apk/Firstapp1-debug-unaligned.apk
remote path: /data/local/tmp/dk.first.Firstapp1
Installing dk.first.Firstapp1
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/dk.first.Firstapp1"
Device disconnected: emulator-5554
Launching application: dk.first.Firstapp1/dk.first.Firstapp1.MainActivity.
DEVICE SHELL COMMAND: am start -n "dk.first.Firstapp1/dk.first.Firstapp1.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
I/O Error: Connection refused
My platform is a mac osx ver.12.9.1
Ok, I don't know if i got "the" answer. but here is how I've solved the same issue on my environnement ( Windows 8/Android Studio, but same error with ADT or eclipse) :
Context of my issues :
I've got an Asus PC, and with all the application suite installed by default.
So I've found that one of this Asus app ( currently "Asus sync") was using adb and in fact, it was taking control of the emulator over my adb in the AndroidSDK directory.
How to fix as a PC user :
Go to Task manager ( right click on task bar) , and look for "adb.exe" . Then right click on it and select "Open the directory". This will bring you to the responding adb. In my case it was Asus Sync, so I just had to unistall this software and everything works fine !
How to fix as a Mac user :
Go to Activity Monitor (/Applications/Utilities/), and look for "adb". Then try to kill the process. Then look if it solve your "Connection refused" in Android studio/ADT or eclipse
If still not working you can try :
Start a emulator ( with your AVD manager)
when finished loading, Open DDMS panel (in android studio : Menu Tools > Android > Monitors DDMS)
Look if you see your current running android emulator ( listed on the Device panel)
See if this line is kind of "flashing" ( connect/disconnect).
If so, you have probably a other adb instance running in conflict
If not, you can restart adb or reinstall your SDK
Hope this could help someone !
This issue occurs when Android Debug Bridge aka ADB is not responding to the request from Android Studio. I killed the process adb.exe and started it again. This solved my problem.
If you are using a real device :
Just reconnect your device, make sure your cable are workable and you installed the proper drivers.
I had the same problem, and my problem fixed by restarting the android-studio. Hope, that will help you too.
For me the following worked(after I tried the above points mentioned by others):
I tried debugging/running anther application. It was okay. So this pointed me to the direction that the current application has some problem
if (point 1 == true) {I uninstalled the application from my phone manually }
Then re-make/rebuild the application and debug/run worked
My Phonegap app refuses to load onto my Android device (even the HellowWorld default app is refusing to load)
Everything was running just great until today.
Here's my console log:
***\>adb devices
List of devices attached
4c05609b device
***\>phonegap run --device -V android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Compiling app on platform "android" via command "cmd" /c ***\platforms\android\cordova\build
[phonegap] Platform "android" compiled successfully.
[phonegap] successfully compiled Android app
[phonegap] installing app onto device
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Running app on platform "android" via command "cmd" /c ***\platforms\android\cordova\run --device
It just sits there saying running... forever.
I have another terminal window open with adb logcat running and at some point (maybe 10-15 seconds into that last line getting printed) it stops logging. Termination of the process and subsequent calls to adb logcat result in more hanging (no logging at all)
So then I have to do a kill-server, start-server to break out of this endless hanging at which point the phonegap process terminates with:
[error] An error occurred while running the android project.
***\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
ERROR: Failed to launch application on device: ERROR: Failed to install apk to d
evice: Error executing "adb -s 4c05609b install -r "***\platforms\android\bin\Po
ached-debug-unaligned.apk"": protocol failure
I have tried::
deleting my .cordova folder in C:\Users\Name
running the adb install directly (without phonegap)
deploying to an emulator (same problem)
unplugging / replugging the device
rebooting all devices
toggling "developer mode" on the device and revoking USB debugging privileges
I am all out of ideas!
Would greatly appreciate any tips or leads.
ADB version 1.0.31
Galaxy S3 running Android v4.3
EDIT:
Deploying to an emulator claims to complete successfully, but the app never opens and does not appear in the app list inside the emulator. So I have no way of actually testing it on the emulator either.
Would really appreciate some assistance.
EDIT 2:
After some further tinkering I've discovered my issue can be more specifically described as ADB hangs (freezes) when I attempt to talk to my device. I've determined this because adb shell, adb install, and adb push all fail the same way as described above. No error, just finite waiting.
adb logcat, adb devices, and other read functions work perfectly fine until one of the aforementioned write functions hangs in which case I need to do a adb kill-server or TASKKILL to get adb logcat working again.
Not sure if this added information helps, but there you go. The last thing I haven't yet tried is to do a factory reset on my phone as suggested by this fellow. If I can't find a solution soon I will back up my data as best I can and attempt this...
Please save me before this becomes my last option!
In case this helps others I had a problem with similar symptoms. ADB install -r "apk path" would hang indefinitely.
I troubleshooted a myriad of things and identified that it was my USB cable length.
I have an USB extender cable as that I plug my devices into. The combined length of my device's cable and the USB extender cable caused this issue. Removing the extension cable fix the issue and eventually I replaced my USB extender cable with a shorter extension cable for the final solution.
The issues seems to resolve itself randomly. As others suggested, an arbitrary combination of ADB kill-server, restarting the device, and re-installing SDKs seems to alleviate the problem (even if only for a couple pushes).
I still have no idea what causes this hanging and, though superstitiously believe the arbitrary combination described above fixes it, am unsure how to permanently resolve it.
To future people reading this, until a solid explanation is given my only advice is to square away an hour or so to restart / rebuild your dev environment... and make sure you buy a durable stress ball.
Shot in the dark here, but some more things to try:
Are you on a work PC or something? Make sure you have USB write permissions. Also, try different USB ports and cables. You have the latest USB driver for your devices right?
Try updating the SDK tools. Or maybe something got corrupted and a re-install might do the trick.
You have free space on your devices right?
Unknown sources is checked on both devices?
What version of Android are you targeting?
Do try restart the device like other suggested. From my experience, kill the adb process, then run the cordova run command helps magically sometimes.
In my case adb seemed to hang, but in fact the data transfer from Mac to emulator was really slow:
$ adb push platforms/android/build/outputs/apk/android-debug.apk /data/local/tmp/
150 KB/s (15587200 bytes in 101.223s)
It's a lot faster on USB connected real device. Don't know why...
Had the same (original) issue (with cordova / testing on an old device) ie. hang during install.
Tried running adb install directly from cmd line ...
adb [-s <deviceID>] install <apk>
...and same issue so not cordova specific....
Opened android device monitor (ADM) ...
..sdk\tools>monitor
..and ran install from cmd line again and saw logcat message saying package was sdk 16 / device was 15...doh!
So went back to AndroidManifest.xml and changed android:minSdkVersion to 15 and all back to normal again - install worked fine.
( Issue arose because I had installed something else which had changed the minSdkVersion and then removed the something else and never reset the minSdkVersion )
So, possibly device sdk / android version is too low for your build. If not, a look at the ADM logcat output as you initiate the install from the command line might indicate what the issue is.
Unplugging and plugging device again usually helps.
This is pretty simple: I'm using NetBeans on Linux with Android emulator 1.6. I have Logcat on my android phone, but the process of getting the messages to somewhere readable isn't smooth at all.
Can someone tell me how to get Logcat running on the emulator? Is there anything I can do to see debug messages other then having to copy the apk to my phone and testing it?
Thanks in advance!
You have a few options for viewing the debug log output, assuming you have the SDK installed and your command path set up correctly:
Type adb logcat. The log output from the connected device or running emulator will appear. I usually prefer adb logcat -v time to see the time stamps.
Type ddms. This launches the stand-alone version of DDMS. It has a logcat display at the bottom.
Install the ADT extension for Eclipse, and open the logcat view. (Since you're using NetBeans I assume this isn't what you want to do, but I'm mentioning it for completeness.)
In all cases, the interaction is the same whether you're using a physical device or software emulator, because the ADB daemon conceals the details. Whatever you're doing for the device is also expected to work for the emulator.
If you have a device and emulator connected simultaneously, you can use adb -e logcat for the emulator and adb -d logcat for the device. From stand-alone DDMS or Eclipse, just pick the device or emulator from the pop-up menu.
If you have setup nbandroid you can find the adb logcat viewer in netbeans under:
Window -> Output -> ADB Log
--edit
Just followed up on the post above and started using C:\Program Files (x86)\Android\android-sdk-windows\tools\ddms which is alot better then the one in netbeans.
The SDK comes with a handy tool called ddms it should be in the tools folder of the SDK.
At the moment an Emulator is running, or a mobile phone is connected to your machine it should show up in ddms and you can see all the log output in ddms.