android-----开发环境搭建(JNI+android4.2)
1.搭建环境
WIN7 64位
2.准备
(1)下载JDK7
http://www.oracle.com/technetwork/java/javase/downloads/index.html
(2)下载Eclipse
http://www.eclipse.org/downloads/
(3)下载ADT
http://developer.android.com/tools/sdk/eclipse-adt.html
(4)下载Android SDK
http://developer.android.com/sdk/index.html
(5)下载NDK
http://developer.android.com/tools/sdk/ndk/index.html#Installing
3.安装
(1)安装JDK7
默认配置安装就好。
设置环境变量:
JAVA_HOME 添加D:\Program Files\Java\jdk1.7.0_21
CLASSPATH 添加.;%JAVA_HOME%\lib
Path 添加%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
测试:
(2)安装eclipse
解压eclipse到本地。
测试:
(3)安装android SDK
解压
注意SDK 号要与ADT号匹配
添加环境变量
PATH 添加sdk\platform-tools 与sdk\tools
测试:
(4)安装NDK
解压到某个目录即可。
设置环境变量
在PATH 中添加F:\android环境\android-ndk-r8e
(5)安装 Android Development Tools (ADT)
备注:要先安装NDK,否则安装ADT可能报错
(6)设定"SDK Location"
(7)测试
新建android工程,hello world
直接运行后
附录:
可能问题集锦
(1)
ADB server didn't ACK
之前运行eclipse执行android应用都没问题,今天突然出问题了,控制台报错:
The connection to adb is down, and a severe error has occured.
You must restart adb and Eclipse.
Please ensure that adb is correctly located at 'E:/setups/android/android-2.1_r01-windows/tools/adb.exe' and can be executed.
在命令行下运行 adb start-server
errors:
* daemon not running. starting it now *
ADB server didn't ACK
* failed to start daemon *
已经确认adb.exe的路径没有问题,重启了两次模拟器和eclipse还是不行,上网查了下资料~
解决办法:
(1)查看任务管理器,关闭所有adb.exe
(2)重启eclipse即可
若重启eclipse未能解决,则可能5037端口被占用
解决:
如果出现adb端口被占用,可以通过netstat -ano | findstr "5037"查看端口的使用情况,结果如图,最后1位是PID这里是6952,被占用的情况下去任务管理器中杀掉这个进程即可)
(2)ADT安装报错
Cannot complete the install because one or more required items could not be found.
Software being installed: Android Native Development Tools 20.0.0.v201206242043-391819 (com.android.ide.eclipse.ndk.feature.group 20.0.0.v201206242043-391819)
Missing requirement: Android Native Development Tools 20.0.0.v201206242043-391819 (com.android.ide.eclipse.ndk.feature.group 20.0.0.v201206242043-391819) requires 'org.eclipse.cdt.feature.group 0.0.0' but it could not be found
解决:
NDK未安装
(3)模拟器窗口过大问题
在模拟器启动的时候, 可以手动设置的,
scale display to real size
screen size 设置为8 就差不多了,