Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build android Development Environment under Ubuntu 11.04

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to build an android development environment under Ubuntu 11.04. the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Install JDK

First, go to oracle's website to download the linux version of JDK at http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html

I chose Linux x86-Self Extracting Installer, about 81.2m.

After downloading back, of course, you can run the installation directly. First cp this file to your installation directory, and then execute it directly in your installation directory:

. / jdk-6u26-linux-i586.bin (of course, if the execution fails because there is no execution permission, then you also need to add the execution permission: chmod + x. / jdk-6u26-linux-i586.bin)

The installer will automatically install you to the jdk1.6.0_26 directory in the current directory.

After the program is installed, you need to set the environment variable.

Execute:

The code is as follows:

Sudo gedit / etc/profile

Add the following section to the configuration file:

The code is as follows:

Export JAVA_HOME=/home/jackwong/jdk1.6.0_26export JRE_HOME=/home/jackwong/jdk1.6.0_26/jreexport PATH=/home/jackwong/jdk1.6.0_26/bin:$PATH export CLASSPATH=.:/home/jackwong/jdk1.6.0_26/lib:/home/jackwong/jdk1.6.0_26/jre/lib

Save, then log out of the current user, log in again, and the environment variable takes effect.

Verify that the installation was successful:

Execute:

The code is as follows:

Java-version

If it appears:

The code is as follows:

Java version "1.6.026"

Java (TM) SE Runtime Environment (build 1.6.0_26-b06)

Java HotSpot (TM) Server VM (build 20.0-b11, mixed mode)

This kind of information means OK.

Note that ubuntu already has openjdk installed by default, so even if you do not install jdk, executing java-version will not report an error, but the information reported is different from that of jdk installed, please pay attention to the distinction.

two。 Install eclipse

Currently, the official recommended development environment is eclipse+ADT. Of course, you can use any other development environment, but I chose the official recommendation because everything is free.

Download eclipse from: http://www.eclipse.org/downloads/

What I downloaded is 32bit linux:

Eclipse IDE for Java Developers http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/heliossr2, 98 MB, which is a basic package for javaSE development. It is recommended to download the classic version. Note that the latest ADT requires that eclipse must be 3.5 or above.

File name: eclipse-java-helios-SR1-linux-gtk.tar.gz

Of course, the first step is to decompress and execute the command:

The code is as follows:

Tar zvxf eclipse-java-helios-SR1-linux-gtk.tar.gz

After the extraction is successful, an eclipse directory appears. This directory is the installed eclipse, enter this directory, execute the eclipse file, you can start eclipse.

You can go in and write a simple program, compile and execute it, to verify that eclispe is working properly, and you will find that eclipse compiles and executes faster under linux than on windows.

Of course, you can also create your own desktop startup shortcuts that are easy to use.

3. Download and install Android SDK Starter Package

Android SDK Starter Package is just the core basic tool of SDK. With it, use its management tool to download the other parts you need. Do you see an android script file in this directory? Executing it will launch Android SDK and AVD Manager, a tool that can help you download other parts you need and create a simulator.

Download address: http://developer.android.com/sdk/index.html

Download to the file is: android-sdk_r11-linux_x86.tgz, about 26m.

Then, of course, unpacking: tar zvxf android-sdk_r11-linux_x86.tgz.

After unpacking, the android-sdk-linux_x86 directory will appear in the current directory. In this directory are the basic tools of sdk. Remember this directory, because you will need it later when you run the tool or set up ADT!

4. Install the ADT (Android Development Tools) plug-in

The ADT plug-in is a plug-in of Eclipse officially developed by google, specially prepared for Android application development.

1. Start Eclipse and select Help > Install New Software....

two。 Click the Add button in the upper right corner

3. In the pop-up Add Repository dialog box, fill in "ADT Plugin" in the Name column, and there are two options in the Location column. One is to fill in the download URL: https://dl-ssl.google.com/android/eclipse/, so that you can download and install it online. The second option is if I have downloaded ADT Plugin, then click the Archive button next to it and find the plug-in directly to the package. For example, I am using the second one, which I have downloaded and the file name is ADT-11.0.0.zip,5.3M. No matter which one, finally choose OK, you can.

4. Then in the following software list, select the checkbox in front of Developer SDK Tools, then click the next button below, and then wait for the installation progress bar to complete, which will appear a list of installed software, you click Next, and then there will be license, you must select agree, and then click finish to complete (of course, there is a download process, which may take some time). After the installation is complete, restart eclipse.

5. Configure the ADT plug-in

The content of the configuration is to modify the reference point to the ADT plug-in in eclipse, which needs to point to the previously installed Android SDK directory. Remember this directory?

Start eclipse and select Window > Preferences..

In the pop-up Preferences dialog box, select the Android tab on the left and the directory of your original Android SDK on the SDK location on the right. For example, I go to the directory: / home/jackwong/android-sdk-linux_x86, then click apply, and then click ok.

In the process, a dialog box will pop up asking if you want to participate in the google satisfaction survey report. You can choose whether to participate or not. Click the process button.

After installation, you can use the Help > Check for Updates option to keep ADT up to date.

6. Add Android operating system and parts

So far, the basic configuration is almost complete, but in order to develop android applications, you must also add an android operating system that can be used by simulators to simulate your applications. Of course, there are other parts that need to be installed. This is actually done through Android SDK and AVD Manager in the SDK toolkit. Of course, you can start this program directly in eclipse: Window > Android SDK and AVD Manager.

Of course, you can also directly run the android script under the tools directory under the sdk directory to start.

The recommended components are generally:

SDK Tools, you installed the sdk starter package and actually installed it.

SDK Platform-tools, this needs to be installed.

SDK platform, you need at least one of this. That is, the operating system, you can download more than one, such as 2.2Jing 3.1 you can download all, but at least one, because the simulator is required to run. So, if you want to simulate and test all kinds of platforms, then you need to download one of all versions of android.

I downloaded three packages of SDK Platform-tools 5 and Android 3.1 Android Compatibility Package.

After the download is complete, the development environment for Android is set up.

7. Try writing a hello,android test program.

It's time to verify the results. Start eclipse and select File- > New- > Project....

Then select Android project under Android and fill in the following information:

Project name:HelloAndroid this is the name of the project, that is, the name of the directory containing the file

Application name:Hello,Android this is the name of the application and the text displayed at the top of the screen when the program is running

There is no need to explain Package Name:my.android. Anyone who has studied java should know that this is the package name of the class.

Create Activity:helloandroidactivity this is the name of activity. Android programs are all started with activity, that is, the name of an activity subclass.

The rest can be created with default values without change, and then click Finish to complete the project creation.

Enter the project and open the helloandroidactivity.java file

Update the code of the onCreate method as follows:

The code is as follows:

Import android.widget.TextView

Public void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); TextView tv = new TextView (this); tv.setText ("Hello, Android = Hello, Android!") ; setContentView (tv)

}

Save, ready to run.

But if you run like this, I can assure you that you are likely to fail. Because android 3.1 is really too resource-intensive. You may see that the simulator comes to a standstill after displaying an android logo.

Therefore, you also need to set up the simulator.

Select windows- > Android SDK and AVD Manager

Then click the new button to create a new virtual machine, as shown in the following figure:

There is a key point, that is, the SKin part, the default is to choose WXGA, the resolution is 1280mm 800, this resolution, my T7500mm 2G laptop, anyway, it is impossible to start the simulator successfully.

Therefore, it is recommended that you modify it and use a custom resolution, such as the 480 300 or 640 400 effects I use are acceptable. Of course, another method is in the start... of the simulator. Window selection: Scale display to real size is also OK, of course, the default 3 inches is too small, adjust to 7 inches or 5 inches on the effect is good, but this mode is relatively slow, and can not see clearly, is not recommended. As shown in the following figure:

All right, everything is all right, now you can Run, of course Run as becomes android application, Eclipse will automatically start the simulator, install apk automatically, and run automatically.

The effect is shown in the following figure:

Of course, there is another problem. The simulator will boot to the boot interface and then stop moving. Friends who have not used android may encounter a little confusion here, and those who have used it will know what to do, as shown below:

At this time, the system will not continue to run your application, you need to drag the following lock up until the system is unlocked, your application will be executed automatically. This is a special point for beginners who have not used android.

If you set the Scale display to real size mode when the simulator starts

The interface of android 3.1 after startup is different, as shown in the following figure:

The way to unlock it at this time is to drag the halo to unlock it.

Unlock it as shown in the following figure:

Then execute the application effect, as shown in the following figure:

Is it too small? So you still need to lower the resolution.

This is the end of this article on "how to build an android development environment under Ubuntu 11.04". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report