No Data exception opening runtime geodatabase

950
4
08-29-2018 08:07 PM
BrianMarchionni1
New Contributor II

I'm writing a Xamarin.Forms application targeting iOS/Android/UWP. Runtime 100.3, I also tried 100.2.1

I'm attempting to side load a runtime geodatabase .geodatabase that I created in ArcGIS 10.3.1 for Desktop by adding a few layers to a .mxd and then clicking File->Share As->ArcGIS Runtime Content...

I then copied the output .geodatabase file into the path of my application and load it with this code:

if (System.IO.File.Exists(System.IO.Path.Combine(Storage.PublicFolderPath, "db.geodatabase")))
{
    Geodatabase gdb = await Geodatabase.OpenAsync(System.IO.Path.Combine(Storage.PublicFolderPath, "db.geodatabase"));

    foreach (GeodatabaseFeatureTable ft in gdb.GeodatabaseFeatureTables.Reverse())
    {
        FeatureLayer fl = new FeatureLayer(ft);
        _map.OperationalLayers.Add(fl);
    }
}

It works fine on iOS/UWP but on Android I get an unhandled exception trying to execute:

Geodatabase.OpenAsync(...)

Unhandled Exception:

Esri.ArcGISRuntime.ArcGISRuntimeException: No data occurred

And thats all the info I get. I've tried a few different android devices and emulators and it always throws the same error. I tried modifying my database to remove some layers / tables but that didn't help. I'd think it was a data issue but it works find on iOS/UWP.

Thanks for your help,

Brian

4 Replies
KevinHoman
New Contributor

I received this error when Norton data protector blocked attempt to lock file

0 Kudos
dotMorten_esri
Esri Frequent Contributor

Since this is Android only, are you sure that file is in that path you provided? What does File.Exists(...) return?
Does your app allow you to read from that location? (Try File.Open(...)).

How did you get the file onto the Android device? (Note that Android doesn't support the convenient 'Content' build action that iOS and UWP does)

This resource might also be helpful: File access on external storage with Xamarin.Android - Xamarin | Microsoft Docs 

(and yes the error could be better - we're working on that)

0 Kudos
ClémentLaskar
New Contributor III

Hi,

I also get this error. I'm trying to open a gdb but I'm on android only with Kotlin. When I call Geodatabase(fakepath), and then run geodatabase.loadAsync(), I get a "File not found" exception. When I call Geodatabase(goodpath), and then run geodatabase.loadAsync() I get a "No data" exception. So it means my app can access the file. I tried generating the geodatabase with ArcGIS Pro and directly on AGS Server but it's the same issue. The gdb is opened without issue on AGS Pro.

My code :

val geodatabase = Geodatabase(context.getString(R.string.offline_gdb_path))
logDescription(geodatabase.path)
logDescription("${geodatabase.geodatabaseFeatureTables}")
geodatabase.loadAsync()
logDescription("startLoadAsync")
geodatabase.addLoadStatusChangedListener {
    logDescription(geodatabase.loadStatus.toString())
    logDescription(geodatabase.loadError.message)
    logDescription(geodatabase.loadError.additionalMessage)
}
geodatabase.addDoneLoadingListener {
    if (geodatabase.loadStatus == LoadStatus.LOADED) {
        logDescription("Loaded")
        //make a featurelayer from each feature table
        for (featureTable in geodatabase.geodatabaseFeatureTables) {
            val featureLayer = FeatureLayer(featureTable)
            mapView.map.operationalLayers.add(featureLayer)
        }
    }
}

When I open the gdb with AGS Pro, there are datas in the layers.

0 Kudos
ClémentLaskar
New Contributor III

Oh well I found it, I had the wrong type of geodatabase. I found Supported geodatabase formats—ArcGIS Runtime SDK for Android | ArcGIS for Developers and in fact I tried with the .gdb file which was the wrong one. I tried with a .geodatabase file and it's ok ! I don't know well the Esri solutions but it's a bit misleading to understand that geodatabase can mean 4 different things that are not treated the same way by all the solutions. Furthermore the "No data" message is not explicit at all...

0 Kudos