Android Studio: HMS Console

From OnnoWiki
Jump to navigation Jump to search

HMS Console penting untuk mengaktifkan HMS Kit. URL di,


Langkah membuat Aplikasi Menggunakan HMS Kit


  • Login Huawei Developer > Console
  • Klik "Distribution and promotion" di atas AppGallery Connect
  • Klik "AppGallery Connect"
  • Klik "My Projects"
  • Klik "Add project"
  • New project > Name : nama-project-yang-kita-buat (misal ITTS HMS Kit Test) > OK
  • Klik "Add app"
  • Isi:
Platform:         Android
Device:           Mobile Phone
App name:         ITTS HMS Kit Test
Package name:     nama.app.anda (contoh itts.onno.hms.kit.test)
App category:     App
Default language: Indonesian
  • Klik OK
  • Lakukan hal yang sama PERSIS di Android Studio, pastikan sama di
App name
Package name

Setup SDK

Download agconnect-services.json

a) Downloaded the agconnect-services.json file.
b) Switch Android Studio to the Project view.
c) Copy the agconnect-services.json file to the app root directory.
  • Copy ke folder src (via File Explorer di OS Ubuntu)
~/AndroidStudioProjects/ITTSHMSKitTest/app/src/


Setup gradle

Edit Projects > Android > Gradle Scripts > build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}  // tambahkan
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        // Add the AppGallery Connect plugin configuration. You are advised to use the latest plugin  version.
                classpath 'com.huawei.agconnect:agcp:1.6.0.300' // tambahkan
    }
}


Edit Projects > Android > Gradle Scripts > settings.gradle

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}
    }
}


Adding Build Dependencies

Edit Projects > Android > Gradle Scripts > build.gradle

plugins {
    id 'com.android.application'
    // Add the following configuration:
    id 'com.huawei.agconnect'
}

android{
..
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    // implementation 'com.huawei.hms:hwid:{version}
    implementation 'com.huawei.hms:hwid:6.4.0.300'
}


Selain agconnect-core, kita perlu menambahkan implementation untuk HMS kit yang kita gunakan seperti daftar berikut,

Service               Configuration
Auth Service          implementation 'com.huawei.agconnect:agconnect-auth:1.6.4.300'
Remote Configuration  implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.6.4.300'
Cloud Functions       implementation 'com.huawei.agconnect:agconnect-function:1.6.4.300'
Cloud DB              implementation 'com.huawei.agconnect:agconnect-cloud-database:1.5.0.300'
App Linking           implementation 'com.huawei.agconnect:agconnect-applinking:1.6.4.300'
Crash                 implementation 'com.huawei.agconnect:agconnect-crash:1.6.4.300'
APM                   implementation 'com.huawei.agconnect:agconnect-apms:1.5.2.309'
Cloud Storage         implementation "com.huawei.agconnect:agconnect-storage:1.4.0.100"
App Messaging         implementation 'com.huawei.agconnect:agconnect-appmessaging:1.6.4.300'

Detail lainnya bisa di lihat di https://developer.huawei.com/consumer/en/hms


Configuring Metadata

<application ...>
    <meta-data     
        android:name="com.huawei.hms.client.channel.androidMarket"  
        android:value="false" />
    ...
</application>

Synchronizing the Project

Referensi