From 4e982d30a15f04ac841b9e9669fa2dab5eef900b Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 2 Sep 2010 03:40:02 +0000 Subject: Extend android.make so that it can generate a debug signed apk. 'make && make apk && adb install -r bin/Rockbox.apk' should work now. You should now be able to develop without eclipse. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27980 a1c6a512-1295-4272-9138-f99709370657 --- android/README | 44 ++++++++++++++++-------------- android/android.make | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 97 insertions(+), 24 deletions(-) diff --git a/android/README b/android/README index c22ab604d1..04436b3c65 100644 --- a/android/README +++ b/android/README @@ -3,39 +3,41 @@ application for android. * Prerequisites -Download and install the Android SDK[1] and NDK[2]. After you extracted the SDK, you need to run /tools/android in order to install the actual platform sdk from the available packages tab (SDK Platform Android 1.5 or above should work). In the virtual devices tab you can also setup a emulator. +Download and install the Android SDK[1] and NDK[2]. +After you extracted the SDK, you need to run /tools/android in order to +install the actual platform sdk from the available packages tab (SDK Platform +Android 1.5 or above should work). +In the virtual devices tab you can also setup a emulator. -Then, make sure you have the ANDROID_NDK_PATH (pointing to the NDK's root directory) environment variable set up, -otherwise configure will fail to find the compiler. - +Then, make sure you have the ANDROID_SDK_PATH and ANDROID_NDK_PATH (pointing to +the each's root directory) environment variables set up, otherwise configure will fail to find the compiler and +compiling the java files will fail. * Build instructions -Until there's a script which does all the work the procedure is documented here. - Use this as your build folder, using '../tools/configure' etc. - $ ../tools/configure + $ ../tools/configure # type 200, then chose A for android and your screen resolution $ make -After the build finished, you need to copy librockbox.so to libs/armeabi/ (create that dir if it doesn't exit) - $ mkdir -p libs/armeabi - $ cp librockbox.so libs/armeabi - -For the other files (codecs, themes), you execute 'make zip'. Then you copy the -zip to libs/armeabi, using the name libmisc.so. This is needed, since there's no -way to bundle stuff into apk's and have access to them from native code other -than pretending it was a library. - $ make zip - $ cp rockbox.zip libs/armeabi/libmisc.so +After the build finished, you can create a Rockbox.apk in bin/ + $ make apk -rockbox.zip..err, libmisc.so will be unpacked at runtime. +You can install that on the device + $ $ANDROID_SDK_PATH/tools/adb install -r bin/Rockbox.apk -To finish, you can follow this guide [3], or use eclipse. Simply install eclipse -and the android plugins, then import this folder as a new Android project and run it. -See [4] for a guide on how to set up eclipse for android development. +NOTE: make apk needs creates a debug signed .apk, not suitable for distribution. +It expects that this key already exists. +You should be able to generate it with "keytool" using the following options: +* Keystore name: "debug.keystore" +* Keystore password: "android" +* Key alias: "androiddebugkey" +* Key password: "android" +* CN: "CN=Android Debug,O=Android,C=US" +* validity: 365 days +Google docs mention the SDK tools can generate it as well, but I haven't found how yet. [1]: http://developer.android.com/sdk/index.html [2]: http://developer.android.com/sdk/ndk/index.html diff --git a/android/android.make b/android/android.make index e87ba39793..a6a7e675be 100644 --- a/android/android.make +++ b/android/android.make @@ -7,10 +7,81 @@ # $Id$ # -# pretty empty here: android port has no additional .c files to compile, -# but a different rule for the final librockbox.so - +.SECONDEXPANSION: # $$(JAVA_OBJ) is not populated until after this .SECONDEXPANSION: # $$(OBJ) is not populated until after this + $(BUILDDIR)/$(BINARY): $$(OBJ) $(VOICESPEEXLIB) $(FIRMLIB) $(SKINLIB) $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) + +PACKAGE=org.rockbox +PACKAGE_PATH=org/rockbox +ANDROID_DIR=$(ROOTDIR)/android + + +java2class = $(addsuffix .class,$(basename $(subst $(ANDROID_DIR),$(BUILDDIR),$(1)))) + +ANDROID_PLATFORM_VERSION=8 + +ANDROID_PLATFORM=$(ANDROID_SDK_PATH)/platforms/android-$(ANDROID_PLATFORM_VERSION) +AAPT=$(ANDROID_PLATFORM)/tools/aapt +DX=$(ANDROID_PLATFORM)/tools/dx +APKBUILDER=$(ANDROID_SDK_PATH)/tools/apkbuilder +ZIPALIGN=$(ANDROID_SDK_PATH)/tools/zipalign + + +MANIFEST := $(ANDROID_DIR)/AndroidManifest.xml + +R_JAVA := $(BUILDDIR)/gen/$(PACKAGE_PATH)/R.java +R_OBJ := $(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class + +JAVA_SRC := $(wildcard $(ANDROID_DIR)/src/$(PACKAGE_PATH)/*.java) +JAVA_OBJ := $(call java2class,$(subst /src/,/bin/,$(JAVA_SRC))) + +LIBS := $(BUILDDIR)/libs/armeabi/$(BINARY) $(BUILDDIR)/libs/armeabi/libmisc.so +TEMP_APK := $(BUILDDIR)/bin/_Rockbox.apk +APK := $(BUILDDIR)/bin/Rockbox.apk + +$(R_JAVA): $(MANIFEST) + $(call PRINTS,AAPT $(subst $(BUILDDIR)/,,$<))$(AAPT) package -f -m -J $(BUILDDIR)/gen -M $(MANIFEST) -S $(ANDROID_DIR)/res -I $(ANDROID_PLATFORM)/android.jar -F $(BUILDDIR)/bin/resources.ap_ + +$(BUILDDIR)/bin/$(PACKAGE_PATH)/R.class: $(R_JAVA) + $(call PRINTS,JAVAC $(subst $(BUILDDIR)/,,$<))javac -d $(BUILDDIR)/bin \ + -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin -sourcepath \ + $(ANDROID_DIR)/gen:$(ANDROID_DIR)/src $< + +$(BUILDDIR)/bin/$(PACKAGE_PATH)/%.class: $(ANDROID_DIR)/src/$(PACKAGE_PATH)/%.java + $(call PRINTS,JAVAC $(subst $(BUILDDIR)/,,$<))javac -d $(BUILDDIR)/bin \ + -classpath $(ANDROID_PLATFORM)/android.jar:$(BUILDDIR)/bin -sourcepath \ + $(ANDROID_DIR)/gen:$(ANDROID_DIR)/src $< + +classes: $(R_OBJ) $(JAVA_OBJ) + +$(BUILDDIR)/bin/classes.dex: classes + $(call PRINTS,DX $(subst $(BUILDDIR)/,,$@))$(DX) --dex --output=$@ $(BUILDDIR)/bin + +dex: $(BUILDDIR)/bin/classes.dex + +$(BUILDDIR)/libs/armeabi/$(BINARY): $(BUILDDIR)/$(BINARY) + $(call PRINTS,CP $(BINARY))cp $^ $@ + +$(BUILDDIR)/_rockbox.zip: zip + $(SILENT)mv $(BUILDDIR)/rockbox.zip $@ + +$(BUILDDIR)/libs/armeabi/libmisc.so: $(BUILDDIR)/_rockbox.zip + $(call PRINTS,CP rockbox.zip)cp $^ $@ + +libs: $(LIBS) + +$(TEMP_APK): libs dex + $(call PRINTS,APK $(subst $(BUILDDIR)/,,$@))$(APKBUILDER) $@ \ + -u -z $(BUILDDIR)/bin/resources.ap_ -f $(BUILDDIR)/bin/classes.dex -nf $(BUILDDIR)/libs + +$(APK): $(TEMP_APK) + $(SILENT)rm -f $@ + $(call PRINTS,SIGN $(subst $(BUILDDIR)/,,$@))jarsigner \ + -keystore "$(HOME)/.android/debug.keystore" -storepass "android" \ + -keypass "android" -signedjar bin/__Rockbox.apk $^ "androiddebugkey" + $(SILENT)$(ZIPALIGN) -v 4 bin/__Rockbox.apk $@ > /dev/null + +apk: $(APK) -- cgit v1.2.3