Android Development Environment Build & first Android project built

Source: Internet
Author: User
Tags virtual environment

I myself to install the development environment to spend time more attention, generally not very long, can meet their current use on it, and not all the resources are fully configured, so I will feel very waste of time, and then all the building will also appear such a problem of unintelligible, Seemingly a solution to their ability to have a certain ascension, and then for me this is not an egg, I use this time, basically can do Android primer, and some people are still pondering how this eclipse how to configure the SDK path problem, Baidu Google a lot. Here's how to quickly build an Android development environment and write out the first Android app, I never write Hello world, because I think it's relatively low, I generally write:

1:eclipse&sdk

Because most of the time before the development of Eclipse, or myeclipse, did not study Android studio, of course, there will be opportunities to contact.

Eclipse went to the official website to download, but I do not have, I now use the Great Wall broadband is very difficult for me to go to the net to download anything. Okay, get to the chase.

This Baidu provides the download is excellent, through the keyword search "Android SDK download", directly on the first page of Baidu can see this integration of Eclipse and SDK software download link. OK, download just fine.

There are about three files in it:

OK, unzip this folder to the specified directory, open eclipse, if you installed the JDK, I use 1.7.0_13, find the directory Help_about ADT, opened to see:

The version number given here is 22.3.0, and I look at the installation version of the next ADT, not sure whether the version number refers to the SDK or ADT, so let's assume that both the SDK and ADT version numbers are 22.3.0. Well, the environment is almost there.

2:jdk

I don't want to say anything about this, I'm guessing no one will, but simply mention it:

, or Baidu, but Baidu is the latest version, or go to Oracle official website download You need, if the official website can not open to see the other links to Baidu, look for the software station, there must be something you want.

Configure environment variables after installation:

Find the JDK installation directory, usually this: C:\Program files\java\jdk1.7.0_13

Added a java_home value:c:\program files\java\jdk1.7.0_13

Locate the class path cursor to the front: C:\Program files\java\jdk1.7.0_13\bin; Add this.

OK, all configured.

The first project is established below:

File-new-other-android-android application Project, of course, is behind the truncation, perhaps the name is not the same, this does not need to tangle.

I use the Xiaomi 2s mobile phone system is Android4.1, so I have to do androidproject all set to Android4.1, save a lot of trouble, the latest version of ADT23, there will be a v7 rely on the library to backward compatibility with less than 4.1 version of the phone, my phone just meet this demand, so Learn the basics of fast Android development, and first of all, please don't tangle with this version spanning issue, these are the compatibility issues that have to be considered after the complete project has been made. Of course platforms inside only a android-19, this is Android4.4, so I have a android-16, this is my 4.1

Then

Next-next-next-next-finish.

Well, the first Android project was built up. Open it and look what it looks like?

That's probably the way it is.

Tell the first Android project to focus on those things:

Mainactivity.java (src-com.somewhater-my_android)

1  Packagecom.somewhater.my_android;2 3 ImportAndroid.os.Bundle;4 Importandroid.app.Activity;5 ImportAndroid.view.Menu;6This is the new project, a new activity in the inside, to control the code logic, etc., all written in this side.7  Public classMainactivityextendsActivity {8 9     protected voidonCreate (Bundle savedinstancestate) {Ten         Super. OnCreate (savedinstancestate); One Setcontentview (r.layout.activity_main); A     } -  -      Public BooleanOncreateoptionsmenu (Menu menu) { the getmenuinflater (). Inflate (R.menu.main, menu); -         return true; -     } -  +}

The render view file, which is the GUI, has two representations, layout and XML, where you can drag various components to complete the required functions, or write them manually in XML, the directory of this file is: Res-layout

The following to see is/my_android/androidmanifest.xml this file, but do not move the bin directory of this file, Bin directory is compiled files, you do not care what he did, a lost do not need to move, then in addition to what error warning, this I did not try. There is a piece of code in it:

1 <Application2         Android:allowbackup= "true"3 Android:icon= "@drawable/ic_launcher"4 Android:label= "@string/app_name"5 Android:theme= "@style/apptheme" >6         <Activity7             Android:name= "com.somwhater.my_android." Mainactivity "8 Android:label= "@string/app_name" ><!--Here you can look at the back of my string.xml file to explain that sometimes you want to install the APK into Chinese, but your project name is in English, Don't be silly to change the project name, hahaha --9             <Intent-filter>Ten                 <ActionAndroid:name= "Android.intent.action.MAIN" /> One  A                 <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> -             </Intent-filter> -         </Activity>

And this file,/my_android/res/values/strings.xml.

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Resources>3 4     <stringname= "App_name">My_android</string>5     <stringname= "Action_settings">Settings</string>6     <stringname= "Hello_world">Hello world!</string>7 8 </Resources>

Of course this Hello world! was generated by himself, not by me. OK, look at the uncomfortable I will change ah, of course, you do not change the words are like this:

And then I changed it and it turned out this way:

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Resources>3 4     <stringname= "App_name">Android Apps</string>5     <stringname= "Action_settings">Settings</string>6     <stringname= "Hello_world">My first Android app, hahaha!!!</string>7 8 </Resources>

Next/my_android/res/values/strings.xml This file, all the strings in the control are best written like this, such as the text value inside the button, declare the string in String.xml, and then in/my_ Android/res/layout/activity_main.xml file can be used in such a way @string/name get this value, do not write in String.xml in the call you called hard code, the consequence is this:

If there is something about obsessive-compulsive disorder, it makes people scratching.

Then run Bai, I did not build a virtual environment, I directly set up their own phone USB debugging mode, so more real, Android simulator opened to a long time, but also the old card, which makes me not too cool.

Well, blogging took me about 40 minutes, installation environment to finish writing the first application, in my 50M of the Great Wall broadband support, it took only 10 minutes. Omg!!!

Android Development Environment Build & first Android project built

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.