Xamarin. Android-"android:已导出"标志出现问题[重复]

pb3skfrl  于 2022-12-07  发布在  Android
关注(0)|答案(1)|浏览(144)
    • 此问题在此处已有答案**:

xamarin.forms (android) cannot update app in appstore "android:exported" attribute missing(1个答案)
昨天关门了。
我在Google Play上发布我的". aab"时遇到了错误。它说我需要添加"android:exported"标志。经过一周的研究,我尝试了所有可能的解决方案,我发现,但一个可以拯救我的解决方案,我不能使用它。解决方案听起来像:"在清单文件中添加android:exported标志"。关键是我不能在任何地方添加它,因为我没有任何服务或intent过滤器。我不知道我可以在哪里添加这个标志。下面我将告诉你我的清单是什么样子的:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="18" android:versionName="1.0" package="com.aa.bb" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
    <application android:label="My App"></application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!--this is necessary for Android v6+ to get the device name and address-->
</manifest>

我尝试在活动标签的MainActivity.cs上添加"android:exported"标志,但它导致了错误。经过一些研究,我明白如果我在那里添加,它将以某种方式重复。

    • Android清单. xml来自对象**文件夹:
<?xml version="1.0" encoding="utf-8"?>
<!--
    This code was generated by a tool.
    It was generated from E:\dev\2021\SmartTestBox\SmartTestBox\SmartTestBox.Android\Properties\AndroidManifest.xml
    Changes to this file may cause incorrect behavior and will be lost if
    the contents are regenerated.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aa.bb" android:installLocation="auto" android:versionCode="16" android:versionName="1.0">
  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <!-- this is necessary for Android v6+ to get the device name and address -->
  <application android:name="android.app.Application" android:allowBackup="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" android:extractNativeLibs="true" android:icon="@mipmap/iconapp" android:label="My App">
    <receiver android:name="crc64cea48322b3427ae9.ConnectivityChangeBroadcastReceiver" android:enabled="true" android:exported="false" android:label="Connectivity Plugin Broadcast Receiver" />
    <receiver android:name="crc643f46942d9dd1fff9.PowerSaveModeBroadcastReceiver" android:enabled="true" android:exported="false" />
    <activity android:name="crc64f524f545a0ac0932.MainActivity" android:configChanges="orientation|screenSize" android:exported="true" android:icon="@mipmap/iconapp" android:label="My App" android:roundIcon="@mipmap/ic_launcher" android:screenOrientation="portrait" android:theme="@style/MainTheme">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <receiver android:name="crc64a40206311a3a24ec.BroadcastMonitor" android:enabled="true">
      <intent-filter>
        <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
      </intent-filter>
    </receiver>
    <provider android:name="mono.MonoRuntimeProvider" android:authorities="com.aa.bb.mono.MonoRuntimeProvider.__mono_init__" android:exported="false" android:initOrder="1999999999" />
  </application>
</manifest>
zdwk9cvp

zdwk9cvp1#

在类BroadcastMonitor上,可能有[BroadcastReceiver]属性,如下所示:

[BroadcastReceiver]
public class BroadcastMonitor : BroadcastReceiver
{
}

更改它,以便显式定义exported属性。

[BroadcastReceiver(Exported = false)]
public class BroadcastMonitor : BroadcastReceiver
{
}

相关问题