ef143447ad
Example: To generate for the `release` build target and for the `armv7`, `arm64v8` and `x86` architectures, run the commands: ``` cd godot scons -j4 platform=android target=release android_arch=armv7 scons -j4 platform=android target=release android_arch=arm64v8 scons -j4 platform=android target=release android_arch=x86 cd platform/android/java ./gradlew generateGodotTemplates ``` Notes: - The generated build templates will be located in the `godot/bin` directory (i.e: `android_debug.apk`, `android_release.apk`, `android_source.zip`). - The gradle command will only generate templates for the target(s) with available native shared libraries. For example, running the commands above will only generate the `android_release.apk` and `android_source.zip` files. To delete the generated artifacts, the following commands can be used: ``` cd platform/android/java ./gradlew cleanGodotTemplates ```
83 lines
2.5 KiB
Groovy
83 lines
2.5 KiB
Groovy
apply plugin: 'com.android.library'
|
|
|
|
dependencies {
|
|
implementation "com.android.support:support-core-utils:28.0.0"
|
|
}
|
|
|
|
def pathToRootDir = "../../../../"
|
|
|
|
android {
|
|
compileSdkVersion versions.compileSdk
|
|
buildToolsVersion versions.buildTools
|
|
useLibrary 'org.apache.http.legacy'
|
|
|
|
defaultConfig {
|
|
minSdkVersion versions.minSdk
|
|
targetSdkVersion versions.targetSdk
|
|
}
|
|
|
|
lintOptions {
|
|
abortOnError false
|
|
disable 'MissingTranslation', 'UnusedResources'
|
|
}
|
|
|
|
packagingOptions {
|
|
exclude 'META-INF/LICENSE'
|
|
exclude 'META-INF/NOTICE'
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
java.srcDirs = ['src']
|
|
res.srcDirs = ['res']
|
|
aidl.srcDirs = ['aidl']
|
|
assets.srcDirs = ['assets']
|
|
}
|
|
debug.jniLibs.srcDirs = ['libs/debug']
|
|
release.jniLibs.srcDirs = ['libs/release']
|
|
}
|
|
|
|
libraryVariants.all { variant ->
|
|
variant.outputs.all { output ->
|
|
output.outputFileName = "godot-lib.${variant.name}.aar"
|
|
}
|
|
|
|
def buildType = variant.buildType.name.capitalize()
|
|
|
|
def taskPrefix = ""
|
|
if (project.path != ":") {
|
|
taskPrefix = project.path + ":"
|
|
}
|
|
|
|
// Disable the externalNativeBuild* task as it would cause build failures since the cmake build
|
|
// files is only setup for editing support.
|
|
gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType
|
|
|
|
def releaseTarget = supportedTargets[buildType.toLowerCase()]
|
|
if (releaseTarget == null || releaseTarget == "") {
|
|
throw new GradleException("Invalid build type: " + buildType)
|
|
}
|
|
|
|
if (!supportedAbis.contains(defaultAbi)) {
|
|
throw new GradleException("Invalid default abi: " + defaultAbi)
|
|
}
|
|
|
|
// Creating gradle task to generate the native libraries for the default abi.
|
|
def taskName = getSconsTaskName(buildType)
|
|
tasks.create(name: taskName, type: Exec) {
|
|
executable "scons" + sconsExt
|
|
args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
|
|
}
|
|
|
|
// Schedule the tasks so the generated libs are present before the aar file is packaged.
|
|
tasks["merge${buildType}JniLibFolders"].dependsOn taskName
|
|
}
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
path "CMakeLists.txt"
|
|
}
|
|
}
|
|
}
|