I downloaded the Android SDK here.
I extracted the file, e.g.
tar -xvzf android-sdk_r20.0.3-linux.tgz
I added the environment variables:
nano /etc/profile
# add the following lines to /etc/profile at the end
PATH=$PATH:/path/To/Folder/android-sdks/platform-tools:/path/To/Folder/android-sdks/tools
export PATH
Then, I restarted my computer.
I typed the line below in Terminal:
android sdk
I saw the screenshots below and chose the proper tools:
You might want to install Android 2.2 or above. I had installed Android 2.2.
I selected Android 1.6 and clicked on Install 2 packages.
I chose Accept All and Install.
This was how it looked when the SDK Manager worked:
After installation, I closed the SDK Manager.
I typed the line below in Terminal:
android list targets
I saw:
id: 1 or "android-4"
Name: Android 1.6
Type: Platform
API level: 4
Revision: 3
Skins: WVGA854, WVGA800 (default), QVGA, HVGA
ABIs : armeabi
----------
id: 2 or "Google Inc.:Google APIs:4"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 1.6 (API level 4)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, HVGA, QVGA, WVGA800 (default)
ABIs : armeabi
...
I typed:
android create project --target 1 --name MyFirstApp \
--path /path/To/Folder/myApps --activity MainActivity \
--package com.example.myfirstapp
I saw:
Created directory /path/To/Folder/android-sdks/myApps/src/com/www/myfirstapp
Added file path/To/Folder/myApps/src/com/www/myfirstapp/MainActivity.java
Created directory /path/To/Folder/android-sdks/myApps/res
Created directory /path/To/Folder/android-sdks/myApps/bin
Created directory /path/To/Folder/android-sdks/myApps/libs
Created directory /path/To/Folder/android-sdks/myApps/res/values
...
I typed:
android avd
I saw the screenshots shown below:
I clicked on New. I typed test-1.6 and chose Android 1.6 - API Level 4.
I created another Android Virtual Device.
I selected either of the two virtual devices I created and clicked on Start.
I pressed Launch.
I saw:
I started another Terminal and typed:
cd /path/To/Root/Folder/Of/MyApps
Make sure that Apache Ant was installed. See here. Then, I typed:
ant debug
I saw:
Buildfile: /path/android-sdks/myApps/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 20.0.3
[checkenv] Installed at /path/android-sdks
-setup:
[echo] Project Name: MyFirstApp
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
...
-post-build:
debug:
BUILD SUCCESSFUL
Total time: 6 seconds
I started the Android Virtual Device. I unlocked this virtual device.
Then, in the other Terminal, I typed:
adb install bin/NameOfApp-debug.apk
I saw:
112 KB/s (4886 bytes in 0.042s)
pkg: /data/local/tmp/NameOfApp-debug.apk
Success
I looked for the application in the virtual device and started the application.
Reference
Building Your First App
Update: The last steps including adb install bin/NameOfApp-debug.apk were added.
No comments:
Post a Comment