[英]I set android:exported but I am still getting error: android:exported needs to be explicitly specified for <receiver>
I am moving from SDK version 30 to 31 and I add android:exported in intent-filter but still I am getting this error:我正在从 SDK 版本 30 迁移到 31,并在意图过滤器中添加 android:exported 但仍然收到此错误:
Merging Errors: Error: android:exported needs to be explicitly specified for .合并错误:错误:需要为 . Apps targeting Android 12 and higher are required to specify an explicit value for
android:exported<\/code> when the corresponding component has an intent filter defined.
面向 Android 12 及更高版本的应用需要为
android:exported<\/code>指定显式值,前提是相应组件定义了 Intent 过滤器。
See https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#exported<\/a> for details.
有关详细信息,请参阅
https:\/\/developer.android.com\/guide\/topics\/manifest\/activity-element#exported<\/a> 。
<?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.mycompany.webviewapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<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/AppTheme">
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<activity android:name="com.mycompany.webviewapp.SplashActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.mycompany.webviewapp.MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.VIEW"></action>
</intent-filter>
</activity>
<service android:name="com.mycompany.webviewapp.FCM.MyFirebaseMessagingService">
</service>
<meta-data android:name="applovin.sdk.key"
android:value="sdk api here"/>
</application>
</manifest>
The reason is because some of the dependency libraries that you're using have elements which do not have "android:exported" attribute.原因是您使用的某些依赖库的元素没有“android:exported”属性。
You need to do this:你需要这样做:
![]()
<activity android:name="SomeActivity" android:exported="false" tools:node="merge" tools:replace="android:exported" \/><\/code><\/pre>
Now you can increase your version to 31.现在您可以将版本增加到 31。
"
I resolve my issue.我解决了我的问题。 I just check the merged manifest and look for reciver.
我只是检查合并的清单并寻找接收者。 In onesignal, I found out reciver with intent filter defined without android:exported.
在 onesignal 中,我发现了带有未定义 android:exported 的意图过滤器的接收器。 I just add android:exported="false".
我只是添加了 android:exported="false"。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.