locked
Extract MMPK File from an Android Device RRS feed

  • Question

  • User395718 posted

    Hey,

    im trying to create an App that can load a MMPK File. (From an Esri Tutorial, cant post a Link at the moment) I put the MMPK File in to my Device and tried to open it with:

    var filePath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; var mapPackagePath = Path.Combine(filePath, "Test.mmpk");

    When i Deploy, the App is tring to read the File. But it send me an Error: Esri.ArcGISRuntime.ArcGISRuntimeException: 'Invalid access: Mobile map package failed to open. Check the archive format is correct, zip file with no compression.' Do u guys know how i can extract this File, from my Device?

    Thanks for helping

    Monday, July 13, 2020 6:53 AM

Answers

  • User382871 posted

    i got it working, i didnt knew that i need to allow Storage Read Permisson on my Device ... To access the external storage, the app needs to declare the following two permissions. <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    Check the tutoiral: https://docs.microsoft.com/en-us/xamarin/android/platform/files/external-storage?tabs=windows#external-storage-permissions

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, July 23, 2020 1:19 AM

All replies

  • User382871 posted

    Extract MMPK File from an Android Device To open the MMPK file, we need to install the ArcGIS Runtime SDK. Create a 'MobileMapPackage' specifying the path to the .mmpk file and load the mobile map package with the LoadAsync method.

    ``` private async void Initialize() { // Get the path to the mobile map package. string filepath = GetMmpkPath();

    try
    {
        // Open the map package.
        MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(filepath);
    
        // Load the package.
        await myMapPackage.LoadAsync();
    
        // Display the first map in the package.
        _myMapView.Map = myMapPackage.Maps.First();
    }
    catch (Exception e)
    {
        new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
    }
    

    } ```

    You could google with the keyword with Open mobile map package to check the related tutorial.

    Monday, July 13, 2020 9:36 AM
  • User395718 posted

    @YelinZh said:

    Extract MMPK File from an Android Device To open the MMPK file, we need to install the ArcGIS Runtime SDK. Create a 'MobileMapPackage' specifying the path to the .mmpk file and load the mobile map package with the LoadAsync method.

    ``` private async void Initialize() { // Get the path to the mobile map package. string filepath = GetMmpkPath();

    try
    {
        // Open the map package.
        MobileMapPackage myMapPackage = await MobileMapPackage.OpenAsync(filepath);
    
        // Load the package.
        await myMapPackage.LoadAsync();
    
        // Display the first map in the package.
        _myMapView.Map = myMapPackage.Maps.First();
    }
    catch (Exception e)
    {
        new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
    }
    

    } ```

    You could google with the keyword with Open mobile map package to check the related tutorial.

    i did it this way :/

    Tuesday, July 14, 2020 9:04 AM
  • User382871 posted

    When i Deploy, the App is tring to read the File. But it send me an Error: If the Path.Combine doesn't work, try to splice the folder path string and the file name to get the mmpk file's path. var folderPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; var file_path = folderPath + "/" + file_name;//add the mmpk file name

    Wednesday, July 15, 2020 8:52 AM
  • User395718 posted

    i got it working, i didnt knew that i need to allow Storage Read Permisson on my Device too. I thought it happens automatically, when i enable it on AndroidManifest.

    Wednesday, July 22, 2020 7:57 AM
  • User382871 posted

    i got it working, i didnt knew that i need to allow Storage Read Permisson on my Device ... To access the external storage, the app needs to declare the following two permissions. <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    Check the tutoiral: https://docs.microsoft.com/en-us/xamarin/android/platform/files/external-storage?tabs=windows#external-storage-permissions

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, July 23, 2020 1:19 AM