Add gradle support to android build script
This commit is contained in:
parent
be00283b2e
commit
ae19ade5e5
5
.gitignore
vendored
5
.gitignore
vendored
@ -56,10 +56,13 @@ android/android-ndk*
|
||||
android/android-sdk*
|
||||
android/assets
|
||||
android/bin
|
||||
android/obj
|
||||
android/build
|
||||
android/libs
|
||||
android/obj
|
||||
android/.gradle
|
||||
android-*
|
||||
*.apk
|
||||
*.keystore
|
||||
|
||||
lib/curl
|
||||
lib/freetype
|
||||
|
@ -31,7 +31,8 @@ after some tweaks, but atm. only linux is supported.
|
||||
|
||||
Dependencies list (may be incomplete):
|
||||
|
||||
autoconf, automake, make, python, ant, imagemagick, cmake, vorbis-tools
|
||||
autoconf, automake, make, python, gradle, ant, imagemagick, cmake,
|
||||
vorbis-tools
|
||||
|
||||
Additionally some dependencies for optimize_data script:
|
||||
|
||||
@ -74,6 +75,13 @@ You can choose build type by setting BUILD_TYPE environment variable to "debug"
|
||||
or "release". The default is debug build. Note that if you choose release build,
|
||||
you have to manually sign the apk with your key and run zipalign.
|
||||
|
||||
Additionally you can choose the build tool by setting BUILD_TOOL environment
|
||||
variable to "gradle" or "ant". Note that ant has been already removed from
|
||||
Android SDK, so you have to use SDK <= 25.2.5 for building with ant. By default
|
||||
the BUILD_TOOL is set to "gradle". It has hardcoded version of SDK build-tools
|
||||
that are set to "25.0.3", so you have to use this particular version (or you can
|
||||
edit build.gradle file).
|
||||
|
||||
Basically if all dependencies are installed in the system, it should be enough
|
||||
to just run:
|
||||
|
||||
|
31
android/build.gradle
Normal file
31
android/build.gradle
Normal file
@ -0,0 +1,31 @@
|
||||
buildscript
|
||||
{
|
||||
repositories
|
||||
{
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies
|
||||
{
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android
|
||||
{
|
||||
compileSdkVersion sdkVersion.toInteger()
|
||||
buildToolsVersion "25.0.3"
|
||||
|
||||
sourceSets
|
||||
{
|
||||
main
|
||||
{
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
jniLibs.srcDirs = ['libs']
|
||||
res.srcDirs = ['res']
|
||||
assets.srcDirs = ['assets']
|
||||
}
|
||||
}
|
||||
}
|
@ -22,16 +22,19 @@ export NDK_ABI_ARMV7=armeabi-v7a
|
||||
export ARCH_ARMV7=arm
|
||||
export HOST_ARMV7=arm-linux-androideabi
|
||||
export NDK_PLATFORM_ARMV7=android-19
|
||||
export SDK_VERSION_ARMV7=19
|
||||
|
||||
export NDK_ABI_X86=x86
|
||||
export ARCH_X86=x86
|
||||
export HOST_X86=i686-linux-android
|
||||
export NDK_PLATFORM_X86=android-19
|
||||
export SDK_VERSION_X86=19
|
||||
|
||||
export NDK_ABI_AARCH64=arm64-v8a
|
||||
export ARCH_AARCH64=arm64
|
||||
export HOST_AARCH64=aarch64-linux-android
|
||||
export NDK_PLATFORM_AARCH64=android-21
|
||||
export SDK_VERSION_AARCH64=21
|
||||
|
||||
|
||||
# A helper function that checks if error ocurred
|
||||
@ -75,16 +78,19 @@ if [ "$COMPILE_ARCH" = "armv7" ]; then
|
||||
export NDK_ABI=$NDK_ABI_ARMV7
|
||||
export ARCH=$ARCH_ARMV7
|
||||
export HOST=$HOST_ARMV7
|
||||
export SDK_VERSION=$SDK_VERSION_ARMV7
|
||||
elif [ "$COMPILE_ARCH" = "x86" ]; then
|
||||
export NDK_PLATFORM=$NDK_PLATFORM_X86
|
||||
export NDK_ABI=$NDK_ABI_X86
|
||||
export ARCH=$ARCH_X86
|
||||
export HOST=$HOST_X86
|
||||
export SDK_VERSION=$SDK_VERSION_X86
|
||||
elif [ "$COMPILE_ARCH" = "aarch64" ]; then
|
||||
export NDK_PLATFORM=$NDK_PLATFORM_AARCH64
|
||||
export NDK_ABI=$NDK_ABI_AARCH64
|
||||
export ARCH=$ARCH_AARCH64
|
||||
export HOST=$HOST_AARCH64
|
||||
export SDK_VERSION=$SDK_VERSION_AARCH64
|
||||
else
|
||||
echo "Unknow COMPILE_ARCH: $COMPILE_ARCH. Possible values are: " \
|
||||
"armv7, aarch64, x86"
|
||||
@ -97,10 +103,12 @@ if [ -z "$BUILD_TYPE" ]; then
|
||||
fi
|
||||
|
||||
if [ "$BUILD_TYPE" = "debug" ] || [ "$BUILD_TYPE" = "Debug" ]; then
|
||||
export BUILD_TYPE="debug"
|
||||
export ANT_BUILD_TYPE="debug"
|
||||
export GRADLE_BUILD_TYPE="assembleDebug"
|
||||
export IS_DEBUG_BUILD=1
|
||||
elif [ "$BUILD_TYPE" = "release" ] || [ "$BUILD_TYPE" = "Release" ]; then
|
||||
export BUILD_TYPE="release"
|
||||
export ANT_BUILD_TYPE="release"
|
||||
export GRADLE_BUILD_TYPE="assembleRelease"
|
||||
export IS_DEBUG_BUILD=0
|
||||
else
|
||||
echo "Unsupported BUILD_TYPE: $BUILD_TYPE. Possible values are: " \
|
||||
@ -108,6 +116,17 @@ else
|
||||
exit
|
||||
fi
|
||||
|
||||
# Check selected build tool
|
||||
if [ -z "$BUILD_TOOL" ]; then
|
||||
BUILD_TOOL="gradle"
|
||||
fi
|
||||
|
||||
if [ "$BUILD_TOOL" != "gradle" ] && [ "$BUILD_TOOL" != "ant" ]; then
|
||||
echo "Unsupported BUILD_TOOL: $BUILD_TOOL. Possible values are: " \
|
||||
"gradle, ant"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Check if we have access to the Android NDK and SDK
|
||||
if [ -z "$NDK_PATH" ]; then
|
||||
export NDK_PATH="$NDK_PATH_DEFAULT"
|
||||
@ -302,5 +321,12 @@ check_error
|
||||
|
||||
# Build apk
|
||||
echo "Building APK"
|
||||
ant $BUILD_TYPE -Dsdk.dir="$SDK_PATH" -Dtarget=$NDK_PLATFORM
|
||||
|
||||
if [ "$BUILD_TOOL" = "gradle" ]; then
|
||||
export ANDROID_HOME="$SDK_PATH"
|
||||
gradle -PsdkVersion=$SDK_VERSION $GRADLE_BUILD_TYPE
|
||||
elif [ "$BUILD_TOOL" = "ant" ]; then
|
||||
ant $ANT_BUILD_TYPE -Dsdk.dir="$SDK_PATH" -Dtarget=$NDK_PLATFORM
|
||||
fi
|
||||
|
||||
check_error
|
||||
|
Loading…
Reference in New Issue
Block a user