107

I'm migrated from Eclipse to android studio 0.5.8, after importing my project to android studio i was getting the error Project with path ':progressfragment' could not be found in root project 'project_name'.

Project Struture :

Libs

enter image description here

Complete Structure (edit 2) :

enter image description here

Gradle.build:

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':progressfragment')
    compile project(':viewpagerindicatorlibrary')
    compile project(':ZBarScannerActivity')
    compile project(':google-play-services_lib')
    compile project(':SwitchCompatLibrary')
    compile project(':actionbarsherlock')
    compile project(':librarymultichoice')
}



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

android {
    compileSdkVersion 14
    buildToolsVersion "19.0.1"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}
7
  • 12
    Don't you have any settings.gradle file?
    – Salem
    Commented May 13, 2014 at 19:54
  • @Salem no i don't have it
    – Humain
    Commented May 13, 2014 at 22:13
  • 2
    Question is not clear please include the comple project structure, where this gradle file is and how the project directory structure looks like because what you have given doesn;t even look like a gradle project. Commented May 14, 2014 at 5:53
  • @pyus13 question edited
    – Humain
    Commented May 14, 2014 at 8:00
  • except the build.gradle nothing seems like a gradle project. Open Message Window from botton panel in AS and make sure it is not showing the warning message like "Not a Gradle Project" . Commented May 14, 2014 at 8:45

5 Answers 5

261

It's not enough to have just compile project("xy") dependency. You need to configure root project to include all modules (or to call them subprojects but that might not be correct word here).

Create a settings.gradle file in the root of your project and add this:

include ':progressfragment'

to that file. Then sync Gradle and it should work.

Also one interesting side note: If you add ':unexistingProject' in settings.gradle (project that you haven't created yet), Gradle will create folder for this project after sync (at least in Android studio this is how it behaves). So, to avoid errors with settings.gradle when you create project from existing files, first add that line to file, sync and then put existing code in created folder. Unwanted behavior arising from this might be that if you delete the project folder and then sync folder will come back empty because Gradle sync recreated it since it is still listed in settings.gradle.

7
  • 7
    module was not there in settings.gradle . I checked and included. It worked for me. Commented Nov 29, 2016 at 7:18
  • 1
    Worked for me! Although I still find it very weird that Gradle works this way. Like why would I declare a "project("project-name"){//settings...}" in my build file, if I didn't want to include it? Why do I have to have a separate file where the only thing it contains is a list of all the projects I have defined in my actual build file. All those projects I defined in my build file? Yeah, I actually want them in my build! I'm curious if anyone knows the design reason behind settings.gradle? Commented Jun 27, 2017 at 15:06
  • There are certain cases where you would want to include a module as part of your project but not use it as a dependency. For example on project I am working on we have 2 android apps, one is the UI part and the other is a content provider app. We do not want to be dependent on Content provider app during build time but would like to be able to easily change and look at it's code in the same project. Commented Jun 28, 2017 at 9:48
  • 2
    Not wroking for me for flutter.
    – Sabrina
    Commented Jul 25, 2020 at 9:38
  • ahhh I should be lover case only, alright, thank you! Commented Sep 27, 2022 at 11:56
5

Remove all the texts in android/settings.gradle and paste the below code

rootProject.name = '****Your Project Name****'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

This issue will usually happen when you migrate from react-native < 0.60 to react-native >0.60. If you create a new project in react-native >0.60 you will see the same settings as above mentioned

4

If Igor's answer doesn't work, chances are you are missing the colon(:) before referring the project name.

Omitting it gives the exact same error.

Ensure you are including the project with the : as prefix

include ':progressfragment'
0
3

You must include that dependacies name with version in 'settings.gradle' file..

include ':paytabs_sdk-v4.0.1'
include ':dtapl-3.5.3'
2
  • which settings.gradle? The one in the root dir or the one in this project's dir?
    – Keverly
    Commented Dec 12, 2022 at 17:15
  • 1
    @Keverly project's dir file. Commented Feb 20, 2023 at 12:58
-5

I got similar error after deleting a subproject, removed

"*compile project(path: ':MySubProject', configuration: 'android-endpoints')*"

in build.gradle (dependencies) under Gradle Scripts

Not the answer you're looking for? Browse other questions tagged or ask your own question.