INSTALL_PARSE_FAILED_MANIFEST_MALFORMED错误,使用Xamarin.Forms在Android 13上发生。

huangapple go评论58阅读模式
英文:

INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error on android 13 using xamarin.forms

问题

I am using Xamarin Forms for my project to develop an Android application. I got the error below when I updated the android:targetSdkVersion from 30 to 33.

My AndroidManifest.xml code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.myapplication.app" android:versionName="2.6.1" android:versionCode="16">
    <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="33" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-feature android:name="android.hardware.telephony" android:required="false" />
    <uses-feature android:name="android.hardware.location" android:required="false" />
    <uses-feature android:name="android.hardware.location.gps" android:required="false" />
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.location.network" android:required="false" />
    <!--<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />-->
    <uses-permission android:name="android.permission.CALL_PHONE" android:required="false" />
    <application android:allowBackup="true" android:requestLegacyExternalStorage="true" android:label="FieldDirect" android:largeHeap="true" android:theme="@style/MyTheme">
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
        <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/icon_transparent" />
        <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/brown" />
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="MyKey" />
        <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
        <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>
        <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.myapplication.app.fileprovider" android:exported="false" android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
        </provider>
    </application>
</manifest>

Please anyone help to resolve this issue.

英文:

I am using xamarin forms for my project to develop android application. I got the error below when i udate the android:targetSdkVersion from 30 to 33.

> Severity Code Description Project File Line Suppression State Error
> ADB0010: Mono.AndroidTools.InstallFailedException: Unexpected install
> output: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse
> during installPackageLI: /data/app/vmdl417360231.tmp/base.apk (at
> Binary XML file line #50): crc64bf328679f9896e0c.MyFirebaseIIDService:
> Targeting S+ (version 31 and above) requires that an explicit value
> for android:exported be defined when intent filters are present]
>
> at
> Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String
> output, String packageName) in
> /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Mono.AndroidTools/Internal/AdbOutputParsing.cs:line
> 357 at System.Threading.Tasks.Task.Execute()
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task) at
> AndroidDeviceExtensions.<PushAndInstallPackageAsync>d__12.MoveNext()
> in
> /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:line
> 208
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> AndroidDeviceExtensions.<PushAndInstallPackageAsync>d__12.MoveNext()
> in
> /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/external/androidtools/Xamarin.AndroidTools/Devices/AndroidDeviceExtensions.cs:line
> 225
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task) at
> Xamarin.Android.Tasks.FastDeploy.<InstallPackage>d__106.MoveNext() in
> /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line
> 351
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> Xamarin.Android.Tasks.FastDeploy.<InstallPackage>d__106.MoveNext() in
> /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line
> 368
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task) at
> Xamarin.Android.Tasks.FastDeploy.<RunTaskAsync>d__100.MoveNext() in
> /Users/runner/work/1/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line
> 216 0

My AndroidManifest.xml code:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:installLocation=&quot;internalOnly&quot; package=&quot;com.myapplication.app&quot; android:versionName=&quot;2.6.1&quot; android:versionCode=&quot;16&quot;&gt;
&lt;uses-sdk android:minSdkVersion=&quot;24&quot; android:targetSdkVersion=&quot;33&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.ACCESS_LOCATION_EXTRA_COMMANDS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;
&lt;uses-feature android:name=&quot;android.hardware.telephony&quot; android:required=&quot;false&quot; /&gt;
&lt;uses-feature android:name=&quot;android.hardware.location&quot; android:required=&quot;false&quot; /&gt;
&lt;uses-feature android:name=&quot;android.hardware.location.gps&quot; android:required=&quot;false&quot; /&gt;
&lt;uses-feature android:name=&quot;android.hardware.camera&quot; android:required=&quot;false&quot; /&gt;
&lt;uses-feature android:name=&quot;android.hardware.location.network&quot; android:required=&quot;false&quot; /&gt;
&lt;!--&lt;uses-permission android:name=&quot;android.permission.ACCESS_LOCATION_EXTRA_COMMANDS&quot; /&gt;  
&lt;uses-permission android:name=&quot;android.permission.ACCESS_MOCK_LOCATION&quot; /&gt;--&gt;
&lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot; android:required=&quot;false&quot; /&gt;
&lt;application android:allowBackup=&quot;true&quot; android:requestLegacyExternalStorage=&quot;true&quot; android:label=&quot;FieldDirect&quot; android:largeHeap=&quot;true&quot; android:theme=&quot;@style/MyTheme&quot;&gt;
&lt;uses-library android:name=&quot;org.apache.http.legacy&quot; android:required=&quot;false&quot; /&gt;
&lt;meta-data android:name=&quot;com.google.firebase.messaging.default_notification_icon&quot; android:resource=&quot;@drawable/icon_transparent&quot; /&gt;
&lt;meta-data android:name=&quot;com.google.firebase.messaging.default_notification_color&quot; android:resource=&quot;@color/brown&quot; /&gt;
&lt;meta-data android:name=&quot;com.google.android.geo.API_KEY&quot; android:value=&quot;MyKey&quot; /&gt;
&lt;receiver android:name=&quot;com.google.firebase.iid.FirebaseInstanceIdInternalReceiver&quot; android:exported=&quot;false&quot; /&gt;
&lt;receiver android:name=&quot;com.google.firebase.iid.FirebaseInstanceIdReceiver&quot; android:exported=&quot;true&quot; android:permission=&quot;com.google.android.c2dm.permission.SEND&quot;&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;com.google.android.c2dm.intent.RECEIVE&quot; /&gt;
&lt;action android:name=&quot;com.google.android.c2dm.intent.REGISTRATION&quot; /&gt;
&lt;category android:name=&quot;${applicationId}&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/receiver&gt;
&lt;provider android:name=&quot;android.support.v4.content.FileProvider&quot; android:authorities=&quot;com.myapplication.app.fileprovider&quot; android:exported=&quot;false&quot; android:grantUriPermissions=&quot;true&quot;&gt;
&lt;meta-data android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot; android:resource=&quot;@xml/file_paths&quot; /&gt;
&lt;/provider&gt;
&lt;/application&gt;
&lt;/manifest&gt;

Please anyone help to resolve this issue.

答案1

得分: 1

[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during
installPackageLI: /data/app/vmdl417360231.tmp/base.apk (at Binary XML
file line #50): crc64bf328679f9896e0c.MyFirebaseIIDService: Targeting
S+ (version 31 and above) requires that an explicit value for
android:exported be defined when intent filters are present]

From document Safer component exporting,we could find that

If your app targets Android 12 or higher and contains activities,
services, or broadcast receivers that use intent filters, you must
explicitly declare the android:exported attribute for these app
components.

and we can notice the warning as follows:

Warning: If an activity, service, or broadcast receiver uses intent
filters and doesn't have an explicitly-declared value for
android:exported, your app can't be installed on a device that runs
Android 12 or higher.

From the error log you posted above, you can recheck if you have added android:exported to MyFirebaseIIDService.cs

For example:

[Service(Exported=true, Name="com.xamarin.example.DemoService")]
public class MyFirebaseIIDService : Service
{

}

英文:

> [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during
> installPackageLI: /data/app/vmdl417360231.tmp/base.apk (at Binary XML
> file line #50): crc64bf328679f9896e0c.MyFirebaseIIDService: Targeting
> S+ (version 31 and above) requires that an explicit value for
> android:exported be defined when intent filters are present]

From document Safer component exporting,we could find that

> If your app targets Android 12 or higher and contains activities,
> services, or broadcast receivers that use intent filters, you must
> explicitly declare the android:exported attribute for these app
> components.

and we can notice the warning as follows:

> Warning: If an activity, service, or broadcast receiver uses intent
> filters and doesn't have an explicitly-declared value for
> android:exported, your app can't be installed on a device that runs
> Android 12 or higher.

From the error log you posted above, you can recheck if you have added android:exported to MyFirebaseIIDService.cs

For example:

[Service(Exported=true, Name=&quot;com.xamarin.example.DemoService&quot;)]
public class MyFirebaseIIDService : Service
{
}

huangapple
  • 本文由 发表于 2023年3月31日 18:17:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897378.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定