Adding java folders to android studio project

前端 未结 3 1754
忘了有多久
忘了有多久 2020-12-16 12:14

Started working on my first project using Android Studio instead of Eclipse ADT. I would like to add sub folders to contain java.classes in order to structu

相关标签:
3条回答
  • 2020-12-16 12:46

    IntelliJIdea mixes packages and directories.

    So, right click on the java folder, click new - 'Package', then add your directory.

    0 讨论(0)
  • 2020-12-16 12:46

    Try this path : src/main/java/[MyCompany]/[myAppName]/...
    src/main/java/ is default source directory in Android Studio

    OR

    if you don't want to change your directory structure. you have to modify your build.gradleto change source directory.

    something like: (this example is for ADT project)

    android {
    
        ...
    
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }
        }
    
        ...
    
    }
    
    0 讨论(0)
  • 2020-12-16 12:55

    In my case I wanted a mock package with java folder:

    1. First step you have to put project mode:

    1. Click right button, new, Directory, in my case "mock".
    2. Click right button, new, Folder, Java Folder:

    1. Click in checkbock "change folder location" and put your path, in my case "src/mock/java":

    1. The solution is this:

    0 讨论(0)
提交回复
热议问题