Android Development Environment Construction & amp; the first Android project establishment, android Development and Construction

Source: Internet
Author: User

Build the Android Development Environment & build the first Android project, and build the android Development Environment

I personally pay attention to the time it takes to install the development environment. Generally, it will not take a long time, so I can use it right now, instead of configuring all the resources, in this way, I will feel a waste of time, and then there will also be such a problem with the deployment cloud, it seems that one by one to solve their own capabilities have a certain degree of improvement, this is nothing for me. During this time, I can basically get started with Android, and some people are still wondering how to configure the sdk path in eclipse, baidu Google has a lot. The following describes how to quickly build an Android development environment and write the first Android Application. I never write hello world because I think it is relatively low:

1: eclipse & sdk

Because most of the time I used eclipse for development, or myeclipse, I have never studied Android studio. Of course, I will have a chance to access it in the future.

Eclipse has been downloaded from the official website, but I don't have it here. The Great Wall broadband I use now is very difficult for me to download anything on the official website. OK.

The download provided by Baidu is excellent. You can search for "Android sdk download" by keyword. You can see the download link of the software integrated with eclipse and sdk on the first page of Baidu homepage. OK. download it.

There are about three files in it, which are like this:

Okay. decompress the folder to the specified directory and open eclipse. The premise is that you have installed jdk. Here I use 1.7.0 _ 13. Find the directory Help_About ADT. After opening it, you can see:

The version number provided here is 22.3.0. I checked the adt installation version again. I am not sure whether this version number refers to sdk or adt. Therefore, I think both sdk and adt versions are 22.3.0. Now, the environment is almost ready.

2: jdk

I don't want to talk much about this. No one will do it, but I 'd like to mention it briefly:

Or Baidu, but Baidu provides the latest version, or you can download what you need from the oracle official website. If the official website cannot be opened, you can see other links from Baidu and find various software sites, you must have something you want.

Configure environment variables after installation:

Find the jdk installation directory, which is generally C: \ Program Files \ Java \ jdk1.7.0 _ 13

Add java_home value: C: \ Program Files \ Java \ jdk1.7.0 _ 13

Move the class path cursor to the frontend: C: \ Program Files \ Java \ jdk1.7.0 _ 13 \ bin; and add this.

OK. All configurations are complete.

The first project is created below:

File-New-Other-Android Application Project, of course, is intercepted only later. The names may not be the same, so you don't need to worry about it.

My own Xiaomi 2 S mobile phone system is Android4.1, so I set all my androidprojects to Android4.1, saving a lot of trouble. The latest version of ADT23, there will be a v7 dependent library for backward compatibility with mobile phones earlier than Version 4.1. my mobile phone just meets this requirement, so I quickly learned about Android development, please do not tangle with the compatibility issues that will be considered after a complete project is created. Of course, there is only one android-19 in platforms. This is Android4.4, so I made another android-16. This is my 4.1

THEN

Next-Finish.

Now, the first Android project is created. Open to see what it looks like?

This is probably the case.

The first Android Project should focus on those things:

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

1 package com. somewhater. my_android; 2 3 import android. OS. bundle; 4 import android. app. activity; 5 import android. view. menu; 6 // This is the newly created Project, where a new activity is created to control the code logic and so on, all written here. 7 public class MainActivity extends Activity {8 9 protected void onCreate (Bundle savedInstanceState) {10 super. onCreate (savedInstanceState); 11 setContentView (R. layout. activity_main); 12} 13 14 public boolean onCreateOptionsMenu (Menu menu) {15 getMenuInflater (). inflate (R. menu. main, menu); 16 return true; 17} 18 19}

Rendering view files, that is, GUI, have two expressions: layout and xml. You can drag various components to complete the required functions or manually write them in xml, the Directory of this file is res-layout.

 

 

The following figure shows/My_Android/AndroidManifest. for xml files, do not change the file in the bin directory. The bin directory is the compiled file. You do not need to change it if you lose it. In addition to error warnings, I have never tried this. There is such a piece of code:

1 <application 2 android: allowBackup = "true" 3 android: icon = "@ drawable/ic_launcher" 4 android: label = "@ string/app_name" 5 android: theme = "@ style/AppTheme"> 6 <activity 7 android: name = "com. somwhater. my_android.MainActivity "8 android: label =" @ string/app_name "> <! -- Here we can look at my string. the xml file indicates that sometimes you want to change the installed apk to Chinese, but your project name is in English. Do not change the project name, hahaha --> 9 <intent-filter> 10 <action android: name = "android. intent. action. MAIN "/> 11 12 <category android: name =" android. intent. category. LAUNCHER "/> 13 </intent-filter> 14 </activity>

The file/My_Android/res/values/strings. xml is also available.

1 <?xml version="1.0" encoding="utf-8"?>2 <resources>3 4     <string name="app_name">My_Android</string>5     <string name="action_settings">Settings</string>6     <string name="hello_world">Hello world!</string>7 8 </resources>

Of course, this is Hello World! It was generated by myself, not by me. Okay. If you don't like it, I will change it. Of course, if you don't change it, it will look like this:

Then I changed it to the following:

1 <? Xml version = "1.0" encoding = "UTF-8"?> 2 <resources> 3 4 <string name = "app_name"> Android Application </string> 5 <string name = "action_settings"> Settings </string> 6 <string name = "hello_world"> my first Android Application, haha !!! </String> 7 8 </resources>

Next I will talk about/My_Android/res/values/strings. xml file, it is best to write all the strings in the control, such as the text value in the Button, in the string. declare this string in xml, and then obtain this value in the/My_Android/res/layout/activity_main.xml file in this way @ string/name, not written in string. people in xml call you hard-coded. The consequence is:

If you can't see what's going on with obsessive-compulsive disorder, it will make you feel scratching your ears.

Then run it. I didn't create a virtual runtime environment. I directly set the usb debugging mode for my mobile phone. This is more realistic. It takes a long time for the Android simulator to be turned on, but it is still stuck, this makes me uncomfortable.

Well, it took me about 40 minutes to write a blog. It took me 10 minutes to install the environment and write the first application. With 50 m of Great Wall broadband support, it took me 10 minutes. OMG !!!

Related Article

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.