【问题标题】:Why does Android Studio throw errors in the manifest file when we change the compileSdkVersion and targetSdkVersion from 26 to 23?为什么我们将 compileSdkVersion 和 targetSdkVersion 从 26 更改为 23 时,Android Studio 会在 manifest 文件中抛出错误?
【发布时间】:2018-02-20 12:42:56
【问题描述】:

我已经彻底搜索过,但找不到我所面临错误的原因。

我做过的事情:

  1. 我将 app gradle 文件中的 compileSdkVersion 和 targetSdkVersions 从 26 更改为 23。
  2. 我现在点击了同步。
  3. 它导致了 7 条错误消息,使我的清单文件变得混乱。

片段:

  1. 更改编译后我的 App Gradle 文件,目标 sdk 版本从 26 到 23
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.airtelanalytics"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.+'
    compile 'com.jaredrummler:android-processes:1.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
  1. Android SDK Platform 23 已安装

  1. 由于 SDK 版本从 26 更改为 23 导致的错误消息(影响 Manifest 文件)

  1. 清单文件

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="23" />

<application
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <activity android:name="com.analyticsdemo.MainActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

如何解决这个问题?

【问题讨论】:

  • 请显示您的AndroidManifest.xml的应用标签
  • 从 Android Manifest 中移除 android:roundIcon
  • 不要将 Gradle 构建文件和错误消息粘贴为图像。将它们粘贴为 text。此外,如果您在清单方面遇到问题,将清单发布为文本会有所帮助。
  • 发布 Mainfest 文件
  • 刚刚读完cmets,一会儿我把它们写成代码

标签: android android-gradle-plugin android-manifest


【解决方案1】:

我将 app gradle 文件中的 compileSdkVersion 和 targetSdkVersions 从 26 更改为 23。

这不是一个好计划,特别是如果您打算通过 Play 商店发货,因为您将 have to raise the values again shortly

如何解决这个问题?

最好的解决方案是将您的 compileSdkVersiontargetSdkVersion 移回 26。

否则,修复编译器报告的错误。

在这种情况下,您的清单在 &lt;application&gt; 上有 android:roundIcon,而在 API 级别 23 中,android:roundIcon 不存在。您通过compileSdkVersion 23 说,您想使用现有的规则进行编译对于 API 级别 23,这包括不使用当时不存在的东西。因此,请从您的实际清单中删除 android:roundIcon

【讨论】:

  • 如果我必须创建一个只针对 Marshmallow(版本 23)的应用程序,我应该卸载已经安装的 Oreo 或 Nougat SDK 吗?
  • @GaneshRamachandran:“我必须创建一个仅针对 Marshmallow(版本 23)的应用程序”——因为这是不可能的,我猜你和我使用不同的术语。 “我应该卸载已经安装的 Oreo 或 Nougat SDK 吗?” -- 这取决于您,与您的问题无关。
猜你喜欢
  • 1970-01-01
  • 2019-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-01
  • 2016-01-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多