使用 Huawei ImageKit doInit() 方法时出错

Getting error while using Huawei ImageKit doInit() method

我正在尝试在我的 android 项目中使用 ImageKit。

val res = imageRenderAPI.doInit(sourcePath, getAuthJson())

每当我像上面的代码一样调用 doInit 方法时,它总是抛出错误代码 35 ,它被转换为 ERROR_DOINIT 根据文档。

我的 XML 文件如下:

<?xml version="1.0" encoding="utf-8"?>
<Root screenWidth="1080">
  <Image x="1080" y="1920" src="background.png"></Image> 
  <Image w="481" h="432"  x="481" y="120" pivotX="500" pivotY="80" rotationX="50" rotationY="50" src="human.png" > 
    <PositionAnimation> 
        <Position x="0" y="0" time="0"/> 
        <Position x="500" y="0" time="1000"/> 
    </PositionAnimation>    
    <RotationAnimation >       
        <Rotation angle="0" time="0"/>        
        <Rotation angle="360" time="6000"/>     
    </RotationAnimation>
</Image>
</Root>

关于 authJson 的参数,除了我不确定的项目 ID要输入什么值,我尝试使用 cp_id 和 agconnect-services.json 中的 product_id 作为 projectId,也给出了同样的错误。我在这里不使用任何令牌,因为文档 Image Kit Documentation 说令牌是可选的。我无法弄清楚哪部分是错误的任何帮助表示赞赏。

您是否初始化图像渲染服务?

您的应用在初始化服务时,需要传递sourcePath(待解析资源的路径)和认证信息(例如APIKey和证书指纹,格式为JSON)。您的应用需要认证成功后才能使用该服务。

您收到错误代码 35,在官方文档中描述为:初始化错误。该问题的官方解决方案是:

Check whether the entered resource path is correct.

有关 Image Kit 相关错误的列表及其含义,请参阅文档:Documentation