01 February, 2015

Setting Up Android For the Nth Time

Since I've been authoring Android apps, I've gone through numerous occasions of installing/re-installing/re-re-installing of the SDK and more recently AndroidStudio.  I've been a bit out of the loop, a bit of a hiatus from development but recently reacquainting with the SDK.

Start by downloading and extracting the SDK;

$ wget http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz

$ tar -zxvf android-sdk_r24.0.2-linux.tgz


Append the locations of the new utilities to your Bash profile;


$ echo "export PATH=\$PATH:~/android-sdk-linux/tools" >> ~/.bashrc

$ echo "export PATH=\$PATH:~/android-sdk-linux/platform-tools" >> ~/.bashrc

The default install generally installs the latest APIs, but you can install additional ones;

$ android

Likely, if you've recently updated or reinstalled the Android SDK, you'll have to update the project XML files.  

The 'update project' command takes a numeric target id, listing the targets and 
find the appropriate id.

$ android list targets | grep id:
id: 1 or "android-7"
id: 2 or "android-8"
id: 3 or "android-21"
id: 4 or "Google Inc.:Google APIs:7"
id: 5 or "Google Inc.:Google APIs:8"
id: 6 or "Google Inc.:Google APIs:21"
The current API version is stored in the project.properties file within the project directory.


$ cat project.properties
.
.
target=Google Inc.:Google APIs:8
.
.

Updating the project to continue to use API 8 would therefore be done by;


$ android update project -p . -t 5

Get the list of devices available by issuing the following command;


$ adb devices
List of devices attached 
01aa7bcb8c8c07be device

$ adb -s 01aa7bcb8c8c07be install -r ./bin/Test01-debug-unaligned.apk


Whole buncha interesting stuff is available by examining the APK;

$ aapt dump badging ./bin/Test01-debug-unaligned.apk
package: name='com.abc.test01' versionCode='3' versionName='1.2' platformBuildVersionName=''
application-label:'Test01'
application-icon-160:'res/drawable/icon.png'
application: label='Test01' icon='res/drawable/icon.png'
application-debuggable
launchable-activity: name='com.abc.test01.Test01'  label='Test01' icon=''
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
sdkVersion:'7'
targetSdkVersion:'7'
feature-group: label=''
  uses-feature: name='android.hardware.screen.portrait'
  uses-implied-feature: name='android.hardware.screen.portrait' reason='one or more activities have specified a portrait orientation'
  uses-feature: name='android.hardware.touchscreen'
  uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
main
other-activities
supports-screens: 'small' 'normal' 'large'
supports-any-density: 'true'
locales: '--_--'
densities: '160'
That's all for now.  Cheers.