Md Mohsin
Md Mohsin

Reputation: 1568

The module 'app' is an Android project without build variants

I am getting below error while importing android project.

Error:The module 'app' is an Android project without build variants, and cannot be built. Please fix the module's configuration in the build.gradle file and sync the project again.

Gradle file code.

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
    applicationId "com.djalel.android.bilal"
    minSdkVersion 9
    targetSdkVersion 25
    versionCode 4
    versionName "1.3"
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt')
    }
}

aaptOptions {
    cruncherEnabled = false
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:25.3.1'
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.jakewharton.timber:timber:3.1.0'
}
repositories {
mavenCentral()
}

I checked with working gradle file as well but getting same error in this project.

Upvotes: 39

Views: 38799

Answers (8)

khush pajwani
khush pajwani

Reputation: 303

Once try to invalidate cache and restart android studio it might be because when fetching your code from git it might have some issue in my case it worked for me.

Upvotes: 1

sasha_trn
sasha_trn

Reputation: 2015

I had this issue in my library project. I solved it by adding

buildscript {
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

To the beginning of build.gradle

Upvotes: 0

NYDB ALL
NYDB ALL

Reputation: 11

You must update your dependencies in build.grade in the buildscript block:

classpath 'com.android.tools.build:gradle:3.1.0'

to:

classpath 'com.android.tools.build:gradle:3.4.2'

Upvotes: 1

nius
nius

Reputation: 509

Try use command line to run gradlew tasks to see why the build would fail.

In my case:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
 platforms;android-27 Android SDK Platform 27
 build-tools;27.0.3 Android SDK Build-Tools 27.0.3

So I just ran Go to Android\sdk\tools\bin sdkmanager --licenses to accept licenses and then the build passed in command line.

I think Android Studio is crying for the wrong issue. So you may check the real output in command line and find what is happening.

Upvotes: 23

Aniket Bhoite
Aniket Bhoite

Reputation: 116

If this error occurs for other module than 'app'

Remove gradle variable from that module's build.gradle like

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

& replace it actual value

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.71"

Clean Project -> Rebuild Project

Upvotes: 0

Dmitry Chistyakov
Dmitry Chistyakov

Reputation: 286

For me, this issue appeared when I updated Android Studio to version 3.3.
Disabling experimental feature "Only sync the active variant" fixes it:

enter image description here

Upvotes: 25

Asad Ali Choudhry
Asad Ali Choudhry

Reputation: 5261

Just install the Android SDK platform package through SDK Manager in Android Studio, relevant to your Compile SDK version. It will prompt you to install the package as well as to accept the license. After that just sync the gradle, it will resolve the issue.

Upvotes: 4

Moeed Ahmed
Moeed Ahmed

Reputation: 612

Above gradle file code seems to be perfect. Probably its nothing to do with app/build.gradle (Module:app). Just open other build.gradle (Project:Android) file in Project window and verify your Android Studio version it must be same as yours.

I replaced from:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

to my Android Studio v3.0.1 in my case:

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

Press "Try Again" to Sync gradle file. This resolved my problem with a successful build.

Upvotes: 41

Related Questions