【问题标题】:Struggling to compile android apps in Eclipse with a min-sdk that is smaller than the target-sdk努力在 Eclipse 中使用小于 target-sdk 的 min-sdk 编译 android 应用程序
【发布时间】:2015-01-14 22:04:58
【问题描述】:

每当我将最小 sdk 级别设置为小于目标 + 编译 sdk 级别时,我都会遇到“找不到资源”问题。我已经尝试了很多支持库解决方案来解决这个问题,但都没有奏效。

这是 Eclipse 控制台中的数百个错误中的一个:

SourceCode\AndroidExact\appcompat_v7\res\values-v21\themes_base.xml:191: 错误:错误:找不到与给定名称匹配的资源:attr 'android:colorPrimaryDark'

但是,我可以在两种情况下编译和运行我的 android 应用程序:

  1. minSDK = 目标SDK。
  2. minSDK =(任何 api 级别)和 targetSDK =(api 级别 21)。

对于这两种情况,我可以使用 Eclipse GUI 向导创建并运行一个空的 hello world android 应用程序项目。我也可以为这两种情况编写一个更复杂的应用程序。

但对于 (minSDK

此解决方案 [1] 在 stackoverflow 上由 reVerse 提供。但是有一个问题!它仅适用于目标 21。我尝试了目标 19,但它不起作用。我需要能够选择 21 以外的目标,以用于学习目的和特定于设备的应用程序。

我也尝试了以下方法(但失败了):

  1. 安装 JDK 7,并配置 android 工作区
  2. 安装 JDK 6,并配置 android 工作区

如果我将 JDK 7 与 Eclipse Kepler 一起使用,并且我的 Eclipse 配置错误,我想我将能够使其工作。

从 Froyo 到 Lollipop 我安装了 SDK 平台和 Google API。我还安装了 Android Support Repo、Android Support Library、Google Play Services、Google Play Repository、Google USB Driver 和 HAXM driver。我已经卸载并重新安装了这些软件包,以防它们可能在 sdk 管理器之外被无意删除。

我使用的是 Windows 7、Eclipse Luna、JDK 8 和 ADT 23.0.4。

你们有什么建议或解决方案吗? 我会根据要求提供更具体的细节,因为我会尽一切努力在 Eclipse 上完成这项工作

【问题讨论】:

    标签: java android eclipse compiler-errors android-support-library


    【解决方案1】:

    跳上 Android Studio 马车。现在是第 1 版。我的建议是在 Android Studio 中创建一个新项目,然后慢慢地手动复制到源文件中。这将为您提供大量使用新 ide 的经验,并且您不会对迁移魔法感到头疼。除此之外,使用 android studio 和 gradle 使用 support (v7) 库需要 gradle 文件中的一行。

    例如,这就是您在带有 android studio 的 gradle 文件中需要的全部内容,用于 google 地图应用程序和支持库,其中它在 eclipse 中的两个额外项目。

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21+'
    compile 'com.google.android.gms:play-services:4.2.42'
    compile 'com.google.maps.android:android-maps-utils:0.3+'
    compile "com.android.support:support-v4:21+"
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-29
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 2014-10-26
      相关资源
      最近更新 更多