Skip to content Skip to sidebar Skip to footer

Missing Main Module In Android Studio

I am trying to migrate my android app from eclipse to Android studio. (0.5.4) The project has several dependencies. (Sherlock etc) I exported the app to Gradle and imported it in A

Solution 1:

You've included an android block inside a buildscript block in your top-level build file, but this is incorrect. Instead it should be structured like this:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.2'
    }
}

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "19.0.2"
}

dependencies {
    //Your app dependencies go here
}

All this is assuming that you truly have an Android application module at your project root (meaning that at your project root directory there's a src directory that has Android sources in it). It seems to be that you're trying to set it up this way because you also have this in your settings.gradle file:

include':'

If that's the case, then rearranging your top-level build file as indicated above should fix it.

If you don't have a module at the project root, then you should restore the top-level build file to its original condition (take out apply plugin and android), take out that include ':' line from settings.gradle, and add an include statement that points to your application module.

Solution 2:

In your settings.gradle file, I don't see where you included your main module. You should add:

include':mainmodule-directory'

Your project should, ideally, have two build.gradle files. One at the root level, one at the module level. In your main module, you specify that the module is an Android module by adding apply plugin: android in the module's build.gradle file. Then you specify that the entire project would need the Android plugin by using the following in the root build.gradle file:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}

Post a Comment for "Missing Main Module In Android Studio"