gpt4 book ai didi

android - 在根项目 ':mypath' 中找不到路径为 'myproject' 的项目

转载 作者:IT王子 更新时间:2023-10-28 23:40:52 28 4
gpt4 key购买 nike

我从 Eclipse 迁移到 android studio 0.5.8,在将我的项目导入到 android studio 后,我收到错误 Project with path ':progressfragment' could not be found in根项目'project_name'。

项目结构:

enter image description here

完整结构(编辑 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')
}
}

最佳答案

只有 compile project("xy") 依赖是不够的。您需要配置根项目以包含所有模块(或称它们为子项目,但此处可能不正确)。

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

include ':progressfragment'

到那个文件。然后同步 Gradle,它应该可以工作了。

还有一个有趣的旁注:如果您在 settings.gradle(您尚未创建的项目)中添加 ':unexistingProject',Gradle 将在同步后为该项目创建文件夹(至少在 Android Studio 中是这样) .因此,当您从现有文件创建项目时,为避免 settings.gradle 出现错误,首先将该行添加到文件中,同步然后将现有代码放入创建的文件夹中。由此产生的不良行为可能是,如果您删除项目文件夹,然后同步文件夹将恢复为空,因为 Gradle 同步重新创建了它,因为它仍列在 settings.gradle 中。

关于android - 在根项目 ':mypath' 中找不到路径为 'myproject' 的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23640059/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com