我有这个错误“..app\src\main\AndroidManifest.xml:27:9-33:20 错误:
android:exported 需要为元素 显式指定。面向 Android 12 及更高版本的应用需要指定显式值android:exported
当相应的组件定义了意图过滤器时。看https://developer.android.com/guide/topics/manifest/activity-element#exported https://developer.android.com/guide/topics/manifest/activity-element#exported了解详情。
...app\src\main\AndroidManifest.xml:34:9-40:20 错误:
android:exported 需要为元素 显式指定。面向 Android 12 及更高版本的应用需要指定显式值android:exported
当相应的组件定义了意图过滤器时。看https://developer.android.com/guide/topics/manifest/activity-element#exported https://developer.android.com/guide/topics/manifest/activity-element#exported了解详情。
...app\src\main\AndroidManifest.xml:41:9-47:20 错误:
android:exported 需要为元素 显式指定。面向 Android 12 及更高版本的应用需要指定显式值android:exported
当相应的组件定义了意图过滤器时
并且不知道我应该做什么
清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.part3_2">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Part3_2"
tools:ignore="DataExtractionRules">
<activity
android:name=".MainActivity">
</activity>
<activity
android:name=".MainActivity2"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".OverlayService"
android:exported="false"
android:enabled="true"
android:foregroundServiceType="mediaProjection">
</service>
</application>
</manifest>
构建.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdk 30
defaultConfig {
applicationId "com.example.part3_2"
minSdk 28
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
ext{
fragment_version = "1.3.0-alpha07"
activity_version = "1.3.0"
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
// implementation 'androidx.fragment:fragment-ktx:1.6.0'
implementation("androidx.fragment:fragment-ktx:$fragment_version")
debugImplementation("androidx.fragment:fragment-testing:$fragment_version")
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.2.0'
implementation 'com.google.firebase:firebase-firestore-ktx:24.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation("androidx.activity:activity-ktx:$activity_version")
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.4"
}
repositories {
google()
mavenCentral()
}
我通过添加这一行解决了这个问题:
android:exported="true"
在我的 androidManifest.xml 文件中
<activity
android:name=".MainActivity"
android:exported="true"
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)