"Device is offline" after succesfully installing APK - android

When trying to debug my app, the installation of the APK works fine, but starting the debugger, gives the error "Device is offline":
01/17 15:56:08: Launching app
$ adb push /home/bf/Projects/.../app-full-debug.apk /data/local/tmp/nl.my.app
$ adb shell pm install -t -r "/data/local/tmp/nl.my.app"
Success
APK installed in 3 s 918 ms
$ adb shell am start -n "nl.my.app/nl.my.app.activities.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Device is offline
I tried updating the SDK, to no avail. Running the same app on another device works fine.
Also, when launching (in the "Select Deployment Target" screen), it doesn't give me any information, only serial number and [null], while I get full info on other devices (make and model, etc)

I didn't resolve the issue itself, but using TCP/IP debugging did work:
~$ adb tcpip 5555
~$ adb connect <ipaddr>:5555
the device is now shown with all information in the "Select Deployment Target" screen as well.

Related

Check if headless android emulator is running

I am running a headless emulator (Android api 25) on a Ubuntu linux 14 server and I see the below output for the command-
$./adb devices
List of devices attached
emulator-5556 device
However, If i try to run any other command I get error
$./adb shell dumpsys deviceidle get deep
Can't find service: deviceidle
$./adb shell 'pm list packages -f'
Error: Could not access the Package Manager. Is the system running?
How can i verify that my emulator is functional?
is adb devices -l not working? it should show you the status of the device as well
try adb push, for eg
adb push foo.txt /sdcard/foo.txt
or adb install for eg
adb -s emulator-5556 install apkname.apk
these commands will work with any running emulator/device
all these commands are available on the documentation

$ adb shell am start -n "" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Client not ready yet

So, i just updated my Android Studio from 1.5.1 to 2.1 Preview 1 thru canary channel . Now when i was trying to run my app on my device then i had to face these errors.
03/16 18:40:12: Launching app
$ adb push D:\Workspace\MyApplication\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.shienh.myapplication
$ adb shell pm install -r "/data/local/tmp/com.shienh.myapplication"
Segmentation fault
$ adb shell am start -n "com.shienh.myapplication/com.shienh.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..
What could be the reason for such an error.
And yes, app was not installed on device.
I don't know why it's not working, it's not depends on Android Studio version. Maybe did you make any mispelling? Make sure that grammar of this command is correct.
For pushing app on device, unistalling it or clearing user data consider to use this IntelliJ/Android Studio plugin:
https://github.com/pbreault/adb-idea
It gives you direct access to pimary adb commands, like in an image below:
Just in your IDE choose File -> Settings -> Plugins -> Install from repository(second option)
Search for ADB IDEA and install the plugin.
Hope it help

Android Studio Error: Adb refused a command

I just changed my PC, and now I have a problem with Android Studio, every time i try to run or compile an app it install it correctly, but then it cannot start the main activity of the app, if you need it this is the full Android studio output:
Waiting for device.
Target device: samsung-gt_i9000-3733E37B1ACB00EC
Uploading file
local path: C:\Users\Federico\swagmasta\TurnarioConapo1.0\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/feddycapdev.conapo.turnario
Installing feddycapdev.conapo.turnario
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/feddycapdev.conapo.turnario"
pkg: /data/local/tmp/feddycapdev.conapo.turnario
Launching application: feddycapdev.conapo.turnario/feddycapdev.conapo.turnario.MainActivity.
DEVICE SHELL COMMAND: am start -D -n "feddycapdev.conapo.turnario/feddycapdev.conapo.turnario.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error: Adb refused a command
I tried to manually run am start -D -n "feddycapdev.conapo.turnario/feddycapdev.conapo.turnario.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER from the adb shell, and it work correctly, some ideas on how could i fix it?
UPDATE : I tried running as admin, rebooting PC, reconnecting cable, killing all the adb.exe processes, killing the adb server and restarting it, noone of this worked.
Maybe it's a problem of driver? I'm using a Samsung Galaxy S for debugging, at the beginning the PC didn't recognized it, so I installed samsung USB driver, so maybe that's the real problem, but if i can install app to my device via adb the driver should be working right?
Please kill and start adb server from console or terminal using following commands:
adb kill-server
adb start-server
If it does not help try to restart your computer.
If you are getting
adb command not found
error then you have to go in platform-tools directory in Android SDK.
hope it helps!
It could be blocked by some other instance of adb.
Look into your task manager if you are not running another instance of adb.

adb and multiple device simultaneously

I am automating some test on android devices.
I am using Jenkins in order to run the tests (via jobs)
each job runs with a 95% success rate when only 1 device is connected to the machine
but when I plug 2 android devices or more, it seems adb has some trouble and I get a 5% success rate.
is it ok to run multiple instances of adb command?
here is the command I run for each job:
adb -s DEVICESERIAL shell am force-stop com.myapp.test
adb -s DEVICESERIAL shell am force-stop com.myapp
adb -s DEVICESERIAL uninstall com.myapp adb -s DEVICESERIAL uninstall com.myapp.test
adb -s DEVICESERIAL install -r com.myapp adb -s DEVICESERIAL install -r com.myapp.test
adb -s DEVICESERIAL shell am instrument -w TESTNAME/android.test.InstrumentationTestRunner
adb -s DEVICESERIAL logcat -d -v time
all command run with success but when the test starts and when I have multiple devices connected i get errors like for example:
- Unable to find instrumentation target package
- INSTRUMENTATION_STATUS_CODE: 0
- Failure [INSTALL_FAILED_INVALID_URI]
at first I thought the test apk was not installed correctly, but when trying manually after the failure, it worked fine (so the test file is installed)
again. Using 1 device only, everything is stable.
Is there something special to do in order to install and run the test on different devices simultaneously?
note that I have tried different usb ports, different cables etc...
thanks

How do you connect your terminal with the Android emulator

I have tried the navigate to the android tool folder and entering the "adb shell" command but it doesn't seem to work. My terminal seems only to recognize the adb part of the command and gives me an error message. What am I doing wrong???
List all connected devices by typing adb devices
Check, if there are any devices listed. If not you may want to check that your device is connected and/or your emulator is running.
If it works and you have for example your emulator running and your usb-device connected use:
adb shell if you only have device connected.
adb -d shell to connect to an USB-Device.
adb -e shell to connect to an emulated device.
If you have more than one emulator or usb devices you might want to use:
adb -s <DEVICE> shell
Note:
Make sure that the path to the android-sdk is properly set-up in your environment. To quickcheck, fire up a shell and type adb version. If that command succeeds, you're set up. If not, add /path/to/android-sdk/tools and /path/to/android/platform-tools to your $PATH env variable. On windows the android sdk is typically located in C:\Users\<username>\AppData\Local\Android\sdk.

Categories

Resources