如何在xamarin中为Android V12配置我的表现

发布于 2025-02-03 04:56:14 字数 2189 浏览 4 评论 0原文

我当前

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cecop.cecop" android:installLocation="auto" android:versionCode="132" android:versionName="14.00">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application android:label="cecop" android:icon="@drawable/cecop">
        <!--Especifique el número de versión de Google Play Services en el manifiesto y la clave de Google Maps V2 API. -->
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyBLH0HotP0r5yfuX8xFESZhM5TS0PcluKs" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
        <!-- Needed for Android >= Nougat for file access -->
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.cecop.cecop.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
        </provider>
        <service android:name="com.cecop.cecop.ServicioSegundoPlano" android:exported="true"></service>
    </application>
</manifest>

在服务和主要活动中的

  [Service(Exported = true, Name = "com.cecop.cecop.ServicioSegundoPlano")]
    public class ServicioStartForeground : Service
    {
     ...
    }

    [Activity(Label = "Cecop", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {...
    }

清单,我在清单中写了此属性,因此您在Google Play上没有出现错误吗?

您已上传具有活动,活动的别名,服务或带有ATNTS过滤器的发射接收器,但没有建立Android属性:导出。该文件不能安装在Android 12或更高版本上。

My current manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cecop.cecop" android:installLocation="auto" android:versionCode="132" android:versionName="14.00">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application android:label="cecop" android:icon="@drawable/cecop">
        <!--Especifique el número de versión de Google Play Services en el manifiesto y la clave de Google Maps V2 API. -->
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyBLH0HotP0r5yfuX8xFESZhM5TS0PcluKs" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
        <!-- Needed for Android >= Nougat for file access -->
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.cecop.cecop.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
        </provider>
        <service android:name="com.cecop.cecop.ServicioSegundoPlano" android:exported="true"></service>
    </application>
</manifest>

In the service and main activity I have this attributes

  [Service(Exported = true, Name = "com.cecop.cecop.ServicioSegundoPlano")]
    public class ServicioStartForeground : Service
    {
     ...
    }

    [Activity(Label = "Cecop", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {...
    }

As I write in the manifest so you don't get the error in the publication on Google Play?

You have uploaded an APK or Android App Bundle that has an activity, an alias of activity, a service or an emission receiver with atnts filter, but without establishing the Android property: exported. This file cannot be installed on Android 12 or later versions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2025-02-10 04:56:14

如果使用[Service]属性,则不必在AndroidManifest.xml中定义任何内容。 Xamarin为您生成了它。

您需要在Android 12上进行的唯一更改是,您需要添加是否导出服务是否导出。默认值应为false,除非您需要从另一个应用程序中访问它。

如果您使用的是Xamarin.Estenters或其他包含服务的库,请确保它们是最新的,并且还遵循有关在其服务中添加导出属性的这些规则。

You don't have to define anything in AndroidManifest.xml if you are using the [Service] attribute. Xamarin generates this for you.

The only change you need to make on Android 12, is that you need to add whether a Service is exported or not. Default should be false unless you need to access it from another App than yours.

If you are using something like Xamarin.Essentials or other libraries that also contain services, make sure they are up to date and also follow these rules about adding Exported property on their services.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文