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'.
我从Eclipse迁移到android studio 0.5.8,在将我的项目导入到android studio之后,我得到了path的错误项目:progressfragment在根项目“project_name”中找不到。
Project Struture :
项目结构:
Libs
填词
Complete Structure (edit 2) :
完整结构(编辑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')
}
}
2 个解决方案
#1
97
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).
仅仅编译项目(“xy”)依赖是不够的。您需要配置根项目以包含所有模块(或称它们为子项目,但这里可能不正确)。
Create a settings.gradle file in the root of your project and add this:
创建一个设置。在您的项目的根目录下的gradle文件,并添加如下:
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.
还有一个有趣的附注:如果你在设置中添加“:unexistingProject”。gradle(你还没有创建的项目),gradle将为这个项目创建一个同步的文件夹(至少在Android studio中是这样的)。为了避免设置错误。当您从现有文件中创建项目时,首先将该行添加到文件中,然后将现有的代码放入创建的文件夹中。由此产生的不需要的行为可能是,如果您删除了项目文件夹,然后同步文件夹将返回空,因为Gradle同步重新创建了它,因为它仍然被列在settings.gradle中。
#2
-2
May be this answer helps for similar error I got similar error after deleting a subproject, removed "compile project(path: ':MySubProject', configuration: 'android-endpoints')" in build.gradle (dependencies) under Gradle Scripts
可能这个答案有助于类似的错误,在删除一个子项目后,我得到了类似的错误,删除了“编译项目(path: MySubProject,配置:‘android-端点’)”。gradle(依赖项)在gradle脚本下。
#1
97
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).
仅仅编译项目(“xy”)依赖是不够的。您需要配置根项目以包含所有模块(或称它们为子项目,但这里可能不正确)。
Create a settings.gradle file in the root of your project and add this:
创建一个设置。在您的项目的根目录下的gradle文件,并添加如下:
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.
还有一个有趣的附注:如果你在设置中添加“:unexistingProject”。gradle(你还没有创建的项目),gradle将为这个项目创建一个同步的文件夹(至少在Android studio中是这样的)。为了避免设置错误。当您从现有文件中创建项目时,首先将该行添加到文件中,然后将现有的代码放入创建的文件夹中。由此产生的不需要的行为可能是,如果您删除了项目文件夹,然后同步文件夹将返回空,因为Gradle同步重新创建了它,因为它仍然被列在settings.gradle中。
#2
-2
May be this answer helps for similar error I got similar error after deleting a subproject, removed "compile project(path: ':MySubProject', configuration: 'android-endpoints')" in build.gradle (dependencies) under Gradle Scripts
可能这个答案有助于类似的错误,在删除一个子项目后,我得到了类似的错误,删除了“编译项目(path: MySubProject,配置:‘android-端点’)”。gradle(依赖项)在gradle脚本下。