Android - How to load HelloWorld app onto my Phone? - android

I made an Android Hello world app and I'm trying to load it onto my HTC Incredible. I believe it has 2.2 (how do I confirm that?)
Anyway, Eclipse gives me this message and then brings up the window in the screenshot below.
Automatic Target Mode: Unable to
detect device compatibility. Please
select a target device.
I'm on Ubuntu 64bit if that matters. I did turn on USB debugging on the phone. I told the phone to connect as a disk drive.
Any ideas how to get my app onto the phone?
Update: Do I need to perform these steps since I'm on Ubuntu? I doesn't mention what to do for Ubuntu 8.10 though.

Ok, it turns out I did have to follow all the instructions from this page. (The sudo stuff mentioned in other answers above didn't help.)
Here are the exact commands I ran for Ubuntu 8.10

You need to run the adb server in superuser mode (i.e. sudo adb start-server).

Try what EboMike said, run sudu adb start-server.
To answer your question "how do I confirm my phone is V2.2?" Press your phone's menu key, then settings, about phone, software information. The Android version is the number you're looking for. This shouldn't be important though for your hello world example.
Also, it's not important that you have the phone connect as a disk drive; this causes the SD card to be dismounted. It will actually cause problems if you run or debug an application that tries to access the SD card. You can just select charge only and use ADB/Eclipse's DDMS perspective to move files to and from the phone.

Here's an update answer in case anyone finds this thread from Google.
http://dimitar.me/how-to-connect-your-android-phone-to-ubuntu-to-do-developmenttestinginstallations-or-tethering/

The easiest way to this: Go to www.dropbox.com and sign up for a free account. Copy your .apk file from your project's /bin directory to your Dropbox. Download and install the free Dropbox app from the Android Market. Navigate to your .apk file on the Dropbox app and click it to download and install on your phone.

These are the steps I took on Arch Linux to resolve the same problem:
As mentioned in some of the other replies you will need a udev rule for the device. In this example I am using an HTC Desire.
(for HTC you'll need to use "0bb4")
Get the correct Vendor and Product IDs
run lsusb with the handset plugged in and you should see something like Bus 001 Device 004: ID 0bb4:0c87 High Tech Computer Corp. Desire (debug)
'0bb4' is the Vender ID: HTC
'0c87' is the Product ID
Make a udev rule using the values you've just retrieved
Now make a udev rule as root using:
$ sudo vim /etc/udev/rules.d/51-android.rules
Add the following (this is for HTC Desire - edit accordingly):
## Rule for an HTC Desire Android Phone
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c87", MODE="0666", GROUP="users", NAME="HTC Desire"
GROUP defines which Unix group owns the device node.
At this point I rebooted and found that my handset was detected. Supposedly you can reload udev rules using the following but if this doesn't work try rebooting.
$ sudo udevadm control --reload-rules

in eclipse: go to Run menu -> Run configuration. Right click on android application on the right side and click new. Fill the corresponding details like project name under the android tab. Then under the target tab. Select launch on all compatible devices and then select active devices from the drop down list. Save the configuration and run it by either clicking run on the run button on the bottom right side of the window or close the window and run again
Cheers !

Related

Getting "error: device offline" from adb.exe in Android Player SDK / Setting Up Unity Remote 5 (Solved)

First of all, this is my first post here and I'm a beginner so my apologies if this ends up being a stupid question or my format is wrong, but any help is appreciated.
Essentially my problem is in trying to set up Unity Remote 5 for debugging in Unity. However, I believe I've finally narrowed it down. The error I'm getting now seems clear:
CommandInvokationFailure: Unity Remote requirements check failed
C:/Program Files/Unity/Hub/Editors/2019.4.17f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK\platform-tools\adb.exe forward tcp:7201 tcp:7201
stderr[ error: device offline]
stdout[]
exit code: 1
I've looked into this error and came upon this: https://stackoverflow.com/a/39031464/14948855 which seems like it might be useful to me, however the issue is I don't know how to run the commands he suggested and stack overflow made it clear it didn't want me posting a question as a response to that question and I don't have enough prestige to comment.
I'm trying to run "sudo adb kill-server" from an ubuntu linux terminal on windows from the directory abd is in (C:\Program Files\Unity\Hub\Editors\2019.4.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools), but it won't run.
proof command not found
I've tried adding it to the path on my computer: I added the directory listed above to "Path" in my "Environment Variables".
My phone is plugged in, I've disabled and reenabled developer mode and usb debugging, and restarted Unity and my phone several times. Any help with running this command in ubuntu or cmd, or even the greater problem of Unity Remote 5 would be fabulous.
Thank you.
Edit: here's a better image showing my issue:
image showing how I've tried to add the folder to the path but it still can't be reached
Final Update:
All my problems have been solved, here's how I got unity remote 5 for android working for posterity:
step 1) Make sure phone is in developper mode (go to "about phone" in settings, tap build number 7 times).
step 2) Make sure "USB debugging" is turned on in developer options.
step 3) Make sure Unity is updated to the most recent supported version through Unity Hub (might not be required but I did this step).
step 3) Download android support module through Unity Hub.
note: if you downloaded current Unity version from the Unity website rather than through Unity Hub, it doesn't seem to let you add modules to it through Unity Hub.
step 4) The sdk path Unity specifies by default is wrong for some reason, so in preferences->external tools, disable the default path and paste in the right directory (should be something like: C:\Program Files\Unity\Hub\Editors\2019.4.17f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK) to be safe I did this for the JDK, NDK and Gradle too.
step 5) When you plug in phone, pull down your notifications, hit "tap to change USB options" and make sure phone is in "camera" mode or some variation. For me it was "Photo transfer".
Note: if you don't have the option to change USB options, try different usb ports/cables, if those don't work you might have debris in your charging port, clean it out with a dab of 91% or 99% rubbing alcohol and a tooth brush/tweezers (this will also make charger sit more snug in phone)
That might be enough to get it working for you, if not...
step 6) (Not sure if necessary) May need to update phone drivers in device manager on windows.
step 7) If Unity gives an adb error saying too many devices connected, it's possible you have a daemon running in the background which adb is picking up as an android emulator because it's using a port greater than 5555. It seems adb checks open ports above port 5555, and assumes anything it finds is an emulator. To check this, as indicated in my original question, and as stated here: https://stackoverflow.com/a/39031464/14948855, in cmd on windows use adb devices (if ur on linux may need to use sudo) to get a list of all devices being detected by adb. (Also use "adb kill-server" to reset it.) If there is an emulator being detected, it should include the port it's using in its name, in my case it was "emulator-5562" in port 5562, which was apparently actually NTKDaemon from Native Instuments, a random music production program I've only used once so far. I'd suggest googling the emulator port you find to try and narrow down the process taking that port. The only thing left to do is to kill the process running in the port. I found NTKDaemon in task manager and also disabled it activating on startup because that's just evil imo.
And that should be it. Hope that works for you if you're here for help.
(btw in terms of my original question, I was able to access adb.exe by changing the directory in cmd, but I still never found why adding the directory to the path didn't work, so if anyone has an answer to that I would be interested)

ADB Install needs Root ? vs Eclipse Install?

I try to understand how this works:
When I create an android app and run it from Eclipse, Eclipse takes care of generating the apk file and uses adb to install it on the phone correct?
When I have an .apk file that I try to push on the phone and use ADB directly in a command line by calling adb install myApp.apk I can't because my phone isn't rooted?
How does Eclipse manages to install apps then?
Is there a way to install from an .apk file on a device without having it rooted ? Obviously Eclipse is able to.
Thanks for any information that may help clarifying this.
David
So the really short answer to your question; You don't need to be rooted to use ADB, all android phones can use ADB without being rooted.
Also, the only reason you would need root is to mess with things on the system level, when installing a regular app you are just installing it like a regular application (to the data partition). Eclipse installs the app using ADB actually, so pushing an app using ADB is the same as installing it through eclipse.
You don't need to be rooted to use ADB, all android phones can use ADB without being rooted. You must be rooted to push applications to /system/apps/ to make them system applications. Also if you download a file explorer like ES File Explorer to your phone, you can transfer an apk file to your phones storage and using a file explorer (I really do recommend ES File Explorer) you can install that app.
Also just a tip, to use ADB command line you must enable ADB on your phone in developer settings.
Go to the settings menu, and scroll down to "About phone." Tap it.
Scroll down to the bottom again, where you see "Build number."
Tap it seven (7) times. After the third tap, you'll see a dialog that says you're four taps away from being a developer. Keep on tapping and the developer settings will show up in the settings app. There you can turn on ADB.
Hope this helps.
Further Reading: http://developer.android.com/tools/help/adb.html
http://www.androidcentral.com/how-enable-developer-settings-android-42

Hisense Sero 7 - USB Debugging Enabled But Not Working

I recently received a Hisense Sero 7 Pro Edition (running android 4.2) for use with development. I am currently on my Linux box trying to get it setup to be used over here since I seem to have better luck with the NDK on this computer.
Aside the point, I have the vendor ID registered in adb_usb.ini and its not seeming to want to play nice with my computer. When I plug the device in it says USB debugging is enabled as well as its connected as a media device. I have heard a few places that connecting as a media device causes some issues with USB debugging. Maybe that is the issue, if so how do I turn that off?
Kinda at a loss here. How do I go about getting this working?
Thanks in advance
I have the same Hisense Sero 7 tablet. The id is 109b, which can be found here in the list of USB Vendor IDs. This must be done in addition to the answer explained by Sumit Jain.
In addition to editing 51-android.rules, you will also need to add third party vendor Id to adb_usb.ini
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x109b
then in the terminal:
adb kill-server
adb devices
> List of devices attached
> 015d8bed094ffe06 device
P.S: this is the command I used
gedit ~/.android/adb_usb.ini
Well I think I have a method which can help u. Just follow the steps...
Type lsusb in your terminal after plugging in your device to your system. You will see some codes. Now remove the device and again run command. Now you will notice that one of the code is missing.
Note down the missing code because that is the code of your device manufacturer.
This is the code in my case (0bb4)
Bus 002 Device 014: ID 0bb4:0ce6 High Tech Computer Corp.
3.Now go to this path /etc/udev/rules.d
4.You will notice a file named 51-android.rules.
5.Open it and copy and paste the last line but change. The last line looks like the one i pasted above. Now in the copied line replace the code with your device code (0bb4 in my case).
Now type adb kill-server
Now type adb devices and you can see your device listed.
Hope this will help you and ya be careful with permissions your require anywhere.
Goto setting/about/build tap build 8 times. Bazinga developer options open up when you back out

USB debugging - Issue with installing drivers for Epson Moverio

New to Android development, I've made a small app using Eclipse that works perfectly on a virtual Android device. Now, I want to run it on the real device: Moverio, a head-mounted display made by Epson, but my computer just does not recognize it as an Android device.
Being on Windows 7, I understood I need a specific USB driver. Epson sent me instructions to install the driver, but it still doesn't work. How can I do it?
Here are the steps I followed:
Add following two lines in [Google.NTx86] and [Google.NTamd64] sections in
\extras\google\usb_driver\android_winusb.inf:
%SingleAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04
%CompositeAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04&MI_01
Add vendor ID in [username].android\adb_usb.ini]
Enable USB debugging mode on the device
Install USB driver following instructions given here http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver
I ran into a problem in the fourth step: in my device management panel, Moverio is in the "Disk drives" category. When I right click on it to install or update drivers nevertheless, inputting the <sdk>\extras\google\usb_driver\ folder, it says the driver is up to date.
When I try to run the app using Eclipse, it asks me to install a virtual device, because it can't find any real device connected.
I managed to find a blog post walking through the process needed to enable ADB access to the device. The original is in Japanese and the Google translation left something to be desired.
I'm providing my recreation of the process below; this is partially a translation and partially an expansion and combination of the original with the official documentation which failed to cover the problem encountered with the Moverio.
With a few modifications noted at the end, I suspect this should work for installing debug support on other devices that only identify as external data drives by default as well.
The first thing you need to do is to edit the .inf file for the Google USB driver.
The file is located at \android-sdk\extras\google\usb_driver\android_winusb.inf.
By default, the android-sdk folder is located under C:\User\YourUserName\AppData\Local\Android\.
You need to add the following lines to the end of the file:
[Google.NTamd64]
; BT-100
%SingleAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04
%CompositeAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04&MI_01
Next connect the device with developer mode disabled. Windows will identify it as a USB mass storage device (MSC).
You need to go into Device Manager and uninstall it. If you have multiple USB-MSDs listed under USB Serial Bus Controllers, you can identify which one is the Moverio by disconnecting it, right clicking on each one that is still present, selecting properties and noting the location value on the general tab. Then reconnect the Moverio and look for the new entry it adds.
After you've uninstalled the Moverio's USB Mass Storage Device entry, disconnect it and enable Developer mode on the device.
Then reconnect it. Device Manager will update to show a BT1 entry under Other Devices
Right click on the BT1 entry, select Update Driver Software, mrowse My Computer for driver software. Provide the path to the USB driver folder from step one. Click Next.
At this point I get a warning about not being able to verify the publisher of the driver. I believe this is related to my having edited the .inf file. Click install this driver software anyway.
Windows will report that the driver is successfully installed. Close the update dialog. You should now see an Android Composite ADB Interface entry in device manager. On my computer it's appearing under ASUS Android Devices; which I assume is a legacy of the Transformerpad I've connected in the past; in the blog I'm using as a source it appeared under Android Phone.
ADB still needs to be informed that the device is available however. To do this, you need to edit the \.Android\adb_usb.ini file. Default location of C:\User\YourUserName\ by appending the vendor ID as a new line to the end. This is an autogenerated file; but running the update process in the comment will remove the entry we need. If you unexpectedly lose the ability to debug, this would probably be a good spot to recheck.
# ANDROID 3RD PARTY USB VENDOR ID LIST - DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x04B8
The only thing left is to stop and restart ADB. To do this, open a command prompt at \android-sdk\platform-tools. Issue the command adb kill-server followed by the command adb devices.
C:\Users\Neelyd\AppData\Local\Android\android-sdk\platform-tools>adb kill-server
C:\Users\Neelyd\AppData\Local\Android\android-sdk\platform-tools>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
WS000 device
When ADB restarts the device should be listed, and appear in DDMS in Eclipse.
To use this procedure to install the generic Android USB driver on a different device I think all you should need to do is to right click on the device's USB Mass Storage Device entry in device manager (step 3); select details, select the Hardware Ids property, note the values displayed, and use them in place of the Moverio's in the android_winusb.inf file (step 1), and the vendor ID in adb_usb.ini (step 10).
Possible simpler option
After figuring this out, I finally got a reply from Epson support. They said it should be possible to install their driver to the USB-MSD identified in step 2 directly. If that works it would replace steps 3-6. I haven't tested it though, so I'm only leaving this note as a postscript.
Installing drivers for Windows might be much more difficult than it seems. From my experience, you have much better chance for successful development for Android on any Linux platform, be it installed next to your Windows installation on your PC or run in a virtual box. Linux does recognise almost any Android device and allows access without any driver installation.

Eclipse wont recognize my android tablet when I try to test my app?

Recently I bought a new android tablet (a no-name Chinese tablet), and I'd like to test an application I'm developing on it.
However, when I try to run it through Eclipse, it won't recognize my tablet (the debugging mode is enabled on the tablet). When I have the select device dialog I see
Serial Number : ???????????
AVD Name : N/A
Target : unknown
Debug :
State : ??
I'm running Linux Mint. What should I do?
On Linux, you have to add an udev rule for your tablet. For instance:
#cat /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", SYSFS{idVendor}=="0502", MODE="0666"
you can use lsusb in order to retrive the vendor id
Bus 002 Device 016: ID 0502:3325 Acer, Inc.
For Linux you need to setup UDEV to support the manufacture's identity, or you need to restart adb using sudo.
To do it correctly, do this:
lsusb
and look for your tablet:
Bus 002 Device 008: ID 04e8:6860 Samsung Electronics Co., Ltd
Note the ID.
Then go to /etc/udev/rules.d and create a new file called androiddevelopment.rules in that file put this:
SUBSYSTEM=="usb", ATTRS{idVendor}=="xxxx", OWNER="yyyy", GROUP="zzzz"
Where xxxx is the first part of the ID (04e8 in my example), yyyy owner is your username and zzzz is your group.
Then restart udev:
sudo service udev restart
That should allow Linux to automatically allow your user to connect to that device.
Problem: How to get Eclipse to recognize my 7" RCA tablet:
This problem frustrated me for two days. I have a generic RCA 7" tablet that I bought at a Black Friday sale at Walmart. I was trying to use it with the Android SDK and eclipse, but my computer would not recognize the tablet as anything more than a storage device. I found several clues that led me in the right direction, but nothing seemed to work; finally found my answer here:
http://pychildren.blogspot.se/2012/12/getting-android-adb-working-with-pipo.html
(Before you start, if you are as much of a newbie as I am, go to this site first to find out something about terminal commands -
community.linuxmint.com/tutorial/view/100
I was working with Linux Mint 15. I had also installed the Eclipse and Android sdk bundle.
No matter what I did, Eclipse would not recognize my tablet. Finally I got the problem resolved. I really just had to three things:
First I had to go to my home folder
Then to the .android folder
Then add the following line to the bottom of the "adb.usb.ini" file:
0x2207
and save the file. I was able to do this from the GUI interface.
Second, I had to open a terminal and navigate to the file system folder
Then to the etc folder
Then to the udev folder
Then to the rules.d folder
I had to create a file called
"51-adroid.rules" that contained only two lines:
SUBSYSTEM=="usb", SYSFS{idVendor}=="2207", MODE=="0666"
SUBSYSTEM=="usb", SYSFS{idVendor}=="0x2207", MODE=="0666"
(I probably needed only the last line, but several sources had not included the "0x" so I included it both ways.
Then, still in the terminal, I ran the following command from my home folder after the ? (just enter cd to return to the home folder)
sudo Development(the name of the folder in which I installed Eclipse and the sdk, yours will be different)/sdk/platform-tools/adb kill-server
Then I had to run the following command from the home folder
sudo Development(the name of the folder in which I installed Eclipse and the sdk)/sdk/platform-tools/adb start-server
I also had to make sure that debugging was enabled on my tablet.
I also turned off wifi on my tablet - no one but my last source had mentioned this, but I think that it may have helped.
Then, when I typed in "adb devices", my tablet was recognized. When I started Eclipse and started the Hello program, it displayed beautifully on my tablet. I just don't understand why my wife was not impressed.

Categories

Resources