【发布时间】:2021-12-01 06:43:33
【问题描述】:
当我在 Flutter 中设置编译 SDK 30 时,我得到了这些错误
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing
com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> One or more issues found when checking AAR metadata values:
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.appcompat:appcompat:1.4.0.
AAR metadata file:
C:\Users\WasiSoft\.gradle\caches\transforms3\6a6bfbcf60d09272b0cdf4bed2dc0443\
transformed\appcompat-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.appcompat:appcompat-resources:1.4.0.
AAR metadata file:
C:\Users\WasiSoft\.gradle\caches\transforms3\8fe9ccdb464c8d3dff16cf232813d78c\
transformed\jetified-appcompat-resources-1.4.0\META-INF\com\
android\build\gradle\aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.emoji2:emoji2-views-helper:1.0.0.
AAR metadata file:
C:\Users\WasiSoft\.gradle\caches\transforms3\aa5ebfefee6d35dee263bd0cd4753256\
transformed\jetified -emoji2-views-helper-1.0.0\META-INF\com\android\build\gradle\
aarmetadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.emoji2:emoji2:1.0.0.
AAR metadata file: C:\Users\WasiSoft\.gradle\caches\transforms-
3\b0e38b05362ae33360070f9b30618d9f\transformed\jetified-emoji21.0.0\METAINF\com\android\build
\gradle\aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core:1.7.0.
AAR metadata file: C:\Users\WasiSoft\.gradle\caches\transforms-
3\028820553fa44b6579541915f81b128d\transformed\core1.7.0\METAINF\com\android\build\gradle\aar
-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-process:2.4.0.
AAR metadata file: C:\Users\WasiSoft\.gradle\caches\transforms-
3\623708390cd51304eeeb10f79f7ceb8b\transformed\jetified-lifecycle-process-2.4.0\META-
INF\com\android\build\gradle\aar-metadata.properties.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: C:\Users\WasiSoft\.gradle\caches\transforms-
3\77475f45e2af1906c765abcaefbb8c4c\transformed\lifecycle-runtime-2.4.0\META-
INF\com\android\build\gradle\aar-metadata.properties.
如果我使用的是 SDK 31,那么我遇到了这个问题
C:\Users\WasiSoft\AndroidStudioProjects\wsms_employee\android\app\src\
main\AndroidManifest.xml Error:
android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12
and higher are required to specify an explicit value for `andro
id:exported` when the corresponding component has an intent filter defined. See
https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.comple.example">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
tools:replace="android:label"
android:name="io.flutter.app.FlutterApplication"
android:hardwareAccelerated="true"
android:label="WSMS Employee"
android:icon="@mipmap/ic_launcher"
>
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|
screenSize|smallestScreenSize|locale|
layoutDirection|fontScale|screenLayout|density|uiMode"
android:launchMode="singleTop"
android:showWhenLocked="true"
android:exported="true"
android:theme="@style/LaunchTheme"
android:turnScreenOn="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
我尝试了所有可能的方法来解决这个问题,我不知道为什么会发生这种情况,请仔细研究一下。还有如何在编译 sdk 31 时设置活动。这在颤振中非常困难
【问题讨论】:
-
你试过
flutter clean吗? -
@StefanGaller 一切都失败了。
-
@Adnanhaider 有什么解决办法吗?
-
找到解决方案了吗?
-
@AbdullahKhan 请检查我的回答我希望你发现这个问题并解决它
标签: flutter android-studio android-manifest