The Android ports provided are based on my own development environment, which is based on Eclipse, as well as to my and the Android own structure. Still, everything inside the packages is plain adaptable source code, but I recommend to use Eclipse with the Android SDK as Google provides a plug-in for Eclipse which comes in handy if you start testing and especially debugging (which is normally a horrible work).
Get this!
First of all you need to get all required tools. As mentioned this tutorial relies on Eclipse. Therefore, you have to download this wonderful IDE (and the de facto standard besides IntelliJ and Netbeans) from its page or through this link (at the moment of writing this tutorial, the current version is 3.5). On the download page you will see many Eclipse packages. Basically it is irrelevant which version you choose, but you have to know that each of them come with different plug-ins doing funny things. For example, the Eclipse Modeling Tools package comes with the whole package of plug-ins and software to support you in making MDA programs. I personally stick with the Eclipse IDE for Java EE Developers package, as everything else can be installed when needed. For your typical Android development even the Eclipse IDE for Java Developers would be enough, if you need to save space. Just download the preferred package from any mirror.
The second thing you need is, of course the Android SDK (currently in version 1.5r3). You can get it from here. Just choose your according operating system and everything is fine. As Eclipse it is used a zip package.
Note: If you do not have Java already installed, download it here and install it as it is a pre-requisite for Eclipse and Android.
Install that!
Now that you have your Eclipse and your Android SDK you can “install” them. I put install in quotation marks because you do not really install any of them. Both are just zip packages you can extract anywhere you like. For me on Windows this would normally be c:/Program Files/. In result you would have a c:/Program Files/eclipse/ and c:/Program Files/android-sdk-windows-1.5_r3/. That is basically the install part as the most important, to also comply to this “non-install” way is done during set up.
Set up!
First of all, start up your Eclipse installation. Depending on your OS you should now how to do this. In the case of Windows just open eclipse.exe. Now Eclipse boots up and will ask you for your workspace. The workspace directory will be the location were all settings and projects for that workspace will be stored. It is totally up to you were to put it. Mine is c:/workspace/android/. I myself separate the overall workspace directory as I have different settings and projects for different circumstances. For instance you could make a /jme/, /java/, /cdt/ etc. But it is up to you. When you selected your workspace Eclipse concludes its boot up and greets you with a nice picture (at least the very first time). You can close this “Welcome” and then you will see the overall Eclipse environment
Eclipse IDE
I will not go over Eclipse in full as it provides MUCH and to describe everything would cost me about 20 years of my life. Good sources for such information is Google, the Eclipse site itself and for plugins Eclipse-Plugins. We will just continue with setting up Eclipse to be able to work with Android and therefore the lessons. We now would have to install the ADT plugin for Eclipse. It can be found here with an installation guide. I will continue here with a guide for Eclipse 3.5 as it is not listed there, but basically works the same. If you have Eclipse 3.3 or 3.4 please follow the instructions on the Android page.
Open Help -> Install New Software…. The window that pops up is to install plug-ins from local or web sources. Normally Eclipse plug-ins come through update sites, which allow a good “keep-up-to-date” functionality. In the Work with field you enter the Android update site for the ADT plug-in, which would be https://dl-ssl.google.com/android/eclipse/. Now press enter and Eclipse should start resolving what could installed from here in the window blow. You can also add the site as a permanent site through the Add button. Everything is the same, but you give away a name for that update site. When Eclipse has found the plug-ins you should see something similar to the image here. Check the whole Developer Tools so that DDMS and ADT are installed. Continue with Next, accept everything and follow the instructions. You will have to restart Eclipse afterwards (even on an OS that is not Windows ^^).
Now that your Eclipse is Android ready you would have to configure the plug-in. Therefore, open Window -> Preferences and select the Android branch. There point the SDK Location field to wherever you extracted the Android SDK. You should see something similar to the figure. I will not go over the rest of the points. Just have a look, most of them are self-explanatory. When you are finished just press OK and the location is stored.
The final step of configuration is to create an Android Virtual Device (AVD). This is basically the image the Emulator will run and install everything to. You can create an AVD with the command tools from Android or by using Eclipse. In Eclipse open Window -> Android AVD Manager. With this Virtual Device Manager you can create and delete AVDs. To create an AVD just enter a descriptive name, select the target of the image and the Skin. The target gives away compatibility preferences. The NeHe Android ports are all developed based on Android 1.5. If you want additional elements like Location-based services, choose the Google API target as it adds this functionality to a 1.5 framework. Just Create AVD and Finish.
Note: Maybe sometimes you want to keep your images clean and only for one project to not install every test on it. In this case you can create several Virtual Devices and select the according one in the Run Configurations under Run -> Run Configurations. Here you can set the target AVD for every Run instance you have.
Eclipse/Android Run Configurations
Import and Begin!
Now that everything is set up you can start download the lessons and import these into your workspace. I provided the lessons as Eclipse projects therefore you can choose to import an existing project into the workspace. Just use the right mouse button in the Package Explorer -> Import -> General/Existing Projects into Workspace and choose either the archived package or if you extracted it already, the super folder to the extracted one. The single or multiple projects in the archive are listed in the window and you can select which to import to your workspace. It is automatically copied and added to it if you click finish.
Note: If the project should have errors (a red cross at the project name) first of all have a look at the “Problems” tab in the lower part. It should state what is wrong and sometimes how to fix it. Possibilities are to right click on the project and choose Android Tools -> Fix Project Properties. If this should not work, refresh the whole project with pressing F5 while the project root node is selected. If this does not work open Project -> Clean and clean all projects. This fires a full rebuild and sometimes resolves some errors. Sometimes you have to configure the Java location in the project properties. Open the properties by right clicking on the project root node. Here select “Java Build Path” and see if there are any problems.
Now, to run the lesson you just right click on the project root node and select Run As -> Android Application. Now, if everything has been configured correctly, Eclipse will start the Emulator and dock onto it to support debugging through the DDMS perspective. The DDMS perspective can be chosen from the upper right or if not already opened from the menu Window -> Open Perspective -> DDMS. The DDMS perspective is important as it allows you to inject for example GPS coordinates for testing purposes as well as it has the LogCat. The LogCat is basically the output window of all messages from the Emulator. For example, if you add a System.out.println() to your source code, it will appear here.
If you run the project, the Emulator should pop up, boot and start your project. You can basically do the same with the Emulator as with an Android device. The only big difference is that a press on the touchscreen is always a press with full amount of pressure. But, scrolling, menus, OpenGL, everything works fine. If you want to switch between vertical and horizontal without the need to set up a new AVD just press Ctrl+F11. Further information for working with Android and Eclipse can be found here, on the official site.
Note: You can leave the Emulator always opened! You do not need to close it every time you start a project with changes again. It will be automatically handled. Only sometimes after many, MANY starts my Emulator has some problems and cannot be connected anymore. But in general you do not need to restart it every time, as the initial boot may take some while. The very first boot of an AVD can take several minutes, so please be patient. If it does not start the project after about 5-10 minutes then try to exit and restart. Sometimes this helps.
DDMS Perspective – Debugging
If any questions should occur, please comment to this page.
分享到:
相关推荐
2.打开android eclipse 安装路径:D:\android-eclipse\eclipse\configuration\org.eclipse.osgi\bundles\5\1\.cp\libs 3.在打开的路径下 找到 ddmlib.jar 替换成 将下载好的ddmlib.jar (替换前先关闭es) 4.重新启动...
(1)安装JDK。版本:1.6址:http://www.oracle.com/technetwork/java/javase/downloads/index.html 安装步骤省略。...(3)安装Eclipse,版本:3.6.1,下载地址:http://eclipse.org/downloads/ 安装步骤省略。
Eclipse安装android插件 ========================================================================= com.android.ide.eclipse.traceview_10.0.1.v201103111512-110841.jar ...
eclipse 安装 android插件的方法
Chapter 4 Installing and Beginning Use of Android Tools Installing Java Development Kit Installing the Android SDK Hello World! Anatomy of an Android Project Drawable Resources Building the Project ...
vlc android eclipse 工程 http://blog.csdn.net/zhutoubenben/article/details/43488187
Eclipse集成Android NDK说明 1 2 为什么要用NDK? 2 3 为什么要集成? 2 4 怎样操作? 2 4.1 预备条件 2 4.1.1 Cygwin 2 4.1.2 Eclipse 2 4.1.3 Eclipse CDT 3 4.1.4 Android SDK 3 4.1.5 Android NDK 3 ...
eclipse如何开发Android:程序下载、环境安装配置
Time for action – setting up your Android device on Windows and Mac OS X Developing with an Android device on Linux Time for action – setting up your Android device on Ubuntu Troubleshooting a ...
该jar包作用:解决eclipse在Android7.0以及7.0以上的手机上无logcat输出 1.将下载好的ddmlib.jar替换到自己ADT的tools目录lib下E:\adt\sdk\tools\lib 2.将下载好的ddmlib.jar替换到自己ADT的configuration目录org....
我自己用的配置文件,用于PHP和android编写 。
下载Android sdk,安装Android SDK---最终帮你完成Eclipse+Android开发环境的安装。 安装完毕教你如何验证JDK安装成功,教你如何验证ADT安装成功,教你如何验证SDK安装成功 另外以图文并茂的方式手把手教你如何...
详细介绍了在eclipse中android项目下c/c++代码的自动编译,和在eclipse中用ant生成ndk需要的jni头文件,加速ndk的开发,因为是原创,费了不少心力和时间,所以设了6分,有人反映太贵了,现在调成3分,这下大家满意了...
Eclipse搭建Android开发环境及新建 新手必备
Android项目eclipse转Android studio常遇到的问题及对应解决方案
eclipse部署android开发环境,详细介绍如何在eclipse中配置android开发环境,一步一步介绍,内容详细,值得下载
了解项目的基本文件目录结构 【原理】 Eclipse安装原理,Android编程方法 【过程】 1. 安装JAVA JDK 下载网址:java.sun./javase/downloads/ 2. 安装Eclipse 下载网址:.eclipse.org/downloads/ 3. 安装Android ...
【长青说安卓】系列专题(七):Eclipse王者归来——如何使用Eclipse调试Android源码 【长青说安卓】系列专题(七):Eclipse王者归来——如何使用Eclipse调试Android源码
android SDK安装详解,android 虚拟平台安装, android与eclipse集成开发
Eclipse for Android Developers (includes Incubating components) https://www.eclipse.org/downloads/packages/release/neon/3/eclipse-android-developers-includes-incubating-components Package Description...