JDK and Android SDK Installation on Ubuntu


I’ve been developing Android application on Windows. But recently, I tried to create an environment in Linux (Ubuntu/Xubuntu). In this article, I will describe the installation of JDK and Android SDK that is required before installing IDE. (It is assumed that without the use of ADT Bundle, we install separately JDK/SDK and IDE.)

Installation of JDK

JDK is updated frequently. So I looked for package management. Then I found that Oracle Java (JDK) 6 / 7 / 8 Installer PPA : “WebUpd8” team provides PPA. This PPA downloads and run the Oracle installer.

Install as follows. Along the way, you are prompted to agree to Oracle license. Then agree.

In the last line, you are sure the installation was successful.
At the result, in my environment, the JDK is installed in /usr/lib/jvm/java-7-oracle.

Installation of Android SDK

Following Android SDK | Android Developers, I have installed the Android SDK.

  1. First, there is the following entry in SYSTEM REQUIREMENTS – Linux.

    64-bit distributions must be capable of running 32-bit applications.

    My Environment is 64bit-Xubuntu. So I installed ia32-libs. (It is not necessary for 32bit OS.)

  2. Next, from DOWNLOAD FOR OTHER PLATFORMS, download Linux 32 & 64-bit package. (Suppose /home/hoge/Downloads/android-sdk_r21.1-linux.tgz)
    * Currently, there is a package called ADT Bundle environment, including Eclipse. However, in this article, it is assumed that you install IDE separately.
  3. In the home directory, make appropriate directory (here, suppose “Development”), and extract files there.

  4. It is useful to make a path to “tools” directory. So add the following line in ~/.bashrc.

    In order to apply the path, do the following.

  5. Update the SDK. (Because SDK for all platform will be downloaded, it will take a lot of time.)

  6. Start the SDK Manager to check the results. (In my environment, the sources has not been downloaded. So I downloaded them.)

  7. For other commands for android, check with –help option.

After this, you can set up favorite IDE, such as IntelliJ or Eclipse, and start development.

[Reference Sites]

[Relative articles]


Log folder of Proguard and .gitignore on IntelliJ


In Android development, output folder of logs of Porguard is different between Eclipse and IntelliJ. In this article, I will explain the difference and managing of Git.

Proguard and Log Files

Proguard is a Java obfuscator and optimizer. You can use it by preparing a little on Eclipse or IntelliJ. Then, if you export a signed “.apk”, log files of proguard are output. In the log files, mapping ifnormation, etc. are recorded. You can use them on debug of the exported “.apk”.

In Eclipse, a folder named “proguard” is made under the project folder as below. Log files will be output in it.
eclipse_proguard_log_compressed

On the other hands, in IntelliJ, the log folder is “proguard_logs”.
intellij_proguard_log

For now, we can not seem to specify the folder of our choice.(YouTRACK:Change Proguard logs output dir)

Git and Logs

To export “.apk” and to modify sources are not one-to-one correspondence. So you should not manage the logs in version control system. (You should save them on release.)

In Git, defining a file named “.gitignore”, you can exclude files to unmanage. You may get a template of “.gitignore” for android from GitHub:A collection of useful .gitignore templates, Android.gitignore. In current version, it support Eclipse and InttelliJ.

However, to support Proguard logs, the templates include definition for Eclipse, but not for IntelliJ. So you should add lines as below.

*2013/04/09 Supplement: Than before, I had to add this PullReques to github. From joeblau, I got a comment that my suggestions have been merged into templates generated by gitignore.io. (add Proguard folder generated by Intellij to Android.gitignore by junf · Pull Request #543 · github/gitignore)
gitignore.io is a service that will automatically generate “.gitignore” for your environment.


To clear the strikethrough of deprecated method in Eclipse


Android is upgraded frequently. Therefore, it is often the case that the old API methods is deprecated and a new method is recommended. Now, it is likely that API methods which have been adopted since 3.x (Honeycomb) is recommended and methods which can be used even less than 2.x are deprecated.

I think that if you can accommodate the situation by Support Library, it is the best to use new API. However, if the method is not supported by the library, you are not forced to use the old API. (At least, Gingerbread has a market share close to 50% yet. For more information, please refer to Dashboards.)

If you use the old methods deprecated in Eclipse, code becomes difficult to read because the “strikethrough” is marked with in the default setting. Then this does not disappear even with the @SuppressWarnings(“deprecation”).

I do not think that even without “strikethrough” you are troubled, because the lint will mark the following warning.
deprecated_method

So I tried to check the settings to turn off the “strikethrough”.

At development of Java (Including Android), to turn off the “strikethrough” for the deprecated method is as easy as following.

  1. Open the menu Window > Preferences > Java > Editor > Syntax Colorling
  2. In Element, select “Deprecated members
  3. Remove the check mark of Enable
  4. Click Apply

syntax_coloring-en
Alternatively, It is a good idea that leaving “Enable”, change the Color or change “Strikethrough” to “Underline”. Of course, if the recommended alternative method is available you should take advantage of that.