Ubuntu 14.04 Setup Android development environment

Source: Internet
Author: User
Tags android sdk manager

Preparing the Java Environment

This article only installs the SDK and does not install any IDE, because I only need to command line mode development.

Install OPENJDK 1.6 first. Then install Ant. This does not repeat.

Download SDK

Download the SDK for Linux 64bit version number here: Http://developer.android.com/sdk/index.html?hl=sk#download

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

After downloading, unzip to local folder, for example/opt/folder, then environment variable setting, add three lines to ~/.BASHRC file

Export android_home=/opt/android-sdk-linuxpath= $PATH:/opt/android-sdk-linux/toolspath= $PATH:/opt/ Android-sdk-linux/platform-tools


Execute Android SDK Manager

Executes the android command. The SDK Manager dialog box will pop up to select the required package for installation


Installing Analog Devices

Android AVD
Official documentation for the detailed examination: http://developer.android.com/training/basics/firstapp/running-app.html

I created an analog device. The simulation device is finally executed.








Create a project display targets

$ android List targetsavailable Android targets:----------id:1 or "android-10" name:android 2.3.3type:platformapi level: 10revision:2skins:wqvga400, HVGA, WVGA854, QVGA, WQVGA432, WVGA800 (default) Tag/abis:default/armeabi----------id:2 o R "android-19" name:android 4.4.2 type:platform API level:19 revision:3 skins:wqvga400, HVGA, wxga800- 7in, WXGA800, WVGA854, QVGA, WQVGA432, WVGA800 (default), WSVGA, WXGA720 tag/abis:default/armeabi-v7a----------Id:3 or     "Google inc.:google apis:10" Name:google APIs type:add-on Vendor:google Inc. Revision:2 description:android + Google APIs Based on Android 2.3.3 (API level) Libraries: * Com.and Roid.future.usb.accessory (Usb.jar) API for USB accessories * COM.GOOGLE.ANDROID.MAPS (Maps.jar) AP I for Google Maps skins:wvga854, WVGA800 (default), WQVGA400, QVGA, WQVGA432, HVGA Tag/abis:default/armeabi-------- --id:4 or "Google inc.:google APIs x86:19" NaMe:google APIs X86 type:add-on Vendor:google Inc. Revision:4 Description:android + Google APIs x86 Based on Android 4.4.2 (API level) Libraries: * com . Google.android.media.effects (Effects.jar) Collection of video effects * Com.android.future.usb.accessory ( Usb.jar) API for USB accessories * COM.GOOGLE.ANDROID.MAPS (Maps.jar) APIs for Google Maps Skins : WVGA800 (default), QVGA, WSVGA, wxga800-7in, WQVGA400, WVGA854, WXGA720, WXGA800, WQVGA432, HVGA tag/abis:default/x86


Create a project

$ android Create Project--target android-10--name myfirstapp--path myfirstapp--activity mainactivity--package com.exa Mple.myfirstapp> Created Project Directory:myfirstappcreated Directory/home/dean/work/gitlab_cloud/android/ example/myfirstapp/src/com/example/myfirstappadded file myfirstapp/src/com/example/myfirstapp/ mainactivity.javacreated directory/home/dean/work/gitlab_cloud/android/example/myfirstapp/rescreated Directory/ Home/dean/work/gitlab_cloud/android/example/myfirstapp/bincreated directory/home/dean/work/gitlab_cloud/android /example/myfirstapp/libscreated directory/home/dean/work/gitlab_cloud/android/example/myfirstapp/res/ valuesadded file myfirstapp/res/values/strings.xmlcreated directory/home/dean/work/gitlab_cloud/android/example/ myfirstapp/res/layoutadded file myfirstapp/res/layout/main.xmladded file myfirstapp/androidmanifest.xmladded file myfirstapp/build.xmladded file Myfirstapp/proguard-project.txt[email protected]:~/work/gitlab_cloud/android /example$ Lsmyfirstapp readme[email protected]:~/work/gitlab_cloud/android/example$ CD MyFirstApp/[email  protected]:~/work/gitlab_cloud/android/example/myfirstapp$ lsandroidmanifest.xml Ant.properties bin Build.xml Libs L Ocal.properties proguard-project.txt project.properties Res src

Compile

Perform the following command compilation

Ant Debug


Suppose the following error is reported:

     [AAPT]/opt/android-sdk-linux/build-tools/19.0.3/aapt:error while loading shared libraries:libz.so.1:cannot open Shared object File:no such file or directory

Installation Library:

sudo apt-get install lib32z1


Deploying programs to Emulators

$ adb install bin/myfirstapp-debug.apk97 kb/s (4858 bytes in 0.048s) pkg:/data/local/tmp/myfirstapp-debug.apksuccess


The execution of the program is good, now you can execute the program in the simulator. Executes the program mainactivity. The following text is displayed:

Hello World, Mainactivity

The text is actually defined in the./res/layout/main.xml file:

<?xml version= "1.0" encoding= "Utf-8"?

><linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" android:orientation= " Vertical " android:layout_width=" fill_parent " android:layout_height=" fill_parent " ><textview android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:text= "Hello World, Mainactivity " /></linearlayout>



Define the application name

Suppose you want to change the name of an app in Android, not edit it in Pom.xml, but define it in Src/values/strings.xml, for example:

<?xml version= "1.0" encoding= "Utf-8"?><resources>    <string name= "App_name" >mvn_example1</ string>    <string name= "Edit_message" >enter a message</string> <string    name= "Button_send" >Send</string>    <string name= "action_settings" >Settings</string>    <string name= " Title_activity_main ">MainActivity</string></resources>





Ubuntu 14.04 Setup Android development environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.