【发布时间】:2021-11-10 22:15:16
【问题描述】:
我在 Jetpack Compose 项目中遇到此错误。
清单合并失败:需要明确指定 android:exported。当相应组件定义了 Intent 过滤器时,面向 Android 12 及更高版本的应用需要为 android:exported 指定显式值。详情见https://developer.android.com/guide/topics/manifest/activity-element#exported
这一切都是从我添加此依赖项开始的
implementation 'com.shakebugs:shake:14.4.0'
我按照这里的设置https://www.shakebugs.com/docs/android/setup
这是我的清单文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uticodes.compose_otp_input_field">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Compose_otp_input_field">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Compose_otp_input_field.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> ```
App class
```class App : Application() {
override fun onCreate() {
super.onCreate()
Shake.getReportConfiguration().isInvokeShakeOnShakeDeviceEvent = true
Shake.start(this, "clientId", "clientScret")
}
} ```
My compileSdk ```compileSdk 31 ``` , ```minSdk 21``` , ``` kotlinCompilerVersion '1.5.21'``` , ```compose_version = '1.0.1' ``` , ```gradle:7.0.1 ```
【问题讨论】:
-
检查您的合并清单以查看库添加了哪些其他活动。确保您使用的是这些库的最新版本。并考虑使用清单合并规则通过您自己的清单添加
android:exported标志。 -
顺便说一句,我很抱歉 - 鉴于您的问题标题,错误似乎是针对服务,而不是活动。
-
是的,错误是针对服务的,但我的应用程序上没有任何服务类
-
更新我的原始评论:检查您的合并清单以查看库添加了哪些其他服务。确保您使用的是这些库的最新版本。并考虑使用清单合并规则通过您自己的清单添加
android:exported标志。
标签: android android-studio kotlin android-jetpack-compose