I have an Android project here, that consists of native parts (*.cpp
and *.h
files) within the jni
folder. In this, there is a package called modules
that has several directories in it. I'd like to add my own module in the modules
package with another sub-directory, however I can only add packages:
Since I believe Android Studio limits me on that point, I added the folder outside of Android Studio, removed my .idea
folder and the *.iml
files and re-synced Gradle. However, my new folder is still a package (icon like the module folder) and not a simple sub-directory like the other directories:
I hope I got the terminology right and don't lack enough understanding about packages and directories. De facto, the other directories are correct, but I could not find anything within the Gradle files that would explain this behaviour.
Here is the build.gradle
of the lib:
apply plugin: 'com.android.library'
android {
// If you want to use the debugger for JNI code, you want to compile this lib-project in Debug!
// And due to gradle limitations/bugs, the best way is to always compile 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 25
buildToolsVersion '27.0.3'
defaultConfig {
compileSdkVersion 25
buildToolsVersion "27.0.3"
minSdkVersion 14
externalNativeBuild {
ndkBuild {
arguments "-j2"
}
}
ndk {
// Specifies the ABI configurations of your native
// libraries Gradle should build and package with your APK.
abiFilters 'armeabi-v7a'
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java {
srcDirs('src/main/java', 'src/jni/SDL2-2.0.5/android-project/src')
}
}
}
externalNativeBuild {
ndkBuild {
path "src/jni/Android.mk"
}
}
lintOptions {
abortOnError false
}
}
dependencies {
api fileTree(dir: 'libs', include: ['*.jar', '*.arr'])
api 'com.android.support:appcompat-v7:25.2.0'
api 'com.google.android.gms:play-services-ads:11.0.4'
}
And the build.gradle
of the whole project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I added my new files in my new folder to the Android.mk
like the other files were added.
How can I add a directory instead of a package to that modules
folder?
Further information: This is the Android port of the LÖVE (love2d) game framework. I'm using a Mac.