Is it possible to share and install the app on other device using APK file generated in debug mode?

DevMaranDevMaran Member ✭✭
edited May 2018 in Xamarin.Forms

I am new to Xamarin development and developing an app in Xamarin.forms using Visual Studio 2017 on Mac. I am testing my app using USB-Debugging/Genymotion on devices and also getting generated APK file at location: XYZ.Android/bin/debug/com.XYZ.XYZ-Signed.apk

The app crashes when I am trying to install it on other devices using the generated APK file at the above-mentioned location right after the Splash screen disappears?

In error reporting I am getting the error: "Unable to find application mono.android.platform.api level 27 or xamarin.android.platform" on Mi5a device

I have tried the solutions at URLs:
https://stackoverflow.com/questions/42243195/unable-to-find-application-mono-android-platform-apilevel-24-or-xamarin-android
https://stackoverflow.com/questions/37063507/unable-to-find-application-mono-android-platform-apilevel-23-or-xamarin-android?rq=1
https://stackoverflow.com/questions/48781713/xamarin-android-app-crashing?rq=1

So is it possible to share and install the app on other device using APK file generated in debug mode OR I need to create APK file in the release mode?

code: https://www.dropbox.com/s/525zce3ysoi56j6/FlashControl.zip?dl=0

Please Assist me for the right settings.

Thanks in advance.

Best Answer

Answers

  • TimSaeleeTimSaelee USMember ✭✭

    You are correct, you have to prepare the package for distribution (the generated APK you find in your bin folders do not work for distribution).

    Follow the instructions here to prepare your app for release mode:
    https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=vsmac

    The last step you find there is Archive for Publishing, which will build the project and bundle it into an archive file. You can have as many archive files as you want. Just select the version of the archive you want to distribute, and click Sign and Distribute, and then select Ad-Hoc to save the APK to your disk for installing on other devices.

    Also, if you don't have a signing identity yet, you'll have to create one. It's fairly straight forward here:
    https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/index?tabs=vsmac

  • DevMaranDevMaran Member ✭✭
    edited May 2018

    @TimSaelee I am getting error:

    java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_26 or Xamarin.Android.Platform!
    at android.app.ActivityThread.installProvider(ActivityThread.java:5934)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:5523)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5462)
    at android.app.ActivityThread.-wrap2(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:163)
    at android.app.ActivityThread.main(ActivityThread.java:6205)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
    Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_26 or Xamarin.Android.Platform!
    at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38)
    at android.app.ActivityThread.installProvider(ActivityThread.java:5931)
    ... 10 more
    Caused by: android.content.pm.PackageManager$NameNotFoundException: Xamarin.Android.Platform
    at android.app.ApplicationPackageManager.getApplicationInfoAsUser(ApplicationPackageManager.java:351)
    at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:333)
    at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:32)
    ... 11 more

    I am getting the above issue when the target framework set to API Level 26. So want to know the reason behind the exception.

    But in my previous project on Xamarin native, I was using the same way to share the APK with QA team before I updated the visual studio and other dependencies.

  • DevMaranDevMaran Member ✭✭
    edited May 2018

    @TimSaelee said:
    You are correct, you have to prepare the package for distribution (the generated APK you find in your bin folders do not work for distribution).

    Follow the instructions here to prepare your app for release mode:
    https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=vsmac

    The last step you find there is Archive for Publishing, which will build the project and bundle it into an archive file. You can have as many archive files as you want. Just select the version of the archive you want to distribute, and click Sign and Distribute, and then select Ad-Hoc to save the APK to your disk for installing on other devices.

    Also, if you don't have a signing identity yet, you'll have to create one. It's fairly straightforward here:
    https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/index?tabs=vsmac

    @TimSaelee, I am still getting the same issue with signed apk with custom keystore file. I am using the latest version of xamarin.form and all the Android SDKs from API level 19 to 27.

  • DevMaranDevMaran Member ✭✭

    @TimSaelee Thanks for your assistance, I had Checked Multi-Dex option which causing the error in release mode. Now the errors are resolved. Thanks for your valuable time.

Sign In or Register to comment.