Xamarin Android INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

时间:2018-11-13 14:23:29

标签: android xamarin xamarin.android android-manifest

在调试模式下使用Visual Studio部署Xamarin Android应用程序时,我收到上述错误,编译过程可以正常完成,但是我无法部署。

该应用在Android 8.1.0上运行良好,但在其他任何较低版本中均无法运行。

错误:

>Project "Empresa1.SMPay.Target.Droid.csproj" (Install target(s)):
>C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.0-rc1\zipalign.exe 4 "E:\HenkoTI\Empresa1\SMPay\src\mpay\app\Empresa1.SMPay.Target.Droid\obj\Debug\android\bin\br.com.henkoti.empresaum.smpay.apk" "bin\Debug\\br.com.henkoti.empresaum.smpay-Signed.apk" 
>C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.0-rc1\apksigner.BAT sign --ks "C:\Users\rodri\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 18 --max-sdk-version 27  bin\Debug\br.com.henkoti.empresaum.smpay-Signed.apk 
>Unexpected install output:     pkg: /data/local/tmp/br.com.henkoti.empresaum.smpay-Signed.apk
>Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
>
>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.<InstallPackage>b__0(Task`1 t)
>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
>   at System.Threading.Tasks.Task.Execute()
>Done building project "Empresa1.SMPay.Target.Droid.csproj".
>Build succeeded.
>Unexpected install output:     pkg: /data/local/tmp/br.com.henkoti.empresaum.smpay-Signed.apk
>Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
>
>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.<InstallPackage>b__0(Task`1 t)
>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
>   at System.Threading.Tasks.Task.Execute()

AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.henkoti.empresaum.smpay" android:installLocation="auto" android:versionName="20181108.0" android:versionCode="4">
  <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="27" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.NFC" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.BIND_NFC_SERVICE" />
  <uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
  <application android:icon="@drawable/ic_launcher" android:theme="@style/MainTheme" android:label="SIGO" android:allowBackup="true" android:fullBackupContent="@xml/my_backup_rules">
    <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
    </provider>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
  </application>
</manifest>

已编译的AndroidManifest-Obj文件夹

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.henkoti.empresaum.smpay" android:installLocation="auto" android:versionName="20181108.0" android:versionCode="4">
  <uses-sdk android:minSdkVersion="18" android:targetSdkVersion="27" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.NFC" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.BIND_NFC_SERVICE" />
  <uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-feature android:name="android.hardware.camera" android:required="false" />
  <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
  <uses-feature android:name="android.hardware.location.gps" />
  <uses-feature android:name="android.hardware.location.network" />
  <application android:icon="@drawable/ic_launcher" android:theme="@style/MainTheme" android:label="SIGO" android:allowBackup="true" android:fullBackupContent="@xml/my_backup_rules" android:name="md5eaa617bc1882abd453813d82db97fb16.MainApplication" android:debuggable="true">
    <provider android:name="android.support.v4.content.FileProvider" android:authorities="br.com.henkoti.empresaum.smpay.fileprovider" android:exported="false" android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
    </provider>
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />
    <service android:enabled="true" android:exported="true" android:name="Empresa1.SMPay.HCECardService" android:permission="android.permission.BIND_NFC_SERVICE">
      <meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="@xml/aid_list" />
      <intent-filter>
        <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
    </service>
    <activity android:configChanges="orientation|screenSize" android:launchMode="standard" android:screenOrientation="portrait" android:theme="@style/MainTheme" android:name="md5eaa617bc1882abd453813d82db97fb16.MainActivity" />
    <activity android:icon="@drawable/ic_launcher" android:label="SIGO" android:noHistory="true" android:screenOrientation="portrait" android:theme="@style/SplashTheme" android:name="md5eaa617bc1882abd453813d82db97fb16.SplashActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <receiver android:enabled="true" android:label="Connectivity Plugin Broadcast Receiver" android:name="md592d74be4bac08a7af63848ae15d2f86e.ConnectivityChangeBroadcastReceiver" />
    <activity android:configChanges="orientation|screenSize" android:name="md5cf4be63b82b35b5ba951617c70f88a94.FilePickerActivity" />
    <activity android:configChanges="orientation|screenSize" android:name="md591f613f6733d8b6e91e929a922515c0e.MediaPickerActivity" />
    <receiver android:enabled="true" android:exported="false" android:name="md5b60ffeb829f638581ab2bb9b1a7f4f3f.PowerSaveModeBroadcastReceiver" />
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="br.com.henkoti.empresaum.smpay.mono.MonoRuntimeProvider.__mono_init__" />
    <!--suppress ExportedReceiver-->
    <receiver android:name="mono.android.Seppuku">
      <intent-filter>
        <action android:name="mono.android.intent.action.SEPPUKU" />
        <category android:name="mono.android.intent.category.SEPPUKU.br.com.henkoti.empresaum.smpay" />
      </intent-filter>
    </receiver>
    <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="@style/com_facebook_activity_theme" />
    <activity android:name="com.facebook.CustomTabMainActivity" />
    <!--
         The initialization ContentProvider will call FacebookSdk.sdkInitialize automatically
         with the application context. This config is merged in with the host app's manifest,
         but there can only be one provider with the same authority activated at any given
         point; so if the end user has two or more different apps that use Facebook SDK, only the
         first one will be able to use the provider. To work around this problem, we use the
         following placeholder in the authority to identify each host application as if it was
         a completely different provider.
        -->
    <provider android:name="com.facebook.internal.FacebookInitProvider" android:authorities="br.com.henkoti.empresaum.smpay.FacebookInitProvider" android:exported="false" />
    <activity android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:excludeFromRecents="true" android:exported="false" />
    <!--Service handling Google Sign-In user revocation. For apps that do not integrate with
            Google Sign-In, this service will never be started.-->
    <service android:name="com.google.android.gms.auth.api.signin.RevocationBoundService" android:exported="true" android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
    <activity android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
  </application>
</manifest>

SplashActivity

    using Android.OS;
    using Android.App;
    using Android.Content.PM;

    namespace Empresa1.SMPay.Target.Droid
    {
        [Activity(Label = "SIGO",
                  Icon = "@drawable/ic_launcher",
                  Theme = "@style/SplashTheme",
                  MainLauncher = true,
                  NoHistory = true,
                  ScreenOrientation = ScreenOrientation.Portrait)]    
        public class SplashActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
        {
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
                this.StartActivity(typeof(MainActivity));
            }
        }
    }

MainActivity

    using System.Net;

    using Android.App;
    using Android.OS;
    using Android.Content;
    using Android.Content.PM;

    using Xamarin.Forms;
    using Xamarin.Facebook;
    using Plugin.Toasts;
    using Plugin.Permissions;
    using Acr.UserDialogs;
    using Autofac;

    using Empresa1.SMPay.Application;
    using Empresa1.SMPay.Application.IoC;
    using Empresa1.SMPay.Target.Droid.Services;
    using Empresa1.SMPay.Infra.Platform.Services;
    using Android.Gms.Auth.Api;
    using InteractiveAlert;
    using Xfx;
    using FFImageLoading.Forms.Droid;

    namespace Empresa1.SMPay.Target.Droid
    {
        [Activity(Theme = "@style/MainTheme",
                    LaunchMode = LaunchMode.Multiple,
                    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
                    ScreenOrientation = ScreenOrientation.Portrait)]
        public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
        {
            protected override void OnCreate(Bundle bundle)
            {
                TabLayoutResource = Resource.Layout.Tabbar;
                ToolbarResource = Resource.Layout.Toolbar;

                base.OnCreate(bundle);

                // Facebook
                FacebookSdk.SdkInitialize(this.ApplicationContext);

                global::Xamarin.Forms.Forms.Init(this, bundle);

                // Calendar
                XamForms.Controls.Droid.Calendar.Init();

                // SSL
                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

                // Permissions
                Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);

                // Toast
                DependencyService.Register<ToastNotification>();
                ToastNotification.Init(this);

                // Dialogs
                UserDialogs.Init(() => (Activity)Forms.Context);
                InteractiveAlerts.Init(() => this);

                // XfxControls
                XfxControls.Init();

                // FFImageLoading
                CachedImageRenderer.Init(true);            

                LoadApplication(new Empresa1.SMPay.Application.App(new Setup(this.ApplicationContext, this, TelephonyService)));            
            }

            protected override void OnStart()
            {
                base.OnStart();
            }

            protected override void OnResume()
            {
                base.OnResume();
            }

            protected override void OnPause()
            {
                base.OnPause();
            }

            protected override void OnStop()
            {
                base.OnStop();
            }

            public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
            {
                PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
                //base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }

            protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (App.FacebookSinging)
                {
                    // facebook auth
                    var facebookService = IoCContainer.Container.Resolve<IFacebookService>();
                    if (facebookService != null)
                    {
                        (facebookService as DroidFacebookService)._callbackManager.OnActivityResult(requestCode, (int)resultCode, data);
                    }
                }
                else if (App.GoogleSinging)
                {
                    // google auth
                    if (requestCode == 1)
                    {
                        var result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
                        DroidGoogleService.Instance.OnAuthCompleted(result); // TODO
                    }
                }
            }
        }
    }

这里的任何人都知道,我该怎么办?

我拍了一些屏幕截图添加到这里:

enter image description here enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

最后,我能够解决此问题,解决方案是将HCECardService的前缀名称更改为lowecase。

之前:Empresa1.SMPay.HCECardService

之后:empresa1.smpay.HCECardService

[Service(Exported = true, Enabled = true, Permission = "android.permission.BIND_NFC_SERVICE", Name = "empresa1.smpay.HCECardService"), IntentFilter(new[] { "android.nfc.cardemulation.action.HOST_APDU_SERVICE" }, Categories = new[] { "android.intent.category.DEFAULT" }),
MetaData("android.nfc.cardemulation.host_apdu_service", Resource = "@xml/aid_list")]
public class HCECardService : HostApduService
{ ... }