当我们将 compileSdkVersion 和 targetSdkVersion 从 26 更改为 23 时,为什么 Android Studio 会在清单文件中抛出错误?
Why does Android Studio throw errors in the manifest file when we change the compileSdkVersion and targetSdkVersion from 26 to 23?
我已经彻底搜索过了,但找不到我所面临的错误的原因。
我做过的事情:
- 我将应用gradle文件中的compileSdkVersion & targetSdkVersions从26改成了23。
- 我点击了同步。
- 它导致了 7 条错误消息,使我的清单文件变得混乱。
片段:
- 我的应用程序 Gradle 文件更改编译后,目标 sdk 版本从 26
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'
}
- Android SDK Platform 23 已安装
- 由于 SDK 版本从 26 更改为 23 导致的错误消息(影响清单文件)
- 清单文件
<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>
如何解决这个问题?
I changed the compileSdkVersion & targetSdkVersions in app gradle file from 26 to 23.
这不是一个好的计划,特别是如果您打算通过 Play 商店发货,您会 have to raise the values again shortly。
How to fix this ?
最好的解决办法是将 compileSdkVersion
和 targetSdkVersion
移回 26。
否则,修复编译器报错
在这种情况下,您的清单在 <application>
上有 android:roundIcon
,并且 android:roundIcon
在 API 级别 23 时不存在。您是说,通过 compileSdkVersion 23
,你想使用 API 级别 23 存在的规则进行编译,这包括不使用当时不存在的东西。因此,从您的实际清单中删除 android:roundIcon
。
我已经彻底搜索过了,但找不到我所面临的错误的原因。
我做过的事情:
- 我将应用gradle文件中的compileSdkVersion & targetSdkVersions从26改成了23。
- 我点击了同步。
- 它导致了 7 条错误消息,使我的清单文件变得混乱。
片段:
- 我的应用程序 Gradle 文件更改编译后,目标 sdk 版本从 26
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' }
- Android SDK Platform 23 已安装
- 由于 SDK 版本从 26 更改为 23 导致的错误消息(影响清单文件)
- 清单文件
<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>
如何解决这个问题?
I changed the compileSdkVersion & targetSdkVersions in app gradle file from 26 to 23.
这不是一个好的计划,特别是如果您打算通过 Play 商店发货,您会 have to raise the values again shortly。
How to fix this ?
最好的解决办法是将 compileSdkVersion
和 targetSdkVersion
移回 26。
否则,修复编译器报错
在这种情况下,您的清单在 <application>
上有 android:roundIcon
,并且 android:roundIcon
在 API 级别 23 时不存在。您是说,通过 compileSdkVersion 23
,你想使用 API 级别 23 存在的规则进行编译,这包括不使用当时不存在的东西。因此,从您的实际清单中删除 android:roundIcon
。