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.
Modules. A module is a collection of source files and build settings that allow you to divide your project into discrete units of functionality. Your project can have one or many modules, and one module may use another module as a dependency. You can independently build, test, and debug each module.
Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Although you do not configure build variants directly, you do configure the build types and product flavors that form them.
To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar. For projects without native/C++ code, the Build Variants panel has two columns: Module and Active Build Variant.
A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.
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.
For me, this issue appeared when I updated Android Studio to version 3.3.
Disabling experimental feature "Only sync the active variant" fixes it:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With