【Android】配置APK开发环境

1.安装java jdk去oracle公司下载
jdk-7u15-windows-i586.exe
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260-zhs.html
---
C:\Documents and Settings\XXXX>java -version
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode, sharing)

2.解压安装eclipse,去eclipse官网下载
eclipse-SDK-4.2.2-win32.zip
http://www.eclipse.org/downloads/

3.网络安装adt  (估计要花几个小时)
    选中eclipse的help->Install New Software
    在界面点击add,在Location位置添加网址http://dl-ssl.google.com/android/eclipse
    下载整个developer tools,一路安装到底
    
4.Android SDK(在第3步估计就安装好了) 中工具adb的路径查看
sdk路径可以按如下方式查看:
Window->Preferences->Android查看SDK Location
举例我的adb路径如下:
C:\Documents and Settings\XXXXX\android-sdks\platform-tools\adb.exe

5.创建AVD(Android模拟器)
Window->Android Virtual Device Manager->Android Virtual Device->New之后一通填写搞定

6.创建项目
File->Project->Android->Android Application Project一通填写(注意选择尺寸得注意,例如我选4.7寸的手机时占了电脑半个屏幕)

7.编写源代码
调出代码试图Window->Show View->Package Explorer
选中项目->src->...->MainActivity.java

package com.example.hello3;



import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;



import android.widget.*;  



public class MainActivity extends Activity {



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        TextView textView = new TextView(this);     

        textView.setText("Hello Android!");

        setContentView(R.layout.activity_main);

    }





    @Override

    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.

        getMenuInflater().inflate(R.menu.main, menu);

        return true;

    }

    

}


8.运行
选中项目->Run As->Android Application
等待编译链接后,eclipse会自动调用手机模拟器,然后你就可以在模拟器里面找到你刚才编写的程序了,点击运行,看看是否达到你要的效果。(这个过程对电脑配置要求挺高的,时长几分钟不等)

9.打包生成apk
选中项目->右键->Android Tools->Export Signed/Unsigned Application Package

10.卸载手机上安装的调试程序
命令adb uninstall com.example.hello

11.手持终端上运行程序
选中项目->Run configurations->Target->选中Always prompt to pick device->在Android Device Chooser界面选中你的手机->点击ok运行,然后去手机上查看运行效果
记得选中"Wipe User Data"

其他:
1)选择SDK版本,选择Android X.X, 不选Google APIs
2)已有项目的导入File->Import->Andrid->Existing Android Code Into Workspace

工作环境:

模拟器界面:

你可能感兴趣的:(android)