【问题标题】:Android Studio : Compiling with API level 16Android Studio:使用 API 级别 16 编译
【发布时间】:2015-01-29 07:54:48
【问题描述】:

我试图编译一个 API 级别为 16 的 Android。但是,我遇到了以下错误。现在是否可以使用 android studio 或 Eclipse 编译 API 级别 16 的应用程序?

Error:(50, 21) No resource found that matches the given name: attr android:actionModeShareDrawable'

Error:(6, 21) No resource found that matches the given name: attr 'android:paddingEnd'

Error:(11, 21) No resource found that matches the given name: attr 'android:layout_marginEnd'

Error:(10, 21) No resource found that matches the given name: attr 'android:paddingStart'.

Error:(6, 21) No resource found that matches the given name: attr 'android:paddingEnd'

Error:(24, 21) No resource found that matches the given name: attr 'android:layout_marginStart'.

Error goes like that.. Total 118 errors..

以下是我在 Android Studio 中安装的内容:

  1. Android SDK 工具 24.0.2
  2. Android SDK平台-工具21
  3. Android SDK 构建工具 20
  4. Android 4.1.2 (API 16)。

我也设置了 Compile with : API level 16。

使用 API 级别 16 编译它是否还需要其他任何东西?我怎样才能摆脱这些错误?有人可以帮我吗?非常感谢。

编辑:

文件 build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

应用程序的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion '20'
    defaultConfig {
        applicationId "com.mtes.sidek.techer"
        minSdkVersion 10
        targetSdkVersion 16
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
}

SDK 管理器:

使用设置编译:

【问题讨论】:

  • 显示您的 gradle 文件。还张贴您的 SDK 管理器的图像
  • @goonerdroid,我已经添加了 SDK 管理器和 gradle 文件的图像。这个可以吗 ?谢谢。
  • 将您的 buildToolsVersion 更改为 21.1.2。您还在 SDK 管理器中安装了 Google Repository、Google Support Repository、Android Support Library、Google Play services,
  • @goonerdroid,我已按照您的要求进行了更改。还是一样的错误。我已经更新了 SDK 管理器并相应地使用图像编译。但我遇到了同样的错误。

标签: android eclipse-plugin android-studio android-4.2-jelly-bean android-sdk-tools


【解决方案1】:

AppCompat v21 构建需要 API 21 (Android 5.0) 中提供的新 API 的主题。要使用 AppCompat 编译您的应用程序,您还必须针对 API 21 进行编译。使用 API 21 编译/构建的推荐设置是 compileSdkVersion 为 21,buildToolsVersion 为 21.0.1(这是目前最高的 - 你总是想要使用最新的构建工具)。另外,如果您想使用 16 进行编译,请使用此 compile 'com.android.support:appcompat-v7:19.1.+'

编译 Appcompat

【讨论】:

  • 是的,编译错误消失了。非常感谢。还有一个疑问,如果我只需要使用 API 级别 16 构建应用程序。我需要使用旧的 buildTools 吗? 21.0.1的版本就够了吗?我想测试 API 级别 16 构建应用程序中的一些错误。所以我需要 API 级别 16 吗? buildToolVersion 会影响我的研究吗?
  • 这只是一个偏好问题。我自己只使用最新的构建工具,即v21.1.2,因为下载所有构建工具会占用我的硬盘空间。建议您下载最新的构建工具.如果它解决了你的问题,也接受答案!
  • goonerdriod,谢谢!
  • 没问题,编码愉快!
猜你喜欢
  • 2013-05-11
  • 2015-06-13
  • 1970-01-01
  • 1970-01-01
  • 2018-02-25
  • 2016-06-11
  • 2013-10-28
  • 1970-01-01
相关资源
最近更新 更多