2014-01-31 26 views
55

我要導入庫項目到我的應用程序,但每當我試圖這樣做,Android的Studio不承認它Android Studio中導入Facebook的庫:找不到屬性「ANDROID_BUILD_SDK_VERSION」

這也給了我在錯誤的build.gradle ..

圖書館是:PagerSlidingTabStrip ....

下面是一些圖片:

enter image description here

enter image description here

我一直在試圖讓3天工作至今! 請幫我:)

編輯:

apply plugin: 'android-library' 

dependencies { 
compile 'com.android.support:support-v4:19.0.0' 
} 

android { 
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 

defaultConfig { 
    minSdkVersion 8 
    targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 
} 

sourceSets { 
    main { 
     manifest.srcFile 'AndroidManifest.xml' 
     java.srcDirs = ['src'] 
     res.srcDirs = ['res'] 
    } 
} 
} 

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' 

EDIT2:

FAILURE: Build failed with an exception. 

* What went wrong: 
A problem occurred configuring project ':Sahertoday'. 
> Could not resolve all dependencies for configuration ':Sahertoday:_debugCompile'. 
> Could not find com.astuetz:pagerslidingtabstrip:1.0.1. 
Required by: 
    Saher-3:Sahertoday:unspecified 

* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get   more log output. 

BUILD FAILED 
+0

請發佈您的build.gradle文件。你是如何申報該圖書館的? – 2Dee

+0

這是圖書館的build.gradle .. –

回答

54

首先,你可以添加這個依賴於你的項目,不在本地編譯lib。

dependencies { 
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1' 
} 

否則,如果你想在本地編譯這個lib,你必須在根中的gradle.properties中定義這些鍵。

ANDROID_BUILD_TARGET_SDK_VERSION=19 
ANDROID_BUILD_TOOLS_VERSION=19 
ANDROID_BUILD_SDK_VERSION=19 
+0

當我使用第一步時,出現錯誤(我發佈上面的錯誤)..第二步也沒有工作! –

+0

對於第一種解決方案,您應該在您的proj/build.gradle中添加知識庫{mavenCentral() }。 –

+0

任務':Sahertoday:processDebugManifest'的執行失敗。 >清單合併失敗。請參閱控制檯瞭解更多信息現在這顯示了:(我真的很感激你的幫助.. –

38

編輯

也有這樣做的一個GUI方式。通過在項目樹中選擇模塊facebook並按f4來訪問它。
也可以右鍵單擊facebook並轉到底部附近的Open Module Settings

它顯示在圖片中。圖片中的數字是寫作時的頂級SDK版本。

first block - The numbers in the pictures don't match the above ones, but that's because I updated them later on.

second block - same update

有一個簡單的解決方案。 像ANDROID_BUILD_SDK_VERSION這樣的常數可以用普通版本的「數字」代替。因此,而不是

android { 
    compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 
    buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 

    defaultConfig { 
     minSdkVersion 8 
     targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 
    } 

..file可以是這樣的:

android { 
    compileSdkVersion 19 
    buildToolsVersion '19.1.0' 

    defaultConfig { 
     minSdkVersion 15 
     targetSdkVersion 19 
    } 
+0

它適合我。 tq –

+0

沒問題。很高興能有所幫助 – mdzeko

+0

在Android Studio> 4.3的新版本中沒有模塊導入選項 –

1

對於那些誰遇到了同樣的問題,同時增加庫和仍然無法得到它的工作。以下本地包含的.aar文件適用於我:

  • 只需手動從maven repo下載.aar文件即可。
  • 在Android Studio中轉到File - > new Module - > import .JAR或 .AAR包並選擇您下載的.aar文件。

Android Studio爲你完成剩下的工作(在build.gradle中)。也許乾淨並重建你的項目。

3

轉到您在項目中導入的facebook文件夾。複製gradle.properties文件並粘貼到您的Facebook模塊中。它將刪除錯誤。

+0

不適合我 – Ilario

1
apply plugin: 'com.android.library' 

android { 
    compileSdkVersion 22 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     minSdkVersion 8 
     targetSdkVersion 4 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 
} 

dependencies { 
    compile 'com.android.support:appcompat-v7:22.2.1' 
} 
相關問題