Can't load MMPK file, using .NET MAUI, Android and the ESRI Tutorial

690
3
07-03-2023 02:52 PM
Labels (2)
mprogers
New Contributor II

I'm following the ESRI tutorial on how to display a MMPK file. I've got the program running on a physical device, and it brings up a mapview, but there's nothing in it. The code itself is quite short:

string pathToMobileMapPackage = System.IO.Path.Combine(Environment.CurrentDirectory, @"MahouRivieraTrails.mmpk");MobileMapPackage mahouRivieraTrails_MobileMapPackage = new MobileMapPackage(pathToMobileMapPackage);await mahouRivieraTrails_MobileMapPackage.LoadAsync();this.Map = mahouRivieraTrails_MobileMapPackage.Maps.FirstOrDefault();

​ But when I run it I get this error:

Thread started: #5
[monodroid-assembly] open_from_bundles: failed to load assembly System.Collections.Specialized.dll

Loaded assembly:/data/data/com.companyname.displayamap/files/.__override__/System.Collections.Specialized.dll [External]

ArcGIS Maps SDK: Load Error: MobileMapPackage
System.IO.FileNotFoundException
File not found: /MahouRivieraTrails.mmpk

The instructions are to just drag the mmpk file into the project, and set Build Action to Compile, I've done that.

I do see the file listed in a file, PublishOutputs.txt, which I presume lists what gets output to the APK.

But, I unzipped the APK file and there is no file with a .mmpk in its name.

I do see a message in the log, @(Content) build action is not supported (XA0101)

Any ideas what I'm doing wrong? 

Thanks so much for any info...

0 Comments
Share
Save
 
 

 

3 Replies
mprogers
New Contributor II

Update to the above:

Now I'm more convinced (about 50% sure) that it's an ESRI problem: I can see the .mmpk file in the Assets folder on the .apk file, i.e., it is being copied (right next to Assets.txt, I made that Always Copy just to be able to check). Now Assets.txt has a path of /Assets.txt, so it follows that MahouRivieraTrails.mmpk ought to have a path of /MahouRivieraTrails.mmpk, and it does. But when I run this code:

// Define the path to the mobile map package.

string pathToMobileMapPackage = Path.Combine(Environment.CurrentDirectory, "MahouRivieraTrails.mmpk");

MobileMapPackage mahouRivieraTrails_MobileMapPackage = new MobileMapPackage(pathToMobileMapPackage);

// Load the mobile map package.
await mahouRivieraTrails_MobileMapPackage.LoadAsync();

// Show the first map in the mobile map package.
this.Map = mahouRivieraTrails_MobileMapPackage.Maps.FirstOrDefault();

it throws an exception on the LoadAsync() line, the error being:

System.IO.FileNotFoundException: File not found: /MahouRivieraTrails.mmpk

I'm desperate, and going to file a bug report, but if anybody has any suggestions (apart from give up and go back to Swift), I'd really, really like to hear from you!

0 Kudos
KevinCheriyan
Occasional Contributor

Hi @mprogers ,

You may want to check if the application can detect your file. 

Use something like this to check if the file exists:

var mmpkLocation = System.IO.Path.Combine(Environment.CurrentDirectory, @"data/MahouRivieraTrails.mmpk");
MMPKExists = File.Exists(mmpkLocation);

 

Note that in my case, the file is located within the data directory. Also, in your post, you said this:

The instructions are to just drag the mmpk file into the project, and set Build Action to Compile, I've done that.

I don't think there's a build action called "Compile". Do you mean Content? You can also check the .sln file in Visual Studio's Solution Explorer to see if the mmpk is added there. Double click on the project in Solution Explorer, and you'll see the .sln file open. Search for instances of "mmpk". You should see something like this.

<ItemGroup>
<Content Include="data\MahouRivieraTrails.mmpk" />
</ItemGroup>

 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
FabricioBezerra
New Contributor II

Are there any updates on this issue? I'm having the same problem on Android and would appreciate any help with it.

Thank you

0 Kudos