【问题标题】:Importing Facebook library in Android Studio: Could not find property 'ANDROID_BUILD_SDK_VERSION'在 Android Studio 中导入 Facebook 库:找不到属性“ANDROID_BUILD_SDK_VERSION”
【发布时间】:2014-02-24 00:26:56
【问题描述】:

我想将一个库项目导入我的应用程序,但每当我尝试这样做时,Android Studio 都无法识别它

它还在 build.gradle 中给了我错误..

库是:PagerSlidingTabStrip ....

这里有一些图片:

到目前为止,我一直在努力让它工作 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

【问题讨论】:

  • 请发布您的 build.gradle 文件。你是如何声明那个库的?
  • 这是库的 build.gradle ..

标签: java android android-studio gradle pagerslidingtabstrip


【解决方案1】:

首先,你可以将这个依赖添加到你的项目中,而不需要在本地编译lib。

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

否则如果你想在本地编译这个库,你必须在根目录的 gradle.properties 中定义这些键。

ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=19
ANDROID_BUILD_SDK_VERSION=19

【讨论】:

  • 当我使用第一步时,出现错误(我发布了上面的错误).. 第二步也不行!
  • 使用第一个解决方案,您应该在 proj/build.gradle 中添加存储库 { mavenCentral() }。
  • 这对我不起作用。它仍然说找不到属性。
  • 这缺少另一个属性。您还需要设置:ANDROID_BUILD_MIN_SDK_VERSION=19
  • @androiddeveloper 我不知道。但你可以创建它。
【解决方案2】:

编辑

还有一种 GUI 方式可以做到这一点。通过在项目树中选择模块facebook 并按f4 来访问它。
您也可以右键单击facebook 并转到底部附近的Open Module Settings

它显示在图片中。图片中的数字是撰写本文时的顶级 sdk 版本。

有一个更简单的解决方案。 像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)
    }

..文件可能如下所示:

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
         minSdkVersion 15
         targetSdkVersion 19
    }

【讨论】:

  • 新版Android Studio > 4.3没有模块导入选项
  • @Xjet 我使用的是 0.8.9 版本,仍然有模块导入选项。我在文件->导入模块下找到它,就在顶部。看来你的版本混淆了。
【解决方案3】:

转到您在项目中导入的 facebook 文件夹。复制 gradle.properties 文件并粘贴到您的 facebook 模块中。它将删除错误。

【讨论】:

    【解决方案4】:

    对于那些在添加库时遇到同样问题但仍然无法正常工作的人。 .aar 文件的以下本地包含对我有用:

    • 只需手动从maven repo 下载 .aar 文件即可。
    • 在 Android Studio 中转到文件 -> 新模块 -> 导入 .JAR 或 .AAR 包并选择您下载的 .aar 文件。

    Android Studio 会为您完成其余的工作(在 build.gradle 中)。也许清理并重建您的项目。

    【讨论】:

      【解决方案5】:
      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'
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多