I have rooted my NexusOne. I can get 'adb shell and su'.
But when I deploy and run my android app on NexusOne and start my application. Under DDMS (connected to the phone of course), I DO NOT see my application. I see some apps but not mine.
How can I make my application visible under DDMS so that I can debug my application using eclipse on a rooted NexusOne?
Thank you.
Since you can see some apps but not yours, I assume you have adb working and your phone configured properly.
The next thing you'd need to check is to make sure that the "debuggable" flag is set in your application manifest. In AndroidManifest.xml, add android:debuggable="true" to the element.
See the official docs for more. You do not need a rooted device to debug apps.
On ubuntu I have to run the following commands for adb to properly recognise my devices:
cd <android sdk root >/tools/ (or platform-tools/ for newer SDK's)
sudo ./adb kill-server
sudo ./adb devices
This then gives adb the right permissions to access the devices.
Then in Eclipse looking in the DDMS perspective, you select the device you want to debug (on the left) and then look in logcat (not the terminal) to see the log.
Not a solution but useful to know, Log Collector is a free app on the market which sends logs to any e-mail address and is often useful for debugging.
Related
Im trying to run an application on my GS5 from android studio and Im getting this:
Waiting for device.
Target device: samsung-sm_g900v-f3af9744
Uploading file
local path: D:\Android\Projects\TestProject\build\outputs\apk\TestProject-debug.apk
remote path: /data/local/tmp/com.brian.testproject
Installing com.datascan.mobilescripts
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.brian.testproject"
Aborted
It seems to be copying the file to the device, I can see it in the /data/local/tmp directory. Its just failing at the "pm install" stage.
On the phone I turned on USB Debugging and authorized the computer. Here is what I get when I run ADB devices:
D:\Android\sdk\platform-tools>adb devices
List of devices attached
f3af9744 device
So that seems to be correct. Im not really sure what the problem is. Google search on the problem didnt give me any relevant results.
Does anyone know how to get more information beyond "Aborted"? Any help is appreciated, Thanks!
EDIT:
As suggested by #AlexP. I ran "adb logcat -d -s PackageManager:*", this was the result:
D:\Android\sdk\platform-tools>adb logcat -d -s PackageManager:*
--------- beginning of main
--------- beginning of system
Not much help, but I did decide to watch the logcat as the pm install was being run and I found this error entry:
Tag=appproc | Text= ERROR: Could not find class 'com.android.commands.pm.Pm'
Tag=art | Text= art.runtime/thread.cc:1105] No pending exeption expected: java.lang.ClassNotFoundException: Didn't find class "com.android.commands.pm.Pm" on path: DexPathList[[zip file "/system/framework/pm.jar"],nativeLibraryDirectories=]/vendor/lib, /system/lib]]
Followed by a whole slew of art error entries.
So it seems as though my phone is missing something, maybe?
The reason that Android Studio fails on Galaxy S5 is because the adbd (ADB service on the phone not your PC), on rooted version of this phone does not run as root, which is a security measure. You can verify this by manually trying to execute the Android Studio apk and execute commands on the device and finding out that they are failing to execute, but retrying them using "su ..." and see that the app installs and starts on the device. There are three options to resolve this and unblock Android Studio:
Options:
Flash a ROM that includes the modification - not desired as from my understanding you would like to stay on the stock image; also a good security measure not to have adbd running as root all the time. Older roms fall in this category as well, but then you are missing Stock Rom updates and security patches.
Create a custom boot.img and flash it to your phone - this is basically a custom kernel and not desired for a similar reasons than above option 1.
Restart adbd on your device with root privileges when doing app development - preferred and achievable fairly easy thru various methods including:
Preferred Solution:
a. Restart adbd with root privileges (insecure mode) by killing the service on the phone and using a terminal app or so to restart it using "su". After you are done with your app development, restart your phone and adbd will be back in secure mode, restoring the security measures.
b. Use Chainfire's ADB insecure app, which is free on XDA (download/link below) or pay for it on Google Play to support his work. You can toggle the mode in the app. In the app, you also have an option to auto re-enable the insecure mode on reboots.
References:
https://android.stackexchange.com/questions/5884/is-there-a-way-for-me-to-run-adb-shell-as-root-without-typing-in-su
http://forum.xda-developers.com/showthread.php?t=1687590 (includes free download link)
https://play.google.com/store/apps/details?id=eu.chainfire.adbd (for supporting Chainfire's work)
Possible Solutions :
1. Check if your app had left any datas :
First if the app is already installed, then clean cache data and uninstall it
Under "System Settings" then "Application Manager"
http://i.stack.imgur.com/b3oys.jpg
Then
Force uninstall by running & adb shell pm uninstall com.brian.testproject
Check "/data/data/com.brian.testproject/" and delete it
Remove any entries of your package on /data/system/packages.xml
Remove any entries of your package on /data/system/packages.list
Also you could install SDMaiD and clean your device, especially with "CorpseFinder" and "AppCleaner"
2. Try to install the app manually and debug the result :
In your case you have an issue with pm over android studio... install it manually to have a more detailed message over command line
$ adb push D:\Android\..\TestProject-debug.apk /sdcard/myapp.apk
$ adb shell pm install /sdcard/myapp.apk
3. Check Android Studio and your app sources
Change the targeted api level :
Right click on your app dir + Open Module Settings + app + check sdk version + change target and minimum under "Flavor"
Sync gradle button
Rebuild project
https://www.youtube.com/watch?v=v4b7C6Q-9dI
Update your android studio if you don't have the last release
If your app use libraries, you have to recompile them.
4. Check System Settings :
Check BOOTCLASSPATH of your init.rc. BOOTCLASSPATH must include /system/framework/ext.jar and /system/framework/framework.jar and so on.
Check DEXPREOPT_BOOT_JARS of build/core/dex_preopt.mk. DEXPREOPT_BOOT_JARS must include ext and framework and so on.
The order of all items on BOOTCLASSPATH must be equal to the order of all items on DEXPREOPT_BOOT_JARS.
5. Try pm command directly on the device :
if pm command does not work try that command with a terminal directly on the phone to see if it's a connection issue between pc and phone
pm install /sdcard/myapp.apk
6. Reinstall your rom once again (just reinstall it) no need to erase.
For anyone having this same issue, unfortunately the only solution that I could find was to downgrade my ROM version (to OA8). Once I did that, adb works perfectly. If anyone finds a better solution I'd be definitely like to know.
Android Studio
step 1: Go to file--> invalidate and restart.
step 2: Clean and rebuild project.
step 3: go to project folder run
gradle clean
step 4: restart phone/Emulator.
Done !!!
I have an Android-based phone (2.3.6) with unlocked root privileges.
Since i'd like to have access to my phone through my computer, today i've installed QtAdb and Android SDK.
If i open a command prompt and i do
adb shell su
i get
#
And so I am able to copy, remove, push files on my phone (on the phone i get a notification using the app "SuperSU".)
But if i launch QtAdb - under Windows 7 - i get the following error: "adbd cannot run as root in production builds". I miss something? There's something wrong with QtAdb?
The problem is that, even though your phone is rooted, the 'adbd' server on the phone does not use root permissions. You can try to bypass these checks or install a different adbd on your phone or install a custom kernel/distribution that includes a patched adbd.
Or, a much easier solution is to use 'adbd insecure' from chainfire which will patch your adbd on the fly. It's not permanent, so you have to run it before starting up the adb server (or else set it to run every boot). You can get the app from the google play store for a couple bucks:
https://play.google.com/store/apps/details?id=eu.chainfire.adbd&hl=en
Or you can get it for free, the author has posted a free version on xda-developers:
http://forum.xda-developers.com/showthread.php?t=1687590
Install it to your device (copy it to the device and open the apk file with a file manager), run adb insecure on the device, and finally kill the adb server on your computer:
% adb kill-server
And then restart the server and it should already be root.
For those who rooted the Android device with Magisk, you can install adb_root from https://github.com/evdenis/adb_root. Then adb root can run smoothly.
Use adb shell; su;
I still have not found any other solution for android 12 rooted with magisk. adb_root does not work with android 12. adbd insecure does not work for me and throws error could not patch adbd.
if anyone is still having issues, heres how i fixed it
you have to start the shell with the phone and go into the magisk app and in the superuser tab (bottom) you have to enable root access for the shell and it works!
You have to grant the Superuser right to the shell app (com.anroid.shell).
In my case, I use Magisk to root my phone Nexsus 6P (Oreo 8.1). So I can grant Superuser right in the Magisk Manager app, whih is in the left upper option menu.
I am using adb(Android Debug Bridge) and working with shell in the Genymotion Emulator(I have mentioned every configurations at the end of this question).
I execute "adb shell" and get the shell successfully but the problem is that I get the root access on the emulator. I don't want root shell, I want the normal one as we get when we execute 'adb shell' on the actual device connected via USB. How to achieve it ?
Any help would be highly appreciated.
*Configuration :
Ubuntu 13.10, 32-bit.
Eclipse 4.2 with ADT.
Genymotion Emulator(To be specific, I was using Android 4.3 here).
adb shell setprop service.adb.root 0
adb shell setprop ctl.restart adbd
or
adb unroot
for short.
It has been long since I posted this question but still want to answer it as it might help someone in need.
Main purpose of mine was to get a non-root shell on emulator for some testing purposes but failed to do so after many attempts.
Sometimes back, by fluke, I was fiddling around playstore app inside emulator and indirectly came across solution to above question.
I noticed while creating an emulator, if I used "Google Play" as the image, I got an emulator which was not root.
Follow below steps to get an Android emulator without root:
Create a new virtual device and select the one where "playstore" column has playstore icon (small triangle) visible, as seen in screenshot below.
In next step, download appropriate files needed for creating the device. Make sure to select the target/ABI as "Google Play" and not "Google API". It will make all the difference. In below image you can see I have 2 AVDs (Android Virtual Devices), first (andy_7) with target as "Google API" and another (nexus_5) with target as "Google Play".
Start the avd with target Google Play, nexus_5 in our case and we will get the desired result.
I'm trying to install my test app on my device, but I does not go there.
I've also prepared my phones as described here: here
1 - In eclipse I see the device with '??????????' as ID.
2 - with adb device, I get:
List of devices attached
???????????? no permissions
I edited the /etc/udev/rules.d/51-android.rules....not sure what else to do?
3 - I copies the app to my SD card and tried to installed it from there ... but at a point the installation stopped and the message was 'Application not installed'
Also! The app gets intalled on my friends phone via eclipse?
Can anybody give me a hand with this???
Thanks!
Ensure your machine is connected to the Phone device correctly..
If the error persists, you can try restarting the adb server, using following commands:
adb kill-server
adb start-server
adb devices
If the error still persists, try restarting both your development machine and phone device.
I've seen that before when the user you are running as did not have permissions. If you're using Ubuntu try running adb via sudo:
sudo adb devices
If you're using another distro either try as root, or use sudo, accordingly. (Assuming you're using Linux, and probably Ubuntu, if you're in that part of the instructions on the page you linked -- but that info in the question would help too.)
Also make sure you're using the correct vendor ID for the device you're trying to use. The instructions show 0bb4 as an example only (that will only work for certain HTC devices). You can use the lsusb command to check to make sure you're device is detected by the OS, and get the correct ID.
lsusb
Bus 002 Device 100: ID 18d1:4e12 Google Inc. Nexus One Phone (Debug)
absolutely beyond my comprehension - the device got found (recognized) after deselecting the Settings > Applications > Development > USB debugging....
:) I signed with relief ...
Thank you very much for the enthusiasm and help!
I'm trying to test an app out on the Motorola Backflip with AT&T as the carrier. I checked USB debugging on the phone's Development screen.
Using Eclipse, how do I get the app to load on the Backflip so I can test it? DDMS shows a device with a bunch of question marks and unkown. Seems that it only gives me the option to load the app on the SD card which doesn't do me any good.
I searched and found a Motorola driver which I'm supposed to install to the adb folder. Where is that folder? I've checked the phone and on my development machine. Maybe I need new glasses?
More info:
I have Run set to manual. When I click on run I get:
Choose a running Android Device:
Serial number ????????
AVD Name N/A
Target Unk
State ??
and the OK button is greyed out so all I have left is to Cancel.
Still trying:
I don't know if this helps but in DDMS the following messages show up:
[2010-03-28 19:20:41 - ddms]execute: running ls -l /
[2010-03-28 19:20:41 - ddms]Got reply 'FAIL', diag='insufficient permissions for device'
[2010-03-28 19:20:41 - ddms]execute: returning
Did what Commonwares suggested:
eric#i7Linux:~/Eclipse3.5/android-sdk-linux_86/tools> ./adb kill-server
eric#i7Linux:~/Eclipse3.5/android-sdk-linux_86/tools> ./adb kill-server
eric#i7Linux:~/Eclipse3.5/android-sdk-linux_86/tools> ./adb start-server
* daemon not running. starting it now *
* daemon started successfully *
eric#i7Linux:~/Eclipse3.5/android-sdk-linux_86/tools> ./adb devices
List of devices attached
???????????? no permissions
eric#i7Linux:~/Eclipse3.5/android-sdk-linux_86/tools>
First, try adb kill-server followed by adb start-server (or just reboot your development machine). Then, with the device plugged in, run adb devices. If your device shows up (and with a real device ID, not question marks or anything), try it again from Eclipse, or use adb install ... (where ... is the path to your APK) to install it.
Since the Backflip does not support app installs outside of the Market, there was a fair bit of public experimentation to ensure the Backflip supported adb-based installs, so I know it works in general.
If you are using Eclipse. when you run the application it should automatically set your phone as the target and push the apk to the phone and execute it. You might have to set your phone as the target instead of the emulator.
Wow. Easier than I thought and I don't know how I missed that post.
If you are running Linux (I'm running Suse 11.2 x64) go to http://developer.android.com/intl/de/guide/developing/device.html for full instructions. I created the 51-android.rules file and I was able to install the app on the Motorola Backflip to test it. (Needless to say, but I'll say it anyway, more testing required. The layout on the Backflip doesn't match the emulator)
Repeating the instructions in the link:
Login as root
go to your etc/udev/rules.d folder
create a file called 51-android.rules
I put this line in the file: SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
save the file
Instructions say to chmod a+r the 51-android.rules file but I didn't have to. Permissions should be -rw-r--r--
Eclipse now sees the phone and I can load directly to it from Eclipse.
Back to coding :-))