Mengganti Nama Package (Paket) Android di Flutter

Jika anda ingin mengganti nama package android pada flutter dapat dilakukan dengan mudah, melalui beberapa tahapan berikut :

  • Ubah pada file AndroidManifest.xml :

<span class="pun">&lt;</span><span class="pln">manifest xmlns</span><span class="pun">:</span><span class="pln">android</span><span class="pun">=</span><span class="str">"http://schemas.android.com/apk/res/android"</span><span class="pln">
    package</span><span class="pun">=</span><span class="str">"your.package.name"</span><span class="pun">&gt;</span>

  • Ubah pada file build.gradle :
  • 
    
    <span class="pln">defaultConfig </span><span class="pun">{</span><span class="pln">
        applicationId </span><span class="str">"your.package.name"</span><span class="pln">
        minSdkVersion </span><span class="lit">16</span><span class="pln">
        targetSdkVersion </span><span class="lit">27</span><span class="pln">
        versionCode </span><span class="lit">1</span><span class="pln">
        versionName </span><span class="str">"1.0"</span><span class="pln">
        testInstrumentationRunner </span><span class="str">"android.support.test.runner.AndroidJUnitRunner"</span>
    <span class="pun">}</span>
  • Ubah pada file MainActivity.java :
  • 
    
    <span class="pln">package your</span><span class="pun">.</span><span class="pln">package</span><span class="pun">.</span><span class="pln">name</span><span class="pun">;</span>

        <span class="kwd">import</span><span class="pln"> android</span><span class="pun">.</span><span class="pln">os</span><span class="pun">.</span><span class="typ">Bundle</span><span class="pun">;</span>
        <span class="kwd">import</span><span class="pln"> io</span><span class="pun">.</span><span class="pln">flutter</span><span class="pun">.</span><span class="pln">app</span><span class="pun">.</span><span class="typ">FlutterActivity</span><span class="pun">;</span>
        <span class="kwd">import</span><span class="pln"> io</span><span class="pun">.</span><span class="pln">flutter</span><span class="pun">.</span><span class="pln">plugins</span><span class="pun">.</span><span class="typ">GeneratedPluginRegistrant</span><span class="pun">;</span><span class="pln">
        public </span><span class="kwd">class</span> <span class="typ">MainActivity</span> <span class="kwd">extends</span> <span class="typ">FlutterActivity</span> <span class="pun">{</span>
  • Lalu ubah struktur direktori project android sesuai dengan nama package yang baru :
  • From:
    
    
    <span class="pln">  android\app\src\main\java\com\example\name</span>

    To:

    
    
    <span class="pln">  android\app\src\main\java\your\package\name</span>

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *