Android

From 太極
Revision as of 14:34, 2 February 2014 by Brb (talk | contribs)
Jump to navigation Jump to search

SDK

http://developer.android.com/sdk/index.html#ExistingIDE

Redhat

At the step of Running your app I cannot run app from Eclipse. The command line way does not work.After several tries, it seems the RHEL does not have an updated Ant package (currently it is 1.7 but I need 1.8). Give up.

Ubuntu

Download the bundle version. The file name I got is <adt-bundle-linux-x86_64-20131030.zip>.

On 64-bit Ubuntu, we need to run

sudo apt-get install libstdc++6:i386 lib32z1 lib32ncurses5 lib32bz2-1.0

For both 32-bit and 64-bit, we need to get openjdk

sudo apt-get install openjdk-6-jre openjdk-6-jdk icedtea6-plugin

Then uncompress <adt-bundle-linux-xxx.zip> and run the file <eclipse> from either file manager or command line. It just works!

We can furthermore set up the PATH variable by editing ~/.bashrc file.

export PATH=$PATH:~/adt-bundle-linux-x86_64-20131030/sdk/platform-tools/
export PATH=$PATH:~/adt-bundle-linux-x86_64-20131030/sdk/tools/

Then source the file by

source ~/.bashrc

A good reference is https://help.ubuntu.com/community/AndroidSDK.

Windows

Genymotion

Genymotion is a complete set of tools that provides a virtual environment for Android. Genymotion is much better than the ADV included in Android SDK. Before we use download/use it, we need to register.

For some reason, on my Ubuntu 12.04, I need to run the following.

sudo apt-get install ia32-libs

The genymotion can be integrated into Eclipse. The document about genymotion can be found on https://cloud.genymotion.com/page/doc/

Qt + Android

Installation

On Ubuntu we can install requirements by

  • SDK -> No need to download a special copy. Just use adt-bundle-linux-x86-2013xxxx one.
  • Apache Ant -> sudo apt-get install ant
  • NDK -> android-ndk-r9c-linux-x86.tar.bz2. Use tar -xjvf android-ndk-r9c-linux-x86.tar.bz2 to extract.
  • Download qt-linux-opensource-5.2.0-android-x86-offline.run and install it into a new location, eg ~/Qt5.2.0Android (Cannot be the same as Desktop version).
  • On a new machine, we need to install opengl library as instructed here and here.
sudo apt-get install mesa-common-dev
sudo apt-get install libglu1-mesa-dev -y

The Qt needs to change the setting from Tools > Options > Android where we can specify the locations of Android SDK, Android NDK, Ant and JDK. On Tools > Options > Devices, we can change the Device from default (Local PC) to Run on Android. See the instruction on qt.project.org. Basically we go to project's setting to do changes. It does take a little longer to get the app on device.

Help, Applications

Books/Tutorials

Android Programming: The Big Nerd Ranch Guide

It seems the solution files still have bugs. For example in Chapter 1 "01_FirstApp", the <layout/activity_quiz.xml> file should have

android:text="@string/question_text_view"

instead of

android:id="@+id/question_text_view"

within <TextView> tag.

TheNewBoston and another author's website

Useful Apps

Network Signal Info

Play store

CPU-Z

Github

The source code is hosted on https://github.com/github/android

Basic(s)

Check connected devices

Enable USB debugging on your device first.

$ sdk/platform-tools/adb devices
List of devices attached 
2011060116402004	device

Where to find the apk files on devices

See here. It is located under /data/app/.

How to uninstall/delete apk files on devices

http://www.botskool.com/geeks/how-uninstall-apk-files-android-windows-sdk-emulator

cd SDK/tools
adb shell ls data/app
adb shell rm data/app/com.androidcan.asudoku.apk

Failed to install HelloWorld.apk on device (null) Error

http://stackoverflow.com/questions/5229906/android-failed-to-install-helloworld-apk-on-device-null-error

Solution: Try changing the ADB connection timeout. I think it defaults that to 5000ms and I changed mine to 10000ms to get rid of that problem. If you are in Eclipse, you can do this by going through Window -> Preferences and then it is in DDMS under Android.

Build without running an application

Building vs running: Building will just generate apk file but running will install the app to the device.

See here. In Eclipse menu, Windows -> Preferences. From this Preferences window: Android -> Build. Now uncheck "Skip packaging and dexing until export or launch. (Speeds up automatic builds on file save.)". From now on, as long as we save any changes in source files, the apk file will be recreated.

Modified the 'name' shown on Eclipse Package Explorer

Modify the name tag in <.project> file (hidden file).