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

84
4
Jump to solution
Thursday
LiuYuhang
New Contributor II

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
New Contributor II

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

原因暂不清楚

View solution in original post

0 Kudos
4 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
New Contributor II

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

0 Kudos
LiuYuhang
New Contributor II

再次尝试后,依旧不行

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
New Contributor II

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

原因暂不清楚

0 Kudos