0

I would like to know that is it possible to have android project without Application module (app or any other name) in Android studio?

Means i can create package and res in root of the project itself rather than having Application Module.

Edited :- Structure looks like

MyApp

  • .idea
  • gradle
  • src
  • res
  • assets
  • AndroidManifest.xml
  • build.gradle
  • etc...
Scorpion
  • 6,831
  • 16
  • 75
  • 123

2 Answers2

1

Please refer "Configuring the Structure" section in https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide. You can specify a different sourceSet

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']
        }

        androidTest.setRoot('tests')
    }
}
Oscar Anthony
  • 190
  • 3
  • 18
human123
  • 295
  • 1
  • 9
  • thanks for the details.. This is really helpful but i have 1 more query, how about building gradle.. how can i create build.gradle file for the project.. i just created one file and put necessary things there but its not giving me any option to sync the project. Do you have any idea about this? – Scorpion Nov 17 '15 at 11:52
  • Have you tried "Sync Project with gradle files"? Button for it is available in toolbar in android studio. Also try rebuilding project – human123 Nov 18 '15 at 05:38
  • After removing app folder and making src as my source root, i can't see any option Like Sync Gradle, Build/Clean/Rebuild in android studio. It seems that without creating module its not possible to work in android studio for android project. And once i create module it creates the structure of its own with default folders which i don't need. – Scorpion Nov 18 '15 at 05:43
0

app/
build.gradle
src
jni
AndroidManefest.xml
build.gradle
settings.gradle

It's doable and here is how I did it:
1) Import the eclipse project from Android Studio.
*if you have a android studio project already, skip this step.
2) Open build.gradle under sub dir app/ and copy the contents and append/paste it to build.gradle of the top level.
3) Move all files under app/ to top level.
*if you don't have these files in top level yet.
4) Remove settings.gradle.
* you don't need it any more since you don't have app as a submodules.
5) Added the following lines to build.gradle

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }
  • Change the dir name to match your layout.
    6) "Clean Projet" and "Rebuild Project"

Note: If you have other submodules in additional to "app", you will need keep settings.gradle and remove:
include ":app"
from it and keep other submodules.

See my project layout here:
enter image description here

The final build gradle is a combination of two together:

enter image description here

Hope it helps.

David

us_david
  • 4,431
  • 35
  • 29