android-project/app/build.gradle
author Sylvain Becker
Sun, 11 Aug 2019 15:23:37 +0200
changeset 13006 4a410f099040
parent 12549 787e86a461f5
permissions -rw-r--r--
Fixed bug 3918 - CMake support for android project
cole@11854
     1
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
cole@11854
     2
def buildAsApplication = !buildAsLibrary
cole@11854
     3
if (buildAsApplication) {
cole@11854
     4
    apply plugin: 'com.android.application'
cole@11854
     5
}
cole@11854
     6
else {
cole@11854
     7
    apply plugin: 'com.android.library'
cole@11854
     8
}
slouken@11647
     9
slouken@11647
    10
android {
slouken@12141
    11
    compileSdkVersion 26
slouken@11647
    12
    defaultConfig {
cole@11854
    13
        if (buildAsApplication) {
cole@11854
    14
            applicationId "org.libsdl.app"
cole@11854
    15
        }
sylvain@12549
    16
        minSdkVersion 16
slouken@12141
    17
        targetSdkVersion 26
slouken@11647
    18
        versionCode 1
slouken@11647
    19
        versionName "1.0"
slouken@11649
    20
        externalNativeBuild {
slouken@11649
    21
            ndkBuild {
sylvain@12549
    22
                arguments "APP_PLATFORM=android-16"
slouken@12364
    23
                abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
slouken@11649
    24
            }
sylvain@13006
    25
            // cmake {
sylvain@13006
    26
            //     arguments "-DANDROID_APP_PLATFORM=android-16", "-DANDROID_STL=c++_static"
sylvain@13006
    27
            //     // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
sylvain@13006
    28
            //     abiFilters 'arm64-v8a'
sylvain@13006
    29
            // }
slouken@11649
    30
        }
slouken@11647
    31
    }
slouken@11647
    32
    buildTypes {
slouken@11647
    33
        release {
slouken@11647
    34
            minifyEnabled false
slouken@11647
    35
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
slouken@11647
    36
        }
slouken@11647
    37
    }
cole@11854
    38
    if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
cole@11854
    39
        sourceSets.main {
cole@11854
    40
            jniLibs.srcDir 'libs'
slouken@11649
    41
        }
cole@11854
    42
        externalNativeBuild {
cole@11854
    43
            ndkBuild {
cole@11854
    44
                path 'jni/Android.mk'
cole@11854
    45
            }
sylvain@13006
    46
            // cmake {
sylvain@13006
    47
            //     path 'jni/CMakeLists.txt'
sylvain@13006
    48
            // }
cole@11854
    49
        }
cole@11854
    50
       
slouken@11647
    51
    }
slouken@11647
    52
    lintOptions {
slouken@11647
    53
        abortOnError false
slouken@11647
    54
    }
cole@11854
    55
    
cole@11854
    56
    if (buildAsLibrary) {
cole@11854
    57
        libraryVariants.all { variant ->
cole@11854
    58
            variant.outputs.each { output ->
cole@11854
    59
                def outputFile = output.outputFile
cole@11854
    60
                if (outputFile != null && outputFile.name.endsWith(".aar")) {
cole@11854
    61
                    def fileName = "org.libsdl.app.aar";
cole@11854
    62
                    output.outputFile = new File(outputFile.parent, fileName);
cole@11854
    63
                }
cole@11854
    64
            }
cole@11854
    65
        }
cole@11854
    66
    }
slouken@11647
    67
}
slouken@11647
    68
slouken@11647
    69
dependencies {
slouken@12364
    70
    implementation fileTree(include: ['*.jar'], dir: 'libs')
slouken@11865
    71
}