在项目“myproject”中找不到路径“:mypath”的项目 [英] Project with path ':mypath' could not be found in root project 'myproject'

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

问题描述

我从Eclipse迁移到android studio 0.5.8 ,在将我的项目导入到android studio之后,我收到了错误项目,路径为'progressfragment'在根项目'project_name'中找到。

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'.

项目Struture:

Project Struture :

Libs

完成结构(编辑2):

Gradle.build:

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


推荐答案

只有编译项目(xy)还不够依赖关系。
您需要配置根项目以包含所有模块(或称为子项目,但这可能不正确的单词)。

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).

创建一个 settings.gradle 文件在您的项目的根目录并添加:

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

include ':progressfragment'

到该文件。然后同步Gradle,它应该工作。

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

另外一个有趣的旁注:
如果在 settings.gradle settings.gradle 出现错误,请先将该行添加到文件,同步然后将现有代码放入已创建的文件夹中。由此引起的不必要的行为可能是如果您删除项目文件夹,然后同步文件夹将返回空,因为Gradle同步重新创建它,因为它仍然列在 settings.gradle 中。

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.

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

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