Tuesday, April 9, 2013

Install Eclipse Android plugin


Android Eclipse plugin:
There are detailed instructions here: http://developer.android.com/sdk/eclipse-adt.html
To install it, inside Eclipse go to Help > Install New Software...
eclipse plugins
Click 'Add...' and enter the following info:
Name: Android SDK
Location: https://dl-ssl.google.com/android/eclipse/
android eclipse plugin info
Press 'OK' and select the new repository in the "Work with:" drop down box in case it's not already selected.
Under the "Developer Tools" section, select "Android Development Tools" and "Android DDMS". It doesn't hurt to have the other ones, but they're not required.
Under "NDK Plugins", select "Android Native Development Tools".
eclipse_android_plugin2
Press 'Next' until you get to the "Review Licenses" screen. Check the "I accept the terms of the license" checkbox and press 'Finish'. Eclipse will download and install the Android plugins. Once it finishes press 'Yes' in the popup to restart Eclipse.
i) Set Eclipse Java compiler compliance to 1.6:
In the last version of Eclipse the Java compatibility should be set to version 6. You can check this in Window > Preferences > Java > Compiler. (Preferences is in the Eclipse menu for OS X.)
The compiler compliance settings should be set to 1.6.
j) Configuring the Android plugin:
Once we have installed the Android plugin we need to tell it where to find the SDK. In Eclipse go to Window > Preferences > Android (or Eclipse > Preferences for OS X) and set the SDK location by browsing to the folder where you uncompressed the SDK before.
android_prefs
Now Eclipse knows where the SDK is.
Next you'll need to install the API files and optionally create an emulator to be able to test programs without uploading to the phone. Press the Android button in the Eclipse toolbar, or go to Window > Android SDK Manager:
android_button
First you need to install the SDK platform-tools and API package. Just click on the "Tools" tab and select the box for Android SDK Platform-tools. Then click on the "Android 4.2 (API 17)" tab and select the box for SDK Platform. It's important to use SDK version 4.2 (API 17) since the makefiles are configured for that version. It doesn't matter what version of the Android OS you want to develop for, apps are compiled using SDK 4.2, but they should work on any phone that is at least 2.2.
Once that is done you can create a new virtual device (AVD). Just select a name, the target Android version and a size for the virtual SD card.
k) Import openFrameworks into Eclipse:
Now that Eclipse has been completely configured to work with openFrameworks for Android, the last step is to import all the projects in the workspace. Go to File > Import and select General > Existing projects in the workspace...
import first screen
Import in this order:
Please note you should not mark "Copy projects into workshpace" on the import screen as this will cause problems building a project.
  • openFrameworks/libs
  • openFrameworks/libs/openFrameworks
  • openFrameworks/addons/ofxAndroid/ofAndroidLib
  • openFrameworks/examples/android
l) Compile openFrameworks:
In the "Project Explorer" on the left side of the window, select the openFrameworks project. Choose the Android target in Project > Build Configurations > Set Active, and then click Project > Build Project. You can also do this from the toolbar by switching to the C/C++ perspective and clicking the toolbar button with a hammer.
OS X seems to be missing pkg-config. Currently this doesn't seem to affect the build, since these commands were only important in detecting Linux libraries.
m) Enable development in your device: Enable USB debugging: Settings > Applications > Development > USB Debug (On Ice Cream Sandwich, this is in Settings > Developer options > USB Debugging). The device needs to be disconnected from the computer while you do this.
n) Connect the device now:
If you attempt to run your project and you don't have a device attached, Eclipse will start the Android emulator for you.
Linux users: adb needs permissions to access the USB device, follow the instructions here to fix your device permissions:
o) Now install and run an example project on the device:
  • Connect the device.
  • Check that it is being detected and restart adb server if necessary.
  • Select the AndroidRelease target. You can pick a target at Project > Build Configurations > Set Active.
  • Make sure you have your project selected and press the play button in the toolbar or Run > Run As > Android Application.
Note: If you get an error about an obsolete build.xml (or connected with that file), you can safely delete the build.xml file and recreate it using 'android update project -p <path-to-project>'. (The 'android' tool is at SDK_DIR/tools/android.) You may also need to do this for openFrameworks/addons/ofxAndroid/ofAndroidLib.
If everything went OK, the example should start on the device.

No comments:

Post a Comment