Where to put the MMPK File

202
5
07-06-2020 05:18 AM
WwLl
by
New Contributor II

Hey all,

im trying to do this tutorial Add layers to a map (offline) | ArcGIS for Developers 

I need to tell the apk where the location of the PackageFolder is. When i put it on my device or i use the path from my pc. It will not load the mmpk, when i test the apk.

this is how i write it:

var mapPackageFolder = @"C:\Users\Test\Desktop\XamarinTest\Vegetation Management";
var mapPackageFile = @"SUEWAG VTPK Grundkarte Beschriftung.mmpk";

this is how i tested it, when i put the folder it to my Device

var mapPackageFolder = @"Interner Speicher\XamarianTest";
var mapPackageFile = @"SUEWAG VTPK Grundkarte Beschriftung.mmpk";

do i miss something?

0 Kudos
5 Replies
JoeHershman
MVP Regular Contributor

What platform, WPF or UWP?  UWP restricts where you could put files.

0 Kudos
WwLl
by
New Contributor II

I think i need to explain more. Im using Visual Studio and Xamarin to create iOS and Android applications. Im working with Windows10. 

I dont use UWP and WPF, maybe im using the wrong tutorial???

0 Kudos
JoeHershman
MVP Regular Contributor

There is no C: drive on an iOS or Android device, you cannot set a location like you would in Windows with a full path.

The easiest way is to use a Environment.SpecialFolder because this returns the platform specific location.

var mapPackageFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SomeSubfolder", "SomePackageName");
WwLl
by
New Contributor II

Thanks it helped me, but i got it working with Android.OS.Environment.ExternalStorageDirectory.

But now i get this Error: 

Esri.ArcGISRuntime.ArcGISRuntimeException: 'Invalid access: Mobile map package failed to open. Check the archive format is correct, zip file with no compression.' 

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Are you able to open the file with standard .NET File APIs with that path? Ie File.OpenRead(pathToMmpk) ?
Also make sure you configure your application manifest to read in that location.
With android you can't really package files with the application itself - you can only package assets, and you'd have to "unpack" those files first to a local folder before opening, or downloading it from an online location to that location on first access.

0 Kudos