【发布时间】:2022-09-29 22:46:41
【问题描述】:
我有这个错误 \"..app\\src\\main\\AndroidManifest.xml:27:9-33:20 错误:
android:exported 需要为元素 <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity> 显式指定。当相应组件定义了 Intent 过滤器时,面向 Android 12 及更高版本的应用需要为 android:exported 指定显式值。有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported。
...app\\src\\main\\AndroidManifest.xml:34:9-40:20 错误:
android:exported 需要为元素 <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity> 显式指定。当对应的组件定义了意图过滤器时,面向 Android 12 及更高版本的应用需要为 android:exported 指定显式值。有关详细信息,请参阅https://developer.android.com/guide/topics/manifest/activity-element#exported。
...app\\src\\main\\AndroidManifest.xml:41:9-47:20 错误:
android:exported 需要为元素 <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity> 显式指定。当相应组件定义了 Intent 过滤器时,面向 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()
}