diff --git a/.gitignore b/.gitignore index 88fabfd7..a20ef43d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,13 @@ libttsespeak.so android/res/raw/espeakdata.zip android/res/raw/espeakdata_version +local.properties + +# android gradle output: + +.gradle/ +build/ + # autotools AUTHORS diff --git a/Makefile.am b/Makefile.am index 6fe3af95..7c42de2d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,7 +23,7 @@ EXTRA_DIST += ChangeLog ##### standard build actions: -all: src/speak src/libespeak.so src/libespeak.a src/espeak src/espeakedit espeak-data/phontab dictionaries docs/speak_lib.h +all: jni espeakdata apk-release install: cd src && make DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) BINDIR=$(BINDIR) INCDIR=$(INCDIR) LIBDIR=$(LIBDIR) install && cd .. @@ -31,6 +31,7 @@ install: clean: cd src && rm -f *.o *~ && cd .. + cd android && gradle clean distclean: clean cd src && rm -f libespeak.a libespeak.so.* speak espeak espeakedit && cd .. @@ -123,6 +124,12 @@ espeak-data/phontab: src/espeakedit espeak-data/dictsource/dir.stamp espeak-data jni: cd android && ndk-build +apk-release: + cd android && gradle assembleRelease + +apk-debug: + cd android && gradle assembleDebug + android/res/raw/espeakdata.zip: espeak-data/phontab dictionaries mkdir -pv android/res/raw rm -f $@ @@ -133,8 +140,7 @@ android/res/raw/espeakdata.zip: espeak-data/phontab dictionaries android/res/raw/espeakdata_version: android/res/raw/espeakdata.zip sha1sum $< | awk '{ print $$1 }' > $@ -android: \ - jni \ +espeakdata: \ android/res/raw/espeakdata.zip \ android/res/raw/espeakdata_version diff --git a/README.md b/README.md index 0fa472de..d3b113a4 100644 --- a/README.md +++ b/README.md @@ -17,40 +17,59 @@ If you are building with Eclipse, you will also need: 1. Eclipse 2. Android Developer Tools (ADT) for Eclipse -If you are building on the command line, you will also need: +If you are building on the command line, you will also need either: -1. ant (e.g. run `sudo apt-get install ant` on a Debian-based distribution) +1. ant (e.g. run `sudo apt-get install ant` on a Debian-based distribution), or +2. gradle 1.6, which can be installed from the + [Ubuntu PPA](https://launchpad.net/~cwchien/+archive/gradle/+files/gradle_1.6-0ubuntu1_all.deb) + debian file (including on Debian systems) -## Building eSpeak +## Building with Gradle -The eSpeak language data file and the JNI bindings needed for the Android -APK can be build using the following commands: +1. Set the location of the Android SDK: - $ ./autogen.sh - $ ./configure --prefix=/usr - $ make android + $ export ANDROID_HOME= +2. Build the project: -## Building the APK with Eclipse + $ ./autogen.sh + $ ./configure + $ make -1. Open Eclipse. -2. Create a new workspace. -3. Import the espeak folder as an exising Android project. -4. Build the espeak apk within Eclipse. +This will create an `android/build/apk/espeak-release-unsigned.apk` file. + +## Building with Eclipse + +1. Build the JNI binding and espeak data file by running: + + $ ./autogen.sh + $ ./configure + $ make jni espeakdata +2. Open Eclipse. +3. Create a new workspace. +4. Import the espeak folder as an exising Android project. +5. Build the espeak apk within Eclipse. The generated `eSpeakActivity.apk` can be installed like any other apk build via eclipse, such as by using the `Run` menu option. -## Building the APK from the Command Line +## Building with Ant -1. Update the project using the Android utility which is part of the SDK: +1. Build the JNI binding and espeak data file by running: + + $ ./autogen.sh + $ ./configure + $ make jni espeakdata +2. Update the project using the Android utility which is part of the SDK: $ cd android $ android update project -s -t 1 -p . -2. Build the package. +3. Build the package. $ ant release -In order to install the built `bin/eSpeakActivity-release-unsigned.apk` APK, +## Signing the APK + +In order to install the built APK (e.g. `bin/eSpeakActivity-release-unsigned.apk`) you need to self-sign the package. You can do this by: 1. Creating a certificate, if you do not already have one: @@ -66,6 +85,8 @@ you need to self-sign the package. You can do this by: $ zipalign 4 bin/eSpeakActivity-release-unsigned.apk \ bin/eSpeakActivity-release-signed.apk +## Installing the APK + Now, you can install the APK using the `adb` tool: $ adb install -r bin/eSpeakActivity-release-signed.apk diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 00000000..3d2eff65 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,27 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:0.4.2' + } +} + +apply plugin: 'android' + +android { + buildToolsVersion '17.0' + compileSdkVersion 17 + + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + res.srcDirs = ['res'] + } + } +} + +tasks.withType(com.android.build.gradle.tasks.PackageApplication) { + pkgTask -> pkgTask.jniDir new File(projectDir, 'libs') +} diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 00000000..10485fa2 --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'espeak'