How to add a directory inside a package?
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

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:

Adding a package to a package in Android Studio

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:

Added folder becomes a package after Gradle sync

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.

Btw: This is my fork containing the problem: https://bitbucket.org/MartyMaro/love2d-admob-unityads-inappbilling-gameservices-android/src/master/ and this is the original repo: https://bitbucket.org/MartinFelis/love-android-sdl2/src/master my own fork cannot compile, because some files are not converted from iOS yet, but it should help to illustrate the issue. UPDATE: It seems that the issue is gone when the repo is pulled to a clean folder without other files. It seems I forgot to remove any file that causes the issue allowing me to recognise the folder as directory. The bounty will go to the person who can tell me how to do this without re-pulling the whole thing. You can reproduce the issue by trying to add another directory to the folder. The folder is at: /love/src/jni/love/src/module
Marty 3 months ago
This is fairly new to me, I can see you are right clicking on modules folder to create new module. Went through documentation they specify creation of modules as File > New > New Module. This should make all the necessary addition to the project.. Then later copy you can add the core files to this new module.. If none of this work Build > Clean, then File> Restart > Invalidate Cache and restart.. Its a long shot hope that helps
SilverHood Apps 3 months ago

Crowdsource coding tasks.

0 Solutions