当Xamarin.Android设置为Android 12时,我收到
“您上传了一个APK或Android应用包,其中包含带有意图过滤器的活动、活动别名、服务或广播接收器,但未设置'android:exported'属性。此文件无法安装在Android 12或更高版本上。请参阅:developer.android.com/about/versions/12/behavior-changes-12#exported“
将APK上传到Google Play控制台以用于新版本时出错。
我已经将Exported属性添加到我的活动和服务中,但仍然设置此错误。
[Activity(Label = "@string/AppDrawerName", Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_launcher_round", Theme = "@style/MainTheme", MainLauncher = true, Exported = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
服务
[Service(Exported = true)]
public class BarcodeService : IBarcodeService
{
从编译输出中,我可以看到下面的消息
命名空间“com.google.android.gms.stats”用于:安卓系统清单. xml,安卓系统清单. xml.
android:exported需要为元素〈service#crc640921eac73192168e.PNMessagingService〉显式指定。当相应组件定义了Intent过滤器时,面向Android 12及更高版本的应用需要为android:exported
指定显式值。https://developer.android.com/guide/topics/manifest/activity-element#exported有关详细信息,请参阅www.example.com。
然后我进入“obj/Debug”文件夹打开清单,我可以看到下面的服务是自动生成的
<service android:name="crc640921eac73192168e.PNMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
有人知道如何为这个服务设置[Service(Exported = true)]
吗?因为它是自动生成的。
2条答案
按热度按时间b5buobof1#
在从下面的“obj/Debug”AndroidManifest.xml中获得信息后
我把它手动添加到我的项目的清单下的标签,最后它的工作。请看下面的清单在项目中。
最好检查obj/文件夹上的Manifest,以确保所有文件都在父文件夹中具有导出集。
voase2hg2#
详细输出MSBuild项目输出的详细程度就达到了这个目的。
当我打开这个功能时,我发现需要一个NotificationPushService和一个TokenService元素来添加android:exported=“true”标签。