Different Ways to Fix “Configuration with name ‘default’ not found” in Android Studio
Whenever you try to import or clone a code from any version control system, there are chances that Android Studio throws the error:
"Error: Configuration with name 'default' not found".
There can be more reasons to face this error such as adding .jar files to your android project. So in this article, we are going to cover the topics: Why there is a need to fix this error and how to fix this error using six different ways.
Why There is a Need To Solve ‘Configuration with name ‘default’ not found’?
While importing the zip file into Android Studio, it shows the above error. When you try to build the project, Gradle sync fails. Some of the Gradle files probably cannot find a library. This error generally occurs due to the following reasons:
- When a module doesn’t have the build.gradle file,
- You’re trying to use a project that doesn’t have a “build.gradle” file.
The build.gradle file for each submodule needs to have the information on how to build itself and any custom Gradle command definitions. So, you need to make sure that each submodule in your project has its own build.gradle file. The name ‘default’ happens because of your project-level build.gradle is trying to build a project that doesn’t know how to build itself, thus it is given the name ‘default.’ We need to fix this error as due to this Gradle sync keeps failing and you cannot build your project.
How To Solve ‘Configuration with name ‘default’ not found’?
Step 1: Open your app’s gradle file
Step 2: Look for the line : compile project(‘:android-ColorPickerPreference’) .
Step 3: Change this line to : compile fileTree(dir: ‘//you libraries location//’, include: [‘android-ColorPickerPreference’])
Add your library folder to the root location of your project and copy all the library files there. For example, YourProject/library then try to sync it.
If your project Library uses submodule management and if all submodules are not loaded properly, this will also cause the error:
Error:Configuration with name 'default' not found
To solve the problem simply execute the command: git submodule update –init
You may have a git submodule problem. Try running:
gradle tasks –info (if you are Linux user) for a more detailed problem description.
For Windows just type: gradlew tasks –info
then wait for few seconds. After that, you should be able to see the “build successful” message on the terminal as shown below.
Open your settings.gradle
You will see many includes “:app” included.
But if items under the project directory seem to be missing then, add the items that need to be included. If the included items are not required, delete its include statement. Try sync again.
Try Renaming the Module. The root/settings.gradle in the root directory will not automatically modify the name. You need to manually rename the name to your modified name.