我一直在寻找了一段时间现在想尽一切答案,我能找到,但没有成功。我开始相信这个问题是在android演播室版本。
但这里是我做了什么:
1 - 我已经下载了Facebook的SDK
2 - 复制的SDK到我的库文件夹,以便该项目的样子 以下内容:
MyProj文
-app
--libs
--- Facebook的
---- build.gradle(2)
--build.gradle(1)
-settings.gradle
3 - 我修改settings.gradle:
包括':库:Facebook的',':应用程序
4 - 我修改build.gradle(1):
应用插件:'机器人'
安卓{
compileSdkVersion 19
buildToolsVersion19.0.3
defaultConfig {
的minSdkVersion 16
targetSdkVersion 19
版本code 1
VERSIONNAME1.0
}
buildTypes {
推出 {
runProguard假
proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
}
}
}
依赖{
编译文件树(导演:库,包括:['的* .jar'])
编译me.dm7.bar codescanner:zxing:1.0
编译com.koushikdutta.ion:离子:1.2.4
编译com.google code.gson:GSON:2.2 +
编译com.squareup.picasso:毕加索:2.1.1
编制项目(':库:Facebook的);
}
5 - 最后编辑build.gradle(2):
buildscript {
库{
mavenCentral()
}
依赖{
类路径com.android.tools.build:gradle:0.9.+
}
}
应用插件:机器人库
依赖{
编译com.android.support:support-v4:+
}
安卓{
compileSdkVersion 19
buildToolsVersion19.0.3
defaultConfig {
的minSdkVersion 16
targetSdkVersion 19
}
sourceSets {
主要 {
manifest.srcFile的AndroidManifest.xml
java.srcDirs = ['src'中]
resources.srcDirs = ['src'中]
res.srcDirs = ['水库']
}
}
}
现在同步,当我得到了恼人的警告: 摇篮的MyApp项目刷新失败: 配置名为默认找不到
和我不能够使用Facebook的库。
我想我做得不对的摇篮文件。任何想法?
解决方案您的项目不符合你正在使用的依赖规范的目录结构;目前还不清楚什么是在 已settings.gradle。你得到配置名称默认未找到的错误是非常直观的,但它在摇篮中寻找某个目录中的模块中,你得到的消息,它不是找到它。如果您有相关性规范(和 settings.gradle 包括)像:库:Facebook的
,它会寻找在 MyProj文/库/ Facebook的,而不是 MyProj文/应用程序/库/ Facebook的您放置它。
我会推荐这样的结构:
MyProj文
-app
--build.gradle(1)
-libs
--facebook
--- build.gradle(2)
-settings.gradle
即。移动库的上一级目录,所以这是旁边的应用程序的目录,而不是它的下面。
您的 settings.gradle 的文件应该是:
包括:应用程序',':库:Facebook的
(这大概是你已经拥有它成立)和Facebook的依赖应该是这样的:
编制项目(':库:Facebook的)
(也怎么样,你已经拥有了它设置了)
I've been searching around for a while now and tried every answer I could find with no success. I am starting to believe that the problem is in the android studio version.
However here is what I've done:
1 - I've downloaded the facebook sdk
2 - Copied the sdk into my libs folder so the project looks like following:
MyProj
-app
--libs
---facebook
----build.gradle (2)
--build.gradle (1)
-settings.gradle
3 - I modified settings.gradle:
include ':libs:facebook', ':app'
4 - I modified build.gradle (1) to:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'me.dm7.barcodescanner:zxing:1.0'
compile 'com.koushikdutta.ion:ion:1.2.4'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.squareup.picasso:picasso:2.1.1'
compile project(':libs:facebook');
}
5 - Lastly edited build.gradle (2):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
Now when syncing I get the annoying warning: Gradle 'MyApp' project refresh failed: Configuration with name 'default' not found
And I am not able to use the facebook library.
I guess I'm doing something wrong with the gradle files. Any ideas?
解决方案The directory structure of your project doesn't match the dependency specs you're using; it's not clear what's in your settings.gradle. That error you get with "Configuration name 'default' not found" is terribly unintuitive, but it's the message you get when Gradle is looking for a module in a certain directory and it's not finding it. If you have a dependency spec (and settings.gradle include) like :libs:facebook
, it will look in MyProj/libs/facebook, not MyProj/app/libs/facebook where you've placed it.
I would recommend this structure:
MyProj
-app
--build.gradle (1)
-libs
--facebook
---build.gradle (2)
-settings.gradle
i.e. move the libs directory one level up so it's alongside app directory instead of underneath it.
Your settings.gradle file should be:
include ':app', ':libs:facebook'
(which is probably how you already have it set up) and a dependency on facebook should look like:
compile project(':libs:facebook')
(also like how you already have it set up)
相关推荐
最新文章