Exploring the world of Android :: Part 1

This blog is accidentally find out, it tells the story of one of our friends about the exploration of the Android world, also inspired my Android‘s interest for learning, exclamation unexpectedly have so many people are learning android, hope this article can let you have greater passion to Android.The blog comes from:http://blog.trifork.com/2009/09/08/exploring-the-world-of-android-part-1/,thanks Tom van Zummeren very much.

September 8th, 2009 by Tom van Zummeren

|

For a short while now, I am developing for the Android
platform, which is a mobile phone operating system developed by Google.
The language to use is Java, so at least I didn’t have to learn an
entirely different new language and I can use the tools I already know
and love. I would like to tell you about my ‘adventures’ as I explore
the world of Android

When I first started studying the Dev Guide I soon discovered that the recommended IDE for developing Android applications is Eclipse. Which was a bit disappointing because I don’t like Eclipse that much. But fortunately the kind folks of Google left room for other IDE’s
to develop with. They explain that when you use another IDE you will
have to use all kind of command line tools instead, which they provide.
Those command line tools allow you to compile your code for Android, run
your application in a phone emulator, connect a debugger to your
emulator, view application logs and stuff like that. But what they
didn’t mention, is that if you use Intellij IDEA (which happens to be my favorite IDE) it also provides good support for Android! This makes the use of most provided command line tools superfluous.

Setting up an Android project using IntelliJ

First of all make sure you’re using the right version of IntelliJ. If
you want to develop using Android SDK version 1.5, you have to use
IntelliJ version 8 or greater. For IntelliJ 7 only a very old version of
the plugin available which just won’t work with the latest Android SDK.
And I expect that for future versions of the Android SDK, you will have
to use IntelliJ 9 since the latest version of the Android plugin for
IntelliJ already requires IntelliJ 9.

  1. Create all necessary files for your new project by executing the android command line tool which is explained on this page: http://developer.android.com/guide/developing/other-ide.html#CreatingAProject
  2. Create a new project using File > New project > Create Java project from existing sources. Base your new IntelliJ project on the source files you created earlier. Note: you might want to deselect the “…/yourProject/tests/src
    folder when IntelliJ offers you to make include it as a source folder.
    Also make sure to select the Android facet which will be auto-detected
    by IntelliJ
  3. Open the Run/Debug configurations window (Alt + Shift + F10 > Edit configurations)
  4. Click the button and select “Android” from the top of the list.
  5. Give the configuration a name and select your main “Activity”
  6. That’s it! You can now run the application using an emulator by clicking the or button

If all went well, the emulator started up, launched your application and looks like this:

Note that the first time you start the emulator, it takes a long
time. But luckily, you can leave the emulator open and redeploy your
application while it’s still running. So the second time you deploy your
application on the emulator will happen much quicker.

One final note, to see the emulator logs (for example to view exception stack traces) run the following command: adb logcat.

Using Maven 2 to build your project

It is possible you want to have a build script for your Android project. This is mainly useful for:

  • compiling and deploying the application without using an IDE
  • running unit tests
  • continuous integration

If you now browse through your Android source files, you will notice that a few files are generated for an Ant
build: build.xml, build.properties, default.properties and
local.properties. If you like using Ant you can leave the files there
and use them for your build. If you, like me, rather use Maven 2 do the
following:

  • Delete the above mentioned Ant related files from your project’s source directory
  • Create a Maven 2 build script (pom.xml) following the instructions on this page: http://code.google.com/p/masa/wiki/GettingStarted
  • If you set up the Maven 2 build script correctly, you can build the project using mvn clean install or also deploy it in the emulator: mvn clean install -Dmasa.debug

Version control

One final note if you want to use a version control system like CVS,
Subversion or Git (which is always a good idea). You should check in all
your project’s source files EXCEPT:

  • the gen directory (this is automatically generated by the Android compiler)
  • IntelliJ project files (iml, ipr and iws)

By now you hopefully also have a Maven 2 build set up for the project
so you can now for example set up a build server (TeamCity, Cruise
control, …) using the Maven 2 build and your VCS repository.

To sum up

I explained how to start developing an Android application using
IntelliJ, Maven 2 and version control. I currently am developing an
application using the exact same setup and it’s all working like a
charm. While further developing my Android application I will probably
encounter various challenges which I will soon tell you more about.

TO BE CONTINUED …

Tags: Android, Getting started, Java Posted in: Custom Development

时间: 2024-10-05 23:55:38

Exploring the world of Android :: Part 1的相关文章

Exploring the world of Android :: Part 2

September 17th, 2009 by Tom van Zummeren | And I’m back! Reporting live on the glorious adventures in the exciting world of Android. This blog post is the second one in the Android series. This time with code samples! Yeah! In my first blog post abou

使用calabash测试开源中国Android客户端

Calabash-android是支持android的UI自动化测试框架,前面已经介绍过<中文Win7下成功安装calabash-android步骤>,这篇博文尝试测试一个真实应用:开源中国客户端.目的是和大家一起学习calabash测试工具. 测试环境与源码准备 先介绍一下oschina.net oschina除了有网站,还有三大平台手机客户端: http://www.oschina.net/app 客户端已经开源! 那么开源可以用来做什么呢? 我正在学用calabash-android,得

Android.mk

Android.mk This page describes the syntax of the Android.mk build file, which glues your C and C++ source files to the Android NDK. Overview The Android.mk file resides in a subdirectory of your project's jni/ directory, and describes your sources an

Own your Android! Yet Another Universal Root(二)

利用 目标 直到现在我们已经看出这是一个典型的UAF漏洞并且一个位于用户空间迷途的文件描述符指向内核中的PING 套接字可以被攻击者获得.接下来我们要填充套接字对象,重新使用这个对象.之后我们可以执行内核中任意代码,最终完成Android设备的提权. 实际上,我们使用套接字对象的close函数.当close(sockfd)调用时,内核最终会进入如下代码 int inet_release(struct socket *sock) { struct sock *sk = sock->sk; if (

Android DDMS应用

具体可见http://developer.android.com/tools/debugging/ddms.html. DDMS为IDE和emultor.真正的android设备架起来了一座桥梁.开发人员可以通过DDMS看到目标机器上运行的进程/现成状态,可以 android的屏幕到开发机上,可以看进程的heap信息,可以查看logcat信息,可以查看进程分配内存情况,可以像目标机发送短信以及打电话,可 以像android开发发送地理位置信息.可以像gdb一样attach某一个进程调试. SDK

[share]How to Become a Lazy but Productive Android Developer

How to Become a Lazy but Productive Android Developer How can we optimize throughput time for writing the business logic for the app and avoid lazy code to write? by Paresh Mayani · Dec. 16, 13 · Mobile Zone Like (1) Comment (3) Save Tweet 21.63k Vie

android studio教学视频资源(点开即看)

自从Google推出android studio之后.包含github在内的非常多第三方代码库项目很多其它的採用的android studio编译的.越来越多的项目使用android studio也变成了大势所趋,所以赶紧放下你的eclipse,開始学习android studio吧. 下面是网上搜集的android studio的教学视频.讲的非常具体,全英文中字幕.点开即看. Android Studio Essential Training 内容包含: - Android Studio安装

Android无线测试之—UiAutmator运行命令介绍与快速调试

一.运行命令介绍: #Test.java package com.uiautomatortest; import android.os.Bundle; import android.os.RemoteException; import com.android.uiautomator.core.UiDevice; import com.android.uiautomator.testrunner.UiAutomatorTestCase; public class Test extends UiAu

Introducing Visual Studio&rsquo;s Emulator for Android

原文地址 Microsoft released Visual Studio 2015 Preview this week and with it you now have options for Android development: C++, Cordova, and C# with Xamarin. When choosing one of those Android development options, Visual Studio will also install the bran