3.2 KiB
Building Android
Building localy
Steps if you have Netbeans setup for Android or want to do that.
-
Setup Netbeans for Android development.
- Download and install JDK (be sure to set JAVA_HOME - it will be important for the SDK).
- Download and install Netebeans.
- Download and install Android SDK (do NOT use ADT boundle).
- Download and install NBAndroid: http://www.nbandroid.org/p/installation.html
- Set path of Android SDK in Netbeans (for installation for all users this is:
c:\Program Files (x86)\Android\android-sdk\).
-
Install Phonegap:
- Add to Windows PATH Android SDK tools:
;C:\...[android-sdk]\platform-tools;C:\...[android-sdk]\tools - Copy ANT home from Netbeans and add it your PATH too.
- Add Java bin to PATH:
;%JAVA_HOME%\bin;%ANT_HOME%\bin
- Add to Windows PATH Android SDK tools:
-
Install cordova command line
- Install node.js.
- Install cordova command line:
npm install -g cordova -
Create and build test project to check command line tools:
cordova create hello com.example.hello "Hello World" cd hello cordova platform add android cordova build -
To open project in Netbeans just use Open Project and in the folder you created the project navigate to platforms\android.
-
Add the plugin following instructions from this page: https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner
Preparing for PhoneGap Build
The process may vary depending on version of Zxing project, but base steps should be the same.
- Get latest zxing-android project and create a LibraryProject from that:
- Checked out zxing-android from SVN (http://zxing.googlecode.com/svn/trunk/).
- Overlayed the source from zxing-core.
- Set to library project.
- Change intent names to avoid conflict with ZXing app.
- Remove two lines from AndroidManifest.xml to avoid shortcuts being created.
- Update plugin.xml with any needed resources (you can use
plugin.xml.generate.phpto generate some stuff for Android). - Refactor LibraryProject for usage with PGB:
- Commented out call to showHelpOnFirstLaunch (it will probably not work anyway).
- Replace R class with FakeR class calls (this is needed beacuse R class will be in a different namespace).
- Add FakeR initialization in each class it was added (note that if some classes extened other then you might want to add a protected fakeR variable to their parent - see e.g. ResultHandler class and it's children).
- Build LibraryProject, rename and copy it.
Building with plugman
Plugman is a Node.js tool used by PG Build.
Workflow for creating and building example project with the plugin:
-
Create and build example project:
cordova create hello com.example.hello "Hello World" cd hello cordova platform add android cordova build -
Copy plugin files to "hello\plugins\barcodescanner".
-
Install the plugin (current dir. being "hello"):
plugman --plugins_dir plugins --plugin barcodescanner --platform android --project platforms\android -
Build & deploy Android project with whatever Android IDE (or ANT + ADK tools).