'Unknown Module in Android Studio

enter image description here

Hi, I am trying to delete the "Unknown" module and move app & myapplication modules outside "Unknown" but every time I delete the "Unknown" module and sync the project, it just keeps coming back. I wonder where this "Unknown" module get generated. Thanks



Solution 1:[1]

I was having the same issue and I was also unable to change this in the Project Structure dialog window. Eventually, I was able to remove the Unknown module folder by editing my project-level build.gradle file. I established classpaths in the buildscript's dependencies method instead of using the plugins method. I've included what this looks like for my build.gradle, with comments:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

//buildscript used instead of plugins to get rid of "Unknown" module folder in Project Structure
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.1.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2"
    }
}

//Commented out the following to get rid of "Unknown" module folder in Project Structure
/* plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
} */

task clean(type: Delete) {
    delete rootProject.buildDir
}

I don't receive any build errors whether the plugins method is commented out, or not. The only thing that seems to change is the presence of the Unknown module folder in Project Structure.

Unfortunately, I can't explain why this is happening, or whether or not the Unknown module folder would even impact an app being approved by Google. The folder's presence never had any impact on my ability to build and run my app on emulators or physical devices, but it was a little disconcerting to see it there.

I hope this was somewhat helpful!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1