[英]Can not import facebook-sdk 4.0.1
I have android studio 1.1.0 and i just created a new project and i'm trying to import new facebook-sdk 4.0.1 but can not do this, I followed Facebook Getting Started 我有android studio 1.1.0,我刚创建了一个新项目,我正在尝试导入新的facebook-sdk 4.0.1但是不能这样做,我跟着Facebook入门
But can not get it work. 但无法让它发挥作用。 My app structure
我的app结构
My build.gradle(Project: MyApplication) file is: 我的build.gradle(Project:MyApplication)文件是:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
//mavenCentral()
}
}
My build.gradle(Module: app) file is: 我的build.gradle(Module:app)文件是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.hema.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
}
Finally the error message is: 最后错误信息是:
Error:(28, 13) Failed to resolve: com.facebook.android:facebook-android-sdk:4.0.1
<a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
Edit I added mavenCentral() in the repositories closure in build.gradle(Project: MyApplication) file but not working with same error message. 编辑我在build.gradle(Project:MyApplication)文件的存储库闭包中添加了mavenCentral(),但没有使用相同的错误消息。
I solved the problem, It was in my Gradle settings >> Unchecked Offline work 我解决了这个问题,这是在我的Gradle设置>> Unchecked Offline工作中
Actually i got the same problem and i solved it .. 实际上我遇到了同样的问题,我解决了..
1 : File > Import Module ..find facebook-android-sdk-4.0.1 then Finish 1 :文件>导入模块..找到facebook-android-sdk-4.0.1然后完成
2 : Go to File > Project sturucture > dependecies tab > Module Dependencies select :facebook 2 :转到文件>项目结构>依赖选项卡>模块依赖关系选择:facebook
3 : SYNC project and Rebuild 3 :SYNC项目和重建
IF you got error like Could not find property ' ANDROID_BUILD_MIN_SDK_VERSION after rebuilding 如果您在重建后遇到无法找到属性' ANDROID_BUILD_MIN_SDK_VERSION的错误
go to facebook/build.gradle and change this part 转到facebook / build.gradle并更改此部分
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
to your sdk version like 你的sdk版本就像
compileSdkVersion 21
buildToolsVersion '21.1.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
在build.gradle文件的存储库闭包中添加mavenCentral()
并进行同步。
Connect your laptop or computer with Internet connection. 通过Internet连接连接笔记本电脑或计算机。 It happened with me.
它发生在我身上。 I tried everything but at last when I commented laptop with Internet connection it worked.
我尝试了一切,但最后当我评论笔记本电脑与互联网连接时,它工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.