【问题标题】:Is it mandatory to compile my app with api 22 lollipop?是否必须使用 api 22 lollipop 编译我的应用程序?
【发布时间】:2015-04-21 05:37:26
【问题描述】:

我的项目使用 api 21 编译并运行良好,当我尝试使用 api 22 编译它时,我遇到了来自 gradle 的许多错误(Error:In <declare-styleable> SherlockSpinner, unable to find attribute android:popupPromptView 和许多其他错误),我无法修复它们。

所以问题是,如果我让 api 22 运行并使用 api 21 编译它会发生什么,哪些设备无法运行我的应用程序?

更新:

请查看我的配置并告诉我哪些设备无法运行我的应用 这是我的 build.gradle 配置文件的一部分:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }

    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
}
dependencies {
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.android.gms:play-services-base:6.5.+'
    compile project(':chipsLibrary')
    compile project(':slidingMenu')
    compile project(':listviewanims')
    compile project(':switchCompatLibrary')
    compile project(':lib_numberpicker')
    compile project(':styleddialogslib')
    compile project(':doomDatePickerlibrary')
    compile project(':swipelistview')
    compile project(':actionbarsherlockPullToRefresh')
    compile project(':showcaseLib_Untouched_library')
    compile project(':cropper')
    compile project(':library_androidanims')
    compile project(':library_async_45')
    compile files('libs/google-api-services-drive-v2-rev123-1.18.0-rc.jar')
    compile files('libs/google-oauth-client-1.18.0-rc.jar')
    compile files('libs/acra-4.5.0.jar')
    // Required for Dropbox
    compile files('libs/dropbox-android-sdk-1.6.1.jar')
    compile files('libs/json_simple-1.1.jar')
    compile files('libs/systembartint-1.0.3.jar')
    compile files('libs/universal-image-loader-1.9.2 (1).jar')
    compile files('libs/volley.jar')
    compile files('libs/google-api-client-1.18.0-rc.jar')
    compile files('libs/google-api-client-android-1.18.0-rc.jar')
    compile files('libs/google-http-client-1.18.0-rc.jar')
    compile files('libs/google-http-client-android-1.18.0-rc.jar')
    compile files('libs/google-http-client-gson-1.18.0-rc.jar')
    compile files('libs/joda-time-2.3.jar')
    compile files('libs/itext-4.2.1.jar')
}

【问题讨论】:

  • 这不是必须的,具有 22 版本的设备也可以运行它,但可能缺少 22nd 暴露的一些功能
  • 它是您选择在哪个 api 级别上编译,以这种方式选择最大和最小 api 级别。或者你可以下载最新的 API 22 并用它制作模拟器然后编译。
  • 设备 = api 19 将无法安装/运行您的应用。
  • 添加你的错误堆栈
  • 我应该怎么做才能包含 api 22 设备并且不会遇到错误?

标签: android android-studio gradle compiler-errors


【解决方案1】:

仅当您希望使用该特定 SDK 版本提供的功能时,才需要通过定义特定的编译 SDK 版本来编译您的应用程序。

你绝对可以用低版本编译并使其与高版本兼容,但如上所述,你将无法使用高版本定义的新功能/特性。

【讨论】:

  • 我已经更新了我的问题,所以请查看我的 targetsdkversion 并告诉我我缺少什么。坦克
  • @user293171 由于 appcompat 库,这看起来像是一个问题,虽然不确定,但在这里发布您的 build.gradle 文件内容以获得更好的想法!
  • 低版本如何编译并兼容高版本?
  • @user293171 为什么要用低版本编译?
  • 我想用 21 编译以避免此类错误,并且还能够在运行 22 lollipop 5.1 的设备上运行。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-26
  • 1970-01-01
  • 2016-06-23
  • 1970-01-01
  • 2017-07-12
  • 1970-01-01
相关资源
最近更新 更多