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