问题:我在尝试运行/安装我的 MAUI Android 应用程序时收到以下信息:
Unable to Install: This app was built for an older version of Android and doesn't include the latest privacy protections
我尝试过的:我更新了 .csproj 文件的属性以及 AndroidManifest.xml 文件。 我在解决方案上尝试了 nuget 包恢复。我进行了清理和重建。
我还需要做什么来解决这个问题?
属性/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.arc.myapp.p" android:versionName="185.06.0" android:installLocation="auto">
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<uses-sdk android:targetSdkVersion="34" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<application android:label="MyApp" android:debuggable="true" android:icon="@drawable/myapp_icon_180px" android:supportsRtl="true"> android:requestLegacyExternalStorage="true"
android:theme="@style/ETheme">
Myapp.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-android34.0</TargetFrameworks>
<!--<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>-->
<OutputType>Exe</OutputType>
<RootNamespace>MyApp</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>MyApp</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.myapp</ApplicationId>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
由于新的 Target API 要求,未达到特定 API 级别的应用程序被某些系统阻止。在某些情况下,这种情况不应该发生,但对于生产中使用非常旧的 SDK 的一些应用程序来说,这是一个导致问题的问题。
有关更多信息,您可以查看:Google Play 应用的目标 API 级别要求。