Difference between revisions of "Android Studio: HMS Console"

From OnnoWiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 47: Line 47:
 
Edit Projects > Android > Gradle Scripts > build.gradle
 
Edit Projects > Android > Gradle Scripts > build.gradle
  
 +
// Top-level build file where you can add configuration options common to all sub-projects/modules.
 
  buildscript {
 
  buildscript {
    repositories {
 
        google()
 
        mavenCentral()
 
        // Configure the Maven repository address for the HMS Core SDK.
 
        maven {url 'https://developer.huawei.com/repo/'}  // '''tambahkan'''
 
    }
 
 
     dependencies {
 
     dependencies {
         classpath "com.android.tools.build:gradle:7.0.4"
+
         classpath "com.android.tools.build:gradle:7.1.2"
 
   
 
   
 
         // NOTE: Do not place your application dependencies here; they belong
 
         // NOTE: Do not place your application dependencies here; they belong
 
         // in the individual module build.gradle files
 
         // 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'''
                classpath 'com.huawei.agconnect:agcp:1.6.0.300' // '''tambahkan'''
 
 
     }
 
     }
 
  }
 
  }
 
+
 +
plugins {
 +
    id 'com.android.application' version '7.1.2' apply false
 +
    id 'com.android.library' version '7.1.2' apply false
 +
}
 +
 +
task clean(type: Delete) {
 +
    delete rootProject.buildDir
 +
}
  
  
 
Edit Projects > Android > Gradle Scripts > settings.gradle
 
Edit Projects > Android > Gradle Scripts > settings.gradle
  
 +
pluginManagement {
 +
    repositories {
 +
        gradlePluginPortal()
 +
        google()
 +
        mavenCentral()
 +
        maven {url 'https://developer.huawei.com/repo/'}  // '''tambahkan'''
 +
    }
 +
}
 
  dependencyResolutionManagement {
 
  dependencyResolutionManagement {
 
     repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
 
     repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
Line 73: Line 83:
 
         google()
 
         google()
 
         mavenCentral()
 
         mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
+
         maven {url 'https://developer.huawei.com/repo/'}   // '''tambahkan'''
        // Configure the Maven repository address for the HMS Core SDK.
 
         maven {url 'https://developer.huawei.com/repo/'}
 
 
     }
 
     }
 
  }
 
  }
 
+
rootProject.name = "My Application"
 +
include ':app'
  
 
==Adding Build Dependencies==
 
==Adding Build Dependencies==
Line 86: Line 95:
 
  plugins {
 
  plugins {
 
     id 'com.android.application'
 
     id 'com.android.application'
    // Add the following configuration:
+
     id 'com.huawei.agconnect'  // '''tambahkan'''
     id 'com.huawei.agconnect'
 
 
  }
 
  }
 
   
 
   
  android{
+
  android {
  ..
+
  ...
 
  }
 
  }
 
   
 
   
  dependencies {
+
  dependencies {  
     implementation 'androidx.appcompat:appcompat:1.2.0'
+
     implementation 'androidx.appcompat:appcompat:1.4.1'
     implementation 'com.google.android.material:material:1.3.0'
+
     implementation 'com.google.android.material:material:1.5.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
+
     implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
     testImplementation 'junit:junit:4.+'
+
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+
     androidTestImplementation 'androidx.test.ext:junit:1.1.3'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    // implementation 'com.huawei.hms:hwid:{version}
+
     implementation 'com.huawei.hms:hwid:6.4.0.300'  // '''tambahkan'''
     implementation 'com.huawei.hms:hwid:6.4.0.300'
 
 
  }
 
  }
 +
 +
 +
==Sync==
 +
 +
Setelah
 +
* Restart
 +
* Sync
 +
 +
Kemungkinan akan ada notifikasi di Event Log untuk
 +
* Plugin updates: HMS Toolkit, Huawei Cloud Toolkit
 +
 +
 +
 +
==Optional Tambahkan Plugin==
  
  
Line 121: Line 142:
  
 
Detail lainnya bisa di lihat di https://developer.huawei.com/consumer/en/hms
 
Detail lainnya bisa di lihat di https://developer.huawei.com/consumer/en/hms
 
 
  
 
==Configuring Metadata==
 
==Configuring Metadata==
  
 +
Tambahkan di application code element di AndroidManifest.xml
  
 
  <application ...>
 
  <application ...>
Line 135: Line 155:
  
 
==Synchronizing the Project==
 
==Synchronizing the Project==
 +
 +
* Klik Sync
  
 
==Referensi==
 
==Referensi==
  
 
* https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/as-integration-hms-core-sdk-0000001050436235
 
* https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/as-integration-hms-core-sdk-0000001050436235
 +
 +
* [[Android Studio: HMS Managed API]]

Latest revision as of 05:33, 10 March 2022

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

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    dependencies {
        classpath "com.android.tools.build:gradle:7.1.2"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'   // tambahkan
    }
}

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


Edit Projects > Android > Gradle Scripts > settings.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}  // tambahkan
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}   // tambahkan
    }
}
rootProject.name = "My Application"
include ':app'

Adding Build Dependencies

Edit Projects > Android > Gradle Scripts > build.gradle

plugins {
    id 'com.android.application'
    id 'com.huawei.agconnect'   // tambahkan
}

android {
...
}

dependencies { 
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.huawei.hms:hwid:6.4.0.300'  // tambahkan
}


Sync

Setelah

  • Restart
  • Sync

Kemungkinan akan ada notifikasi di Event Log untuk

  • Plugin updates: HMS Toolkit, Huawei Cloud Toolkit


Optional Tambahkan Plugin

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

Tambahkan di application code element di AndroidManifest.xml

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

Synchronizing the Project

  • Klik Sync

Referensi