Search code examples
androidhuawei-mobile-serviceshuawei-developers

Getting error while using Huawei ImageKit doInit() method


I am trying to use ImageKit in my android project.

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

whenever I call doInit method like the code above, it always throws the error code 35 which is translated to ERROR_DOINIT according to the documentation.

My XML file is below :

<?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>

About the parameters of the authJson, I follow exactly what I got from my app/agconnect-services.json for appId, authApiKey, clientSecret & clientId, except the project id which I'm not sure what value to put in, I've tried using cp_id and the product_id in agconnect-services.json as the projectId, also giving same error. And I don't use any token here, since the documentation Image Kit Documentation says the token is optional. I could not figure it out which part is wrong any help is appreciated.


Solution

  • Did you Initialize the Image Render Service?

    When initializing the service, your app needs to pass the sourcePath (path of the resources to be parsed) and authentication information (for example, APIKey and certificate fingerprint, in JSON format). Your app can use the service only after it is successfully authenticated.

    You are getting error code 35 which is described as : Initialization error in the official documentation. And official solution for the problem is:

    Check whether the entered resource path is correct.

    For list of the Image Kit related errors and what they mean, here is the documentation: Documentation