Select to view content in your preferred language

The local TPKX file and SLPK file cannot be loaded in apk

1112
5
Jump to solution
09-22-2022 08:25 PM
LiuYuhang
Emerging Contributor

Unity Version:2021.3.6f1

local file path: Internal storage in the root directory / GIS

local file format: tpkx and slpk

tpkx: use for basemap, basemap layer type has set imagelayer

slpk: use for 3DObjectSceneLayer

In Unity editor mode, everything works fine, but when packaged as APK, no errors are reported and the model and base map are not loaded. 

Can you tell me exactly what is not done well? thank you

code:

LiuYuhang_0-1663903210189.png

Unity Editor:

LiuYuhang_1-1663902548449.png

LiuYuhang_3-1663902652820.png

player setting:

LiuYuhang_4-1663902726902.png

LiuYuhang_6-1663902799260.png

 

 

0 Kudos
1 Solution

Accepted Solutions
LiuYuhang
Emerging Contributor

手动在android/data/com.xxx.xxx/file下创建文件夹,并将tpk文件和slpk文件放入后,使用Application.persistentDataPath路径后,加载成功。

原因暂不清楚

View solution in original post

5 Replies
WilburYoung
New Contributor

直接在arcgismapcomponent.layer图层添加slpk文件相对路径就可以了

private void CreatGSLine()
{
// Create ArcGIS layers and add them to the map
var layer_1 = new ArcGISLayerInstanceData();
layer_1.Name = "MyLayer_gs";
layer_1.Type = LayerTypes.ArcGISImageLayer;
layer_1.Source = Application.streamingAssetsPath + "/你的数据文件.tpk";
layer_1.Opacity = 1.0f;
layer_1.IsVisible = true;
//layer_1.Authentication = ;
arcgismapcomponent.Layers.Add(layer_1);
}

0 Kudos
LiuYuhang
Emerging Contributor

目标平台为安卓,谢谢,不过我也会试下直接在Inspector里面把文件路径填写上去。

0 Kudos
LiuYuhang
Emerging Contributor

再次尝试后,依旧不行

void Start()
{
ArcGISMapComponent arcGISMapComponent = FindObjectOfType<ArcGISMapComponent>();

//arcGISMapComponent.Basemap = "file:///storage/emulated/0/GIS/sh_gaode.tpkx";
//arcGISMapComponent.Basemap = "file:///storage/emulated/1/GIS/sh_gaode.tpkx";
arcGISMapComponent.Basemap = "jar:file://" + Application.dataPath + "!/assets/sh_gaode.tpkx";
arcGISMapComponent.BasemapType = BasemapTypes.ImageLayer;

ArcGISLayerInstanceData buildingLayer = new ArcGISLayerInstanceData();
buildingLayer.Name = "Building";
//buildingLayer.Source = "file:///storage/emulated/0/GIS/sh_part.slpk";
//buildingLayer.Source = "file:///storage/emulated/1/GIS/sh_part.slpk";
buildingLayer.Source = "jar:file://" + Application.dataPath + "!/assets/sh_part.slpk";
buildingLayer.Type = LayerTypes.ArcGIS3DObjectSceneLayer;
buildingLayer.Opacity = 1.0f;
buildingLayer.IsVisible = true;

arcGISMapComponent.Layers.Add(buildingLayer);
}

0 Kudos
LiuYuhang
Emerging Contributor

手动在android/data/com.xxx.xxx/file下创建文件夹,并将tpk文件和slpk文件放入后,使用Application.persistentDataPath路径后,加载成功。

原因暂不清楚

FrantišekMužík
Occasional Contributor

Thanks for your post! I was struggling with this issue as well. So there is apparently no way to open tpkx files on mobile device other than manually placing them on the internal storage? It must work somehow 😅. Does anyone tried to implement this solution to work properly on any device? Meaning that tpkx files would install together with the application from Google Play or from apk. I was thinking of storing the tpkx files somewhere in the Assets folder and find them using UnityWebRequest on Android platform.

0 Kudos