android-project/app/build.gradle
author Cole Campbell <cole.campbell@twistedlogik.net>
Tue, 09 Jan 2018 19:11:34 -0500
changeset 11854 934d77867168
parent 11649 fe6769530709
child 11865 af91d564aa40
permissions -rw-r--r--
Allow Android Java shim to be built as an AAR
     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 16
    12     buildToolsVersion "26.0.1"
    13     defaultConfig {
    14         if (buildAsApplication) {
    15             applicationId "org.libsdl.app"
    16         }
    17         minSdkVersion 14
    18         targetSdkVersion 16
    19         versionCode 1
    20         versionName "1.0"
    21         externalNativeBuild {
    22             ndkBuild {
    23                 arguments "APP_PLATFORM=android-14"
    24             }
    25         }
    26         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    27     }
    28     buildTypes {
    29         release {
    30             minifyEnabled false
    31             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    32         }
    33     }
    34     if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
    35         sourceSets.main {
    36             jniLibs.srcDir 'libs'
    37         }
    38         externalNativeBuild {
    39             ndkBuild {
    40                 path 'jni/Android.mk'
    41             }
    42         }
    43        
    44     }
    45     lintOptions {
    46         abortOnError false
    47     }
    48     
    49     if (buildAsLibrary) {
    50         libraryVariants.all { variant ->
    51             variant.outputs.each { output ->
    52                 def outputFile = output.outputFile
    53                 if (outputFile != null && outputFile.name.endsWith(".aar")) {
    54                     def fileName = "org.libsdl.app.aar";
    55                     output.outputFile = new File(outputFile.parent, fileName);
    56                 }
    57             }
    58         }
    59     }
    60 }
    61 
    62 dependencies {
    63     compile fileTree(include: ['*.jar'], dir: 'libs')
    64     androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    65         exclude group: 'com.android.support', module: 'support-annotations'
    66     })
    67     testCompile 'junit:junit:4.12'
    68 }