GaiaX SDK Integration Guide

Oct 8, 2024 | Programming

GaiaX-logo

README-en
README-zh
Docs-zh
GitHub release
GitHub Stars
GitHub Forks
user repos
GitHub Contributors
![License](https://img.shields.io/github/license/alibaba/GaiaX)

Introduction

Welcome to the integration guide for the GaiaX SDK! This guide will walk you through the steps to incorporate this powerful tool into your Android, iOS, and Harmony projects seamlessly.

Getting Started

This section outlines how to set up the GaiaX SDK for various platforms.

For Android


1. In your settings.gradle:
   pluginManagement {
       repositories {
           gradlePluginPortal()
           google()
           maven { url 'https://jitpack.io' }
           mavenCentral()
       }
   }
   dependencyResolutionManagement {
       repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
       repositories {
           google()
           maven { url 'https://jitpack.io' }
           mavenCentral()
       }
   }

2. In your build.gradle (allprojects):
   repositories {
       maven { url 'https://jitpack.io' }
   }
   implementation 'com.github.alibaba.GaiaX:GaiaX-Adapter:$version'
   implementation 'com.github.alibaba.GaiaX:GaiaX:$version'
   implementation 'com.alibaba:fastjson:1.2.76'

For iOS


1. Add this to your Podfile:
   pod 'GaiaXiOS'

2. Usage in your .m file:
   #import 
   [GXRegisterCenter registerTemplateServiceWithBizId:bizId templateBundle:@xxx.bundle];

For Harmony


1. In your project’s oh-package.json, add:
   {
       "dependencies": {
           "GaiaxHarmony": "latest"
       }
   }

2. Usage example:
   import GXTemplateItem from 'GaiaxHarmony/src/main/ets/context/GXTemplateItem';
   import GXTemplateData from 'GaiaxHarmony/src/main/ets/context/GXTemplateData';

Utilizing the SDK

After setting up the SDK, the following examples explain how to use it:

Android Example:


val item = GXTemplateEngine.GXTemplateItem(activity, templateBiz, templateId)
val size = GXTemplateEngine.GXMeasureSize(100F.dpToPx(), null)
val dataJson = AssetsUtils.parseAssets(activity, template-data.json)
val data = GXTemplateEngine.GXTemplateData(dataJson)
val view = GXTemplateEngine.instance.createView(item, size)
GXTemplateEngine.instance.bindData(view, data)
findViewById(R.id.template_container).addView(view, 0)

Understanding the Code

Imagine you are a chef preparing a gourmet dish. First, you gather all your ingredients (data and assets), making sure they are in the right sizes (GXMeasureSize). Next, you prepare your cooking space (createView), binding the ingredients (bindData) together before presenting your dish (addView) to your guests who are eagerly waiting to take a look (your app users).

Troubleshooting

  • If you encounter issues during your setup, ensure that all repository links are correct and up to date.
  • Check your dependency versions to confirm compatibility across the SDK and your current libraries.
  • For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

By following this guide, you should now have a solid foundation for integrating the GaiaX SDK into your applications. Let your creativity flow and leverage the full potential of dynamic template development!

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox