I moved to 100.7.
This no longer works.
vtlayer = new ArcGISVectorTiledLayer(vectorTileCache, itemResourceCache);
Same exact files as before the move to 100.7.
Same exact code.
Symptoms: nothing from this vtpk shows.
No error messages that I can tell.
It just never shows.
There is nothing in the release notes that you changed anything here.
What's going on?
Nathan,
We are looking into this and will respond shortly.
My first thoughts are if you have changed the API level of you app?
Target API level is still 28
I did have to migrate to Androidx because that was necessary in moving from 100.6 to 100.7.
Attached is the ItemResourceCache, zipped up.
I was able to intercept a loading error "Unable to find resources.zip"
Here is where I initialize the ItemResourceCache
ItemResourceCache itemResourceCache = new ItemResourceCache(stylespath + "day");
According to source code records, this code has been used to load the ItemResourceCache for 18 months.
It did not change this week when we released with 100.7/
If I change it to
ItemResourceCache itemResourceCache = new ItemResourceCache(stylespath + "day/bcosm");
It is loading.
Since resources.zip IS in day/bcosm, this actually seems more correct.
HOWEVER, see the above. It seems that previously you were expecting resources.zip to be one level deeper.
Did something like that change?
I will note that I have NEVER seen any documentation on how I am supposed to create an ItemResourceCache.
Has that changed?
See this topic from two years ago:
This was never answered and I had to learn mostly from trial and error.
Nathan,
I've written a couple of applications today which are displaying VTPK files without any issues I can see.
Without looking at your code it is hard for me to see what is happening, but I have a few thoughts:
- If you have changed your API level to 23+ then there are changes in Android where you need to do some extra things to get permission to read files. Prior to 23 you could just get away with adding the permission in the manifest. You now need to explicitly request this and a dialog will pop up in your app.
- You say it fails silently, but are you doing anything to capture error conditions? In the done loading listener you can look at the load status. This is what I've crudely added to my listener on the tileCache:
tileCache = new VectorTileCache(Environment.getExternalStorageDirectory() + "/ArcGIS/Samples/TilePackage/vectorTilePackage.vtpk"); tileCache.loadAsync(); tileCache.addDoneLoadingListener(()-> { Log.e("mb:" , "load status " + tileCache.getLoadStatus()); Log.e("mb:" , "load error " + tileCache.getLoadError());
- The other thought I'm having is around garbage collection. Are you using member variables in your code where you are reading values in a separate thread to where you called loadAsync?
To show you what I mean here is some vulnerable code:
// create feature layer with its service feature table
// create the service feature table
ServiceFeatureTable serviceFeatureTable = new ServiceFeatureTable(
getResources().getString(R.string.sample_service_url));
// create the feature layer using the service feature table
FeatureLayer featureLayer = new FeatureLayer(serviceFeatureTable);
// trigger the layer to load
featureLayer.loadAsync();
// this code gets run on a new thread when the feature is loaded.
featureLayer.addDoneLoadingListener(() -> {
String desc = featureLayer.getDescription();
Toast.makeText(this, "Description: " + desc, Toast.LENGTH_SHORT).show();
});
serviceFeatureTable is a variable which will eventually get garbage collected once it goes out of scope. There is always a possibility if you are unlucky it will get garbage collected before the doneLoadingListener gets fired... it therefore looks like it has silently failed! If serviceFeatureTable is a member of the class this will not happen.
Note sure if any of this helps, but something to be thinking about.
Note that we are always happy to help, but please keep the conversation polite 😉
Nathan
We replied at exactly the same time. I've noted you point about the ItemTileResource directory. I will need to ask someone on the offline data team about this.
Nathan,
We investigated this more and I can't explain why this has changed in your app. I've spent some time with the offline data team and we've looked at any code changes in this area between 100.6 and 100.7 and there were none which could cause this.
In addition I've been testing with your data. For 100.6 and 100.7 the ItemResourceCache is failing to load when you reference the "day" directory. For 100.6 and 100.7 is works if you reference the "day/bcosm" directory.
I can't reproduce the situation you are reporting, however having the code so that it references "/day/bcosm" is correct.
I've also looked into your feedback about documentation. I'm not a vector tile cache expert, but I can tell you there are 2 ways of generating the ItemResouceCache. You can request it via the API from the server, or I believe you can also create them from ArcGIS Pro.
The following page (scroll right down to the bottom) explains how to achieve this with the API:
Take a layer offline—ArcGIS Runtime SDK for Android | ArcGIS for Developers
Having the same situation as yours, I've never seen any document about how to creat an ItemResourceCache. Could you tell me how to create day.zip? I couldn't find any document whose structure is relevant to item.json in VTPK, and could you tell me how to acquire it? Looking forward to your reply.
@Anonymous User
The day.zip file is attached to a post made by the original poster.
This is a fairly old post so its probably best if you create a new thread describing what you are trying to achieve giving details of your code and the version of the API you are using.