-1

My app work fine when i build with mono for Android. But when i build with il2cpp, my app work fine too but when i want create a KML file i have a exception: "object reference not set to an instance or a object". Certainly because root must be null.

KmlFile kml = KmlFile.Create(root, false); 
            using (FileStream stream = File.OpenWrite(path))
            {
                kml.Save(stream);
            }

I don't understand why it work with mono but not with il2cpp. il2cpp doesn't include sharpkml in binary app ?

Cyrille Mouret
  • 75
  • 1
  • 1
  • 5
  • Can you provide a bit more context? Where should the root variable come from? – Josh Peterson Jan 16 '20 at 13:06
  • Hi. root come from [SharpKml](http://www.nudoq.org/#!/Packages/SharpKml.Core/SharpKml/Document). root represents a container for KML features, shared styles. I found [here](https://issuetracker.unity3d.com/issues/il2cpp-notsupportedexceptions-exception-is-thrown-in-build-with-newtonsoft-dot-json-plugin) – Cyrille Mouret Jan 16 '20 at 18:22
  • a solution. Now, after create a link.xml for assembly "System.Core", i can write kml file on android device but without data , and i have a new exception `The type initializer for SharpKml.Base.KmlFactory threw an exception at SharpKml.Base.Serailizer.WriteStartTag`. – Cyrille Mouret Jan 16 '20 at 18:38
  • I don't know much about SharpKml, sorry. It seems like the error maybe coming from there. You may want to preserve the entire SharpKml assembly via the link.xml file. It may not work well with managed code stripping. – Josh Peterson Jan 17 '20 at 15:11
  • Thank you Josh for your answer. You'r right, the problem come from SharpKml and the link file. I tested to include SharpKml with this link ` ` without result. – Cyrille Mouret Jan 17 '20 at 16:06

1 Answers1

0

I found. I simply add <assembly fullname="SharpKml.Core" preserve="all"/> and not <assembly fullname="SharpKml" preserve="all"/> and the app work fine.

Cyrille Mouret
  • 75
  • 1
  • 1
  • 5