Hi, this is YOSHIMURA, researching wearable devices at ATL. I would like to share some Android-type technologies.
When you make something with a wearable device, what tool are you going to use?
When you use a device which uses Android for an OS such as Google Glass and Android Wear, it has some kinds of freedom with development, and with a variety of sensors, you can develop many fun things because it has good compatibility with peripheral devices. Besides that, you can apply the method of Android development with less effort. On the other hand, it is also true a development environment of Android itself looks unattractive compared with other mobile environments.
All of these, however, will be changed after the announcement of a href=”https://developer.android.com/sdk/installing/studio.html” title=”Android Studio | Android Developers”>Android Studio as an alternative environment with Eclipse by Google I/O 2013.
Integrated smart build tool Gradle and Android-type features such as layout preview and debugger into IntelliJ IDEA with almighty autocomplete function and high refactoring support function, this environment plays a central role in Android development by solving engineers’ complaints and frustration about Eclipse-based environments.
I will show you a set of flow from installation to debug this time since you don’t still see this information about Android Studio in Japanese.
This article will be mainly for Mac users. Sorry for those people who were hoping for the information with Windows/*nix.
Download and install it from Google by choosing the latest version. The latest version at this time was 0.8.6 but I use 0.8.0 for this entry.
Finish it by opening the dmg and installing the application into /Applications for Mac.Finish it by opening the dmg and installing the application into /Applications for Mac.
Let’s build a sample now. If you have a sample code with API 19 and later, you will be able to build it with ease with Android Studio.
/Applications/Android Studio.app/sdk/samples/android-19/sensors/BatchStepSensor to a directory and choose the directory by selecting Import Project from Android Studio.
Soon, you will see the project has incorporated.
Oh, an error occurs. This is because the version of Android Gradle Plugin is old, so update the version. Android Gradle Plugin is closely related with the version of Build Tools, so update the buildToolsVersion in order to use the latest version 19.1 or later.
In this way, when you change the Gradle-type file, click the icon with the Gradle logo falling down, and apply the environmental change to Android Studio.
You can also select Tools > Android > Sync Project with Gradle Files; either way is okay.
Once you have finished this, build with Ctrl+R (Run > Run ‘…’) and execute it.
Okay, so you can finish executing it with these steps above. Let’s move on to link break point but before that, we need to attach a debugger.
Android Studio is an integrated development environment as Eclipse, which allows you to start executing just by pressing Ctrl+D.
Does it work okay? Were you able to execute it?
If you have done this before, you may have noticed this already; there is a weak point that the executing speed gets definitely slow when you attach debugger to an application with Eclipse or Android Studio.
Unfortunately, there is no radical solution to this.
In Android development use a static debug method with marks as much as possible. When you really need to use is, I think it is the best to call Debugger from here By using Debug#waitForDebugger().
In order to make a released package, you need to do some settings such as ProGuard and signature.
Next, we will build a package. Execute Gradle direly to make the package since Android Studio unlike Eclipse is not built by itself and it leaves it all to Gradle.
Type command as Tools > Open Terminal as seen below.
bash ./gradlew assembleRelease
Once you have finished it all, a file as build/outputs/apk/BatchStepSensorSample-release.apk. is created, so release this.
So, how do you feel about this? For those who are familiar with developing Android as before, I think some like this and others do not like this because there are lots of differences between what they used to do. However, once you get used to it, functions such as Autocomplete functions, refactoring support functions, and layout tools will be useful. So, use this until it fits in hands.
What I personally appreciate the most is that the build tool is separated from Gradle. Although Gradle still has big problems such as big memory consumption, I am extremely satisfied with Gradle because it supports parallel operations of builds compared with previous Ant, it prepares libraries just with writing names like Maven, and the build file gets easier to read, etc.
Once you have got used to this tool, you cannot make development with Eclipse or Ant-based tools any more unless you have a special reason. Actually Google itself seems to give up ADT, so switch your style into this modern Android development style for this opportunity.