项目与路径“:mypath中”无法根项目中找到'MYPROJECT“ [英] Project with path ':mypath' could not be found in root project 'myproject'

查看:613
本文介绍了项目与路径“:mypath中”无法根项目中找到'MYPROJECT“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从Eclipse的移植到Android工作室的 0.5.8 ,导入我的项目到Android工作室我居然也得到了误差项目与路径之后':progressfragment不能在根项目PROJECT_NAME中找到。

项目Struture:

利布斯

完整结构(编辑2):

Gradle.build:

 应用插件:'机器人'依赖{
    编译文件树(导演:'库',包括:的* .jar)
    编制项目(':progressfragment')
    编制项目(':viewpagerindicatorlibrary')
    编制项目(':ZBarScannerActivity')
    编制项目(:谷歌播放services_lib')
    编制项目(':SwitchCompatLibrary')
    编制项目(':actionbarsherlock')
    编制项目(':librarymultichoice')
}buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径'com.android.tools.build:gradle:0.9.+
    }
}安卓{
    compileSdkVersion 14
    buildToolsVersion19.0.1    sourceSets {
        主要{
            manifest.srcFile'的Andr​​oidManifest.xml
            java.srcDirs = ['src'中]
            resources.srcDirs = ['src'中]
            aidl.srcDirs = ['src'中]
            renderscript.srcDirs = ['src'中]
            res.srcDirs = ['水库']
            assets.srcDirs = ['资产']
        }        //移动测试,测试/ JAVA,测试/ RES等...
        instrumentTest.setRoot(测试)        //移动构建类型构建类型/<&型GT;
        //例如,建立类型/调试/ JAVA,内置类型/调试/ AndroidManifest.xml中,...
        //这个动作出来在src / LT他们默认位置和的;类型> / ...这将
        //与SRC /冲突正在使用的主要来源集。
        //添加新的构建类型或产品的口味应该陪同
        //通过类似定制。
        debug.setRoot(集结类型/调试)
        release.setRoot(集结类型/释放)
    }
}


解决方案

这是不够的,仅仅有编制项目(XY)依赖。
您需要配置根项目,包括所有模块(或称他们为子项目,但可能不会在这里正确的单词)。

创建的 settings.gradle 的文件在你的项目的根目录并添加此

包括':progressfragment

该文件。然后同步摇篮,它应该工作。

另外一个有趣的边注:
如果添加:unexistingProject中的 settings.gradle 的(您尚未创建项目),摇篮将为同步后,该项目创建的文件夹(至少在Android的工作室,这是它的行为) 。因此,为了避免有错误的 settings.gradle 的,当你从现有文件创建项目,首先添加一行到文件,同步然后把创建的文件夹中现有的code。由此产生不必要的行为可能是,如果你删除的项目文件夹,然后同步文件夹会回来空的,因为摇篮同步重建它,因为它是仍然列出的 settings.gradle

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

Complete Structure (edit 2) :

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')
    }
}

解决方案

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.

这篇关于项目与路径“:mypath中”无法根项目中找到'MYPROJECT“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆