Android Xamarin C#: app runs in emulator but in ac

2019-07-14 13:42发布

My app runs perfectly in the android emulator but when I try to deploy in debug configuration it fails and tells me this:

3>:Deployment failed
3>Mono.AndroidTools.InstallFailedException: Unexpected install output:  pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
3>Failure [INSTALL_PARSE_FAILED_BAD_MANIFEST]
3>
3>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
3>   at Mono.AndroidTools.AndroidDevice.<InstallPackage>c__AnonStoreyD.<>m__0(Task`1 t)
3>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
3>   at System.Threading.Tasks.Task.Execute()
3>Deployment failed because of an internal error: Unexpected install output:    pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
3>Failure [INSTALL_PARSE_FAILED_BAD_MANIFEST]

I can't seem to figure what this error really means, other than it is something to do with the android manifest?

This is my manifest:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="scout.app" android:versionCode="1"
          android:versionName="0.0.0" android:installLocation="auto">
  <uses-feature android:name="android.hardware.usb.accessory" />
  <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.RESTART_PACKAGES" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_SMS" />
  <uses-permission android:name="android.permission.RECEIVE_SMS" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <application android:label="Scout" android:debuggable="true"></application>
</manifest>

EDIT:

So when I try to deploy sometimes this error pops up instead:

2>:Deployment failed
2>Mono.AndroidTools.InstallFailedException: Unexpected install output:  pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
2>Failure [INSTALL_PARSE_FAILED_NOT_APK]
2>
2>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
2>   at Mono.AndroidTools.AndroidDevice.<InstallPackage>c__AnonStoreyD.<>m__0(Task`1 t)
2>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
2>   at System.Threading.Tasks.Task.Execute()
2>Deployment failed because of an internal error: Unexpected install output:    pkg: /data/local/tmp/Mono.Android.DebugRuntime-debug.apk
2>Failure [INSTALL_PARSE_FAILED_NOT_APK]

EDIT 2:

Sometimes this error pops up instead as well even if I havent changed anything..

1>:Deployment failed
1>Mono.AndroidTools.InstallFailedException: The package was not properly signed (NO_CERTIFICATES).
1>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
1>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass89_0.<InstallPackage>b__0(Task`1 t)
1>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
1>   at System.Threading.Tasks.Task.Execute()
1>Deployment failed because of an internal error: The package was not properly signed (NO_CERTIFICATES).

EDIT 3:

This is the manifest from App/obj/Debug/android/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="scout.app" android:versionCode="1" android:versionName="0.0.0" android:installLocation="auto">
  <uses-feature android:name="android.hardware.usb.accessory" />
  <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.RESTART_PACKAGES" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_SMS" />
  <uses-permission android:name="android.permission.RECEIVE_SMS" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <application android:label="Scout" android:debuggable="true" android:name="mono.android.app.Application" android:allowBackup="true" android:icon="@drawable/icon">
    <receiver android:enabled="true" android:label="InstructionReciever" android:name="md5f8bfa05656068c3725933b788fa9610f.SmsReciever" />
    <activity android:icon="@drawable/icon" android:label="Scout" android:name="md5657830f1484ab57cd89db0f9549d303a.MainActivity">
      <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="UsbListener" android:name="md5787c3ec38a313bacb6190da23f10b0af.UsbConnectReciever">
      <intent-filter>
        <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
      </intent-filter>
    </receiver>
    <receiver android:enabled="true" android:label="UsbListener" android:name="md5787c3ec38a313bacb6190da23f10b0af.UsbDisconnectReciever">
      <intent-filter>
        <action android:name="android.hardware.usb.action.USB_ACCESSORY_DETACHED" />
      </intent-filter>
    </receiver>
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="scout.app.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.scout.app" />
      </intent-filter>
    </receiver>
  </application>
</manifest>

1条回答
别忘想泡老子
2楼-- · 2019-07-14 14:28

I've had similar sorts of errors occur when trying to debug after installing a release version.

The fix was to manually uninstall the app via the app manager on the device first.

Sometimes it shows up in the app manager under the namespace only rather than the application name.

查看更多
登录 后发表回答