Skip to content

2. Integration

Zidd edited this page Mar 13, 2023 · 2 revisions

Step by step implementasi AndroidCore ke Project

  1. Integrasikan project dengan Firebase. Seperti menambah file google-services.json.

  2. Tambahkan repository jitpack.io di file settings.gradle.

    repositories {
        // other repositories
        maven { url 'https://jitpack.io' }
    }
  3. Tambahakan depedencies di build.gradle level module sepeti crash analystic, hilt dan lainnya.

    buildscript {
        dependencies {
            classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4'
        }
    }
    plugins {
        id 'com.android.application' version '7.3.1' apply false
        id 'com.android.library' version '7.3.1' apply false
        id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
        id 'com.google.gms.google-services' version '4.3.14' apply false
        id 'com.google.dagger.hilt.android' version '2.44' apply false
    }
  4. Selanjutnya, tambahkan plugin" yang dibutuhkan seperti kotlin-kapt, kotlin-parcelize dan lainnya di file build.gradle level app.

    plugins {
        // other plugin
        id 'kotlin-kapt'
        id 'dagger.hilt.android.plugin'
        id 'kotlin-parcelize'
        id 'com.google.firebase.crashlytics'
        id 'com.google.firebase.firebase-perf'
        id 'com.google.gms.google-services'
    }
  5. Di langkah ini kita akan membuat sebuah variable yang di generatekan oleh gradle dan variable tersebut akan di simpan di file BuildConfig. Untuk melihat file tersebut, biasanya terdapat di base directory (note: base directory yang di generate oleh gradle bukan yang tempat untuk menyimpan file) (misal: com.android.firstapp.BuildCondifg) semisal belum di generate filenya, bisa lakukan rebuild project yang bisa melalui menu Build -> Rebuild Project.

    Di file BuildConfig ini kita bisa menyiman variable" yang tidak boleh diekspos keluar atau private yang hanya developer yang tahu seperti base url api, token api, auth code dan lainnya.

    tambakan kode ini di file build.gradle level app

    defaultConfig {
        // ...
    
        // kode di bawah ini artinya
        // kita menyimpan sebuah variable dengan nama BASE_URL
        // typenya String valuenya https://baserurl.test/
        buildConfigField "String", "BASE_URL", "\"https://baserurl.test/\""
    }
  6. Selanjutnya tambah kode ini di file build.gradle level app

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            manifestPlaceholders = [usesCleartextTraffic: false, crashlyticsEnabled: true, performanceEnabled: true]
        }
        debug {
            debuggable true
            manifestPlaceholders = [usesCleartextTraffic: true, crashlyticsEnabled: false, performanceEnabled: false]
        }
    }
  7. Karena library core crocodic menggunakan DataBinding pastikan kita aktifkan fitur DataBinding di project kita melalui buildFeaturesdi file build.gradle level app.

    android {
        // ...
    
        buildFeatures {
            viewBinding true
            dataBinding true
        }
    }
  8. Di langkah ini menambahkan dependecies yang dibutuhkan ke project, ada bayak sekali library" open source ataupun yang dibuat oleh tim android sendiri, tapi disini kita hanya akan menambhakan library" yang di butuhkan saja atau library yang di intregasikan dengan library core crocodic.

    dependencies {
        // ini library core crocodic
        // untuk melihat versi yang terbaru kunjungi
        // https://github.com/crocodic-studio/AndroidCoreProject/releases
        implementation 'com.github.crocodic-studio:AndroidCoreProject:x.x.x'
    
        implementation 'com.google.dagger:hilt-android:2.38.1'
        kapt 'com.google.dagger:hilt-compiler:2.38.1'
    
        kapt 'com.github.bumptech.glide:glide:4.12.0'
        kapt 'androidx.room:room-compiler:2.3.0'
    
    }
  9. Last step and most most important, enjoy this crocodic core library🎩🎉 and keep learning🎓.

Clone this wiki locally