Skip to main content

How to Connect an Android Phone to Ubuntu to Access System and Files on Android?

How to connect an Android phone to Ubuntu to access system and files on Android?

How to connect an Android phone to Ubuntu to access system and files on Android?

image.png

Introduction

If you want to connect your Android phone to Ubuntu to do development, testing, manipulating files or just fun. You could be following these methods.
If you want to develop Android software in Ubuntu. Firstly, you need to connect your Android phone to Ubuntu and you may encounter no permissions to access your Android phone. There is a way to help you correctly connection.
Commonly, We often connect the Android phone to the computer through USB port and run 'adb devices'. However, you may will find out that it is not recognized, such as below:


$ ./adb devices 
List of devices attached  
???????????? no permissions   

If you encounter this problem, don't worry, it is easily repairable in Ubuntu. You just edit a file and then you should be good to go.

Equipment

Operation System: Ubuntu 14.04 LTS
Mobile Phone: HTC incredible S (htc_vivo)

Usage

  1. To find out the Vendor ID number and Product ID number.

Your Ubuntu can not recognize your Android phone, because it have not the manufacturer and model of the device. Now, you are able to find out it through by this command-line 'lsusb' when you connected it via USB of course.


$ lsusb
Bus 001 Device 003: ID 0fce:51a3 Sony Ericsson Mobile Communications AB
Bus 002 Device 005: ID 093a:2521 Pixart Imaging, Inc.
… (More)

In this case, the vendor ID number is '0fce' and the Product ID number is '51a3'.
Please keep the two numbers in your note, you will use them.

  1. To create or edit a rule file of USB device in Ubuntu.

$ cd /etc/udev/rules.d
$ ls -l
51-android.rules
99-android.rules

If you want to create or edit them. Please remember to use 'sudo' command-line, because the directory (/etc/udev/rules.d) of the owner is root. There are some examples for you.



$ sudo gedit /etc/udev/rules.d/10-android.rules
$ sudo gedit /etc/udev/rules.d/51-android.rules
$ sudo gedit /etc/udev/rules.d/91-android.rules
$ sudo gedit /etc/udev/rules.d/99-android.rules


If you can not find out it, you should refer to your note and fill blank the line as below.

SUBSYSTEMS==”usb”, ATTRS{idVendor}==”(Vendor ID)″, ATTRS{idProduct}==”(Product ID)″, MODE=”0666″

Otherwise, you can reference to my rules files as below.

File name: /etc/udev/rules.d/51-android.rules
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="(Your Login Account Name)"
# usbboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="(Your Login Account Name)"
# usbboot protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on grouper/tilapia (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on grouper/tilapia (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on manta (Nexus 10)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="(Your Login Account Name)"
# fastboot protocol on manta (Nexus 10)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="(Your Login Account Name)"
# adb protocol on Sony Ericsson Mobile Communications AB C2304
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”18d1″, MODE=”0666″, OWNER="(Your Login Account Name)"
# HTC G1
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c01″, MODE=”0666″
# HTC Hero
UBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c02″, MODE=”0666″
# HTC EVO
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c8d”, MODE=”0666″
# HTC EVO Shift
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0ca5″, MODE=”0666″
# HTC ThunderBolt
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0ca4″, MODE=”0666″
# LG OPTIMUS LG-P506
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”1004″, ATTRS{idProduct}==”618e”, MODE=”0666″
# Motorola Xoom
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8″, ATTRS{idProduct}==”70a9″, MODE=”0666″
# Samsung Galaxy S II I9100
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”04e8”, ATTRS{idProduct}==685e”, MODE=”0666”
# Samsung Nexus S
SUBSYSTEMS==”usb”, ATTR{idVendor}==”18d1”, ATTR{idProduct}==”4e22”, MODE=”0666”
# Samsung Galaxy S2
SUBSYSTEMS==”usb”, SYSFS{idVendor}==04e8, SYSFS{idProduct}==”685e”, MODE=”0666”, OWNER=”(your login account name)”, GROUP=”plugdev”
# Motorola Droid 3
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8”, ATTRS{idProduct}==”41db”, MODE=”0666”
# General Mobile Discovery 16 GB
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4”, ATTRS{idProduct}==|0c03”, MODE=”0666”

File name: /etc/udev/rules.d/10-motorola-droid.rules
# Motorola Droid
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”22b8″, ATTRS{idProduct} ==”41db”, MODE=”0600″

File name: /etc/udev/rules.d/99-android.rules
# Nexus One
SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″
# HTC incredible S
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0cac", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0cac"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="51a3", MODE="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="51a3"
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{ACTION} –device=$env{DEVNAME}"

File name: /etc/udev/rules.d/91-android.rules
# Samsung Galaxy
SUBSYSTEM==”usb”,ATTRS{idVendor}==”04e8”, SYMLINK+=”android_adb”, MODE=”0666”, OWNER="(Your Login Account Name)"
# GPAD G10 4 Gig
SUBSYSTEM==”usb”,ATTRS{idVendor}==”18d1”, SYMLINK+=”android_adb”, MODE=”0666”, OWNER="(Your Login Account Name)"

You need to change attributes of those files.



$ sudo chmod a+rx /etc/udev/rules.d/10-android.rules
$ sudo chmod a+rx /etc/udev/rules.d/51-android.rules
$ sudo chmod a+rx /etc/udev/rules.d/91-android.rules
$ sudo chmod a+rx /etc/udev/rules.d/99-android.rules


  1. To enable 'Unknown sources' and 'USB debugging' in your Android phone.

3.1. Go to 'Settings'
3.2. If you have not to see 'development/developer options', you should go to 'About phone' to find out 'Build number' and then tap it seven times. Go back 'Settings', you would be able to see it.
3.3. Go to 'Development' and enable the USB debugging.
3.4. Go to 'Applications' and check the 'Unknown sources' check-box.

  1. Restart 'udev' in Ubuntu.

You need to use 'sudo' command-line, because 'restart udev' can not run.
In my opinion, I think you should be to stop and start the 'adb server'.



$ sudo restart udev
$ ./adb kill-server
$ ./adb start-server
$ ./adb devices
List of devices attached
SH24SW123456     device

You are also running this command-line as below.
$ sudo /etc/init.d/udev restart
$ sudo ./(your adb path)/platform-tools/adb kill-server
$ sudo ./(your adb path)/platform-tools/adb start-server

  1. If you had the Android Development Utility, such as 'ADT', 'Android-Studio' or 'GAT', you should be to try another 'adb' command-line it is much better to test your applications on a real device rather than just relying on the emulator.


$ ./adb root
$ ./adb remount
$ ./adb push filename(a file) /system/app(a path)
$ ./adb pull /system/app(a path) filename(a file)
$ ./adb shell


Exception

  1. If it still cannot recognize, you might restart your computer or reconnecting your USB cable.

By the way, you also try to edit the file (adb_usb.ini) as below.



$ cd ~
$ sudo gedit /.android/adb_usb.ini


File name: ~/.android/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.
# For example, if you had an HTC incredible S you would attend your vendor ID in this file.
0bb4

Therefore, you need to restart your computer.

  1. If you got a response message as likely as not this 'Undefined command: “adb”. Try “help”.” when you ran 'adb'. The mean that you need to install 'adb' package. 'adb' is part of the Android SDK. There are two ways to help you install.

2.1. Open terminal (Ctrl+Alt+T in Ubuntu). From the command-line, the installation can be completed by running the following command from the terminal.

$ sudo apt-get install android-tools-adb android-tools-fastboot

2.2. If you had Synaptic package management, you would search for 'android-tools-adb' package, select Mark for installation, then click on the Apply button.

2.3. Normally, using the Ubuntu Software Center (USC), search for the phrase 'android-tools-adb', highlight the package and select install.

  1. Take a look at this web site to download the Android SDK.

3.1. Open a web browser.

3.2. Go to http://developer.android.com/sdk/

  1. If you have been installing 'adb' package, but you got an error message. Such as 'No command 'adb' found'. You might add your 'adb' path in your PATH variable.

4.1. It seems the shell cannot find the command 'adb', so you need add 'adb' to your path variable. Normally, you are able to find out it in the Android SDK.



$ ./adb devices
No command 'adb' found, did you mean:
Command 'cdb' from package 'tinycdb' (main)
Command 'gdb' from package 'gdb' (main)
Command 'aub' from package 'aub' (universe)
... (more)

4.2. If you had 'adt-bundle-linux-x86_64-xxxxxxxx', you would be to find out it in this path ('your adt path'/sdk/platform-tools).

4.3. If you had 'android-studio', you would be to find out it in this path('your android-studio path'/sdk/platform-tools).

4.4. If you had 'adt-bundle-windows-x86_64-xxxxxxxx', you would be to find out it in this path ('your adt path'/sdk/platform-tools).

4.5. If you want to make any directories in Ubuntu, you should add them in your '.bashrc' it is much better for developing your applications.



$ cd ~
$ ls -la
.bashrc
... (more)
$ sudo gedit .bashrc

File name: .bashrc
# export PATH=('your adt path'/sdk/platform-tools):$PATH
# export PATH=${PATH}:('your adt path'/sdk/platform-tools)
For example, it is as likely as not as below.
export PATH=/home/tester/adt-bundle-linux-x86_64-20140702/sdk/platform-tools:$PATH
export PATH=${PATH}:/home/tester/adt-bundle-linux-x86_64-20140702/sdk/platform-tools

Once you are done, you will need to be sourced the file (.bashrc) if you want to change to be picked up, you are just to run a command-line.



$ . ./.brashrc


By other way, you could restart a new terminal and then it will be loaded new configuration file (.bashrc) by your edition.

  1. What is the rules format of the 'udev'?

If you want to know about the rules format of the 'udev', you would visit to this web site [4]. There are richly explained about 'udev' rules by [4].

Popular Posts

波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

最佳化處理策略之快速消除扭曲演算法

Python 日期與時間的處理

波蘭文學習之旅:1-1. 波蘭文字母與發音(注音版)

Image

最佳化處理策略之快速消除扭曲演算法

Image

Python 日期與時間的處理

Image

Visual Basic 6.0 程式案例學習: 10. 條碼列印程式 (2014版)

Image

Visual Basic .Net 程式案例學習: 06. 題庫測驗系統 (2014版)

Image

修復損毀的 SQLite DB 資料庫

Image

用10種程式語言做影像二值化(Image binarization)

Image

解決 ValueError: If using all scalar values, you must pass an index

Image

Visual Basic 6.0 程式案例學習: 04. 人事考勤管理系統 (2014版)

Image

Visual Basic 6.0 程式案例學習: 07. 收據列印程式 (2014版)

Image

佑佑的 Line 貼圖創作

貼圖作者網址:

https://line.me/S/shop/sticker/author/3883362

靜態貼圖

 
 
 
 
  牡羊座:狗狗角色

作者:佑佑
依照牡羊座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  金牛座:兔兔角色

作者:佑佑
依照金牛座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  雙子座:貓貓角色

作者:佑佑
依照雙子座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  巨蟹座:倉鼠角色

作者:佑佑
依照巨蟹座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  獅子座:幼獅角色

作者:佑佑
依照獅子座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  處女座:松鼠角色

作者:佑佑
依照處女座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  天秤座:鴿子角色

作者:佑佑
依照天秤座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  天蠍座:鳳凰角色

作者:佑佑
依照天蠍座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  射手座:人馬角色

作者:佑佑
依照射手座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  魔羯座:山羊角色

作者:佑佑
依照魔羯座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  水瓶座:海豚角色

作者:佑佑
依照水瓶座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
  雙魚座:小丑魚角色

作者:佑佑
依照雙魚座的個性優點、個性缺點、生活習慣、理財習慣、社交習慣、愛情觀、節假日、禮貌問候,所編撰的貼圖。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  上班族都變成狒狒,心裡想要說的話。

作者:佑佑
最近在台灣走紅的狒狒,用擬人化的方式,變成上班族,畫出心裡的想說的話。
購買貼圖
  接案派遣的日常

作者:佑佑
接案派遣到其他公司的日常對話,有調皮、正經、日常對話。
購買貼圖
  貓女事務員的搞笑時刻

作者:佑佑
把行政人員在職場上遇到千奇百怪的事情畫出來,用可愛的貓女來擔任行政人員的代言人。
購買貼圖
  貓貓說每天都會用到的話

作者:佑佑
日常生活常見的短句,用小貓擬人化的方式呈現,比較親切可愛。
購買貼圖
 
     
  大人的煩惱特輯:小兔角色

作者:佑佑
錢包餓了,生活苦了。變美變健康?先讓我睡飽吧。心好累,我需要充電。
購買貼圖
     

動態貼圖

 
 
 
 
  牡羊座日常交際:狗狗角色

作者:佑佑
依照牡羊座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  金牛座日常交際:兔兔角色

作者:佑佑
依照金牛座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  雙子座日常交際:貓貓角色

作者:佑佑
依照雙子座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  巨蟹座日常交際:倉鼠角色

作者:佑佑
依照巨蟹座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  獅子座日常交際:幼獅角色

作者:佑佑
依照獅子座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  處女座日常交際:松鼠角色

作者:佑佑
依照處女座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  天秤座日常交際:鴿子角色

作者:佑佑
依照天秤座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  天蠍座日常交際:鳳凰角色

作者:佑佑
依照天蠍座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
 
 
 
  射手座日常交際:人馬角色

作者:佑佑
依照射手座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  魔羯座日常交際:山羊角色

作者:佑佑
依照魔羯座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  水瓶座日常交際:海豚角色

作者:佑佑
依照水瓶座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
  雙魚座日常交際:小丑魚角色

作者:佑佑
依照雙魚座的個性,描繪日常生活的行為,供交際表達心情使用。星座只能當參考用,不會完全準確。
購買貼圖
 
     
  厭世報:鬍渣男

作者:佑佑
厭世總有個理由跟原因,實在是令人不爽,為什麼最倒楣的總是我?真希望明天就是世界末日,讓大家都一樣慘。
購買貼圖
     

表情貼

 
 
 
 
  貓貓說每天都用得到的表情貼

作者:佑佑
日常生活常見的表情用語,用小貓擬人化的方式呈現,比較親切可愛。
購買貼圖
  天秤座的表情貼:鴿子角色

作者:佑佑
日常生活常見的表情用語,天秤座的鴿子擬人化方式呈現,比較親切可愛。
購買貼圖
  天蠍座的表情貼:鳳凰角色

作者:佑佑
日常生活常見的表情用語,天蠍座的鳳凰擬人化方式呈現,比較親切可愛。
購買貼圖
  射手座的表情貼:人馬角色

作者:佑佑
日常生活常見的表情用語,射手座的人馬擬人化方式呈現,比較親切可愛。
購買貼圖
 
 
 
 
  魔羯座的表情貼:山羊角色

作者:佑佑
日常生活常見的表情用語,魔羯座的山羊擬人化方式呈現,比較親切可愛。
購買貼圖
  水瓶座的表情貼:海豚角色

作者:佑佑
日常生活常見的表情用語,水瓶座的海豚擬人化方式呈現,比較親切可愛。
購買貼圖
  雙魚座的表情貼:小丑魚角色

作者:佑佑
日常生活常見的表情用語,雙魚座的小丑魚擬人化方式呈現,比較親切可愛。
購買貼圖