apply plugin: 'com.android.library' android { // If you want to use the debugger for JNI code, you want to debug this lib-project in Debug! // And due to gradle limitations/bugs, the best way is to always debug it in debug. // See https://code.google.com/p/android/issues/detail?id=52962 // and http://stackoverflow.com/questions/27277433/why-does-gradle-build-my-module-in-release-mode-when-the-app-is-in-debug // defaultPublishConfig "debug" compileSdkVersion 30 buildToolsVersion '30.0.2' ndkVersion '21.3.6528147' defaultConfig { compileSdkVersion 30 buildToolsVersion "30.0.2" minSdkVersion 16 resValue 'bool', 'embed', 'false' externalNativeBuild { ndkBuild { arguments "-j" + Runtime.runtime.availableProcessors() } } ndk { // Specifies the ABI configurations of your native // libraries Gradle should build and package with your APK. abiFilters 'armeabi-v7a', 'arm64-v8a' debugSymbolLevel 'SYMBOL_TABLE' } targetSdkVersion 30 } def retrieveAll3pModules = { -> def modules = [] fileTree("src/jni/lua-modules").visit { FileVisitDetails details -> if (details.isDirectory()) { if (file(details.file.path + "/Android.mk").exists()) { logger.lifecycle("3rd-party module: " + details.file.path) def javainfo = file(details.file.path + "/java.txt") if (javainfo.exists()) { def fstream = new FileInputStream(javainfo) def infile = new BufferedReader(new InputStreamReader(fstream)) def javapath = infile.readLine().replace("\\", "/") def mpath = null if (javapath[0] != '/') { mpath = details.file.path + "/" + javapath } else { mpath = details.file.path + javapath } modules << mpath logger.lifecycle("Registered path " + mpath) infile.close() } } } } return modules } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } debug { ndk { abiFilters += 'x86_64' } } } flavorDimensions 'mode' productFlavors { normal { dimension 'mode' } embed { dimension 'mode' } } sourceSets { main { java { srcDir 'src/jni/SDL2/android-project/app/src/main/java' srcDir 'src/main/java' srcDirs += retrieveAll3pModules() } } normal { java { srcDirs += 'src/normal/java' } } } externalNativeBuild { ndkBuild { path 'src/jni/Android.mk' } } lintOptions { abortOnError false } packagingOptions { exclude 'lib/arm64-v8a/libSDL2.so' exclude 'lib/armeabi-v7a/libSDL2.so' } } dependencies { api fileTree(dir: 'libs', include: ['*.jar']) api 'androidx.appcompat:appcompat:1.2.0' }