首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xamarin Android INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

Xamarin Android INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
EN

Stack Overflow用户
提问于 2018-11-13 14:23:28
回答 1查看 1K关注 0票数 1

当我在调试模式下使用Visual部署我的Xamarin Android应用程序时,我收到了上述错误,编译过程完成得很好,但我无法部署。

该应用程序在Android8.1.0中运行良好,但在其他任何较低版本中则不然。

错误:

代码语言:javascript
复制
>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

代码语言:javascript
复制
<?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文件夹

代码语言:javascript
复制
<?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

代码语言:javascript
复制
    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

代码语言:javascript
复制
    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
                    }
                }
            }
        }
    }

在座的人都知道,我该怎么办?

我在这里加了一些截图:

EN

回答 1

Stack Overflow用户

发布于 2018-11-13 21:10:49

最后,我解决了这个问题,解决方案是将HCECardService的前缀名更改为lowecase。

以前: Empresa1.SMPay.HCECardService

后: empresa1.smpay.HCECardService

代码语言:javascript
复制
[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
{ ... }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53283162

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档