skip to Main Content

I have created an application using Flutter, and it runs correctly. The problem occurred when I tried to upload it to the Play Store. They asked me to update the

namespace com.example.hydraulic_employee 

and the

applicationId com.example.hydraulic_employee 

because I cannot use the word ‘example.’ I made the changes in the build.gradle and google-services.json files, but then I received this error:

Launching libmain.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...                             54.8s
√  Built buildappoutputsflutter-apkapp-debug.apk.
Installing buildappoutputsflutter-apkapp-debug.apk...           7.2s
E/AndroidRuntime(15400): FATAL EXCEPTION: main
E/AndroidRuntime(15400): Process: com.simbrainsolutions.hydraulic_employee, PID: 15400
E/AndroidRuntime(15400): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.simbrainsolutions.hydraulic_employee/com.simbrainsolutions.hydraulic_employee.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.simbrainsolutions.hydraulic_employee.MainActivity" on path: DexPathList[[zip file "/data/app/~~sq5QywKCAXbNrdsSe4bbbw==/com.simbrainsolutions.hydraulic_employee-XUEIJt1wNJ6QQDBmEYwMxQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~sq5QywKCAXbNrdsSe4bbbw==/com.simbrainsolutions.hydraulic_employee-XUEIJt1wNJ6QQDBmEYwMxQ==/lib/x86_64, /data/app/~~sq5QywKCAXbNrdsSe4bbbw==/com.simbrainsolutions.hydraulic_employee-XUEIJt1wNJ6QQDBmEYwMxQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
E/AndroidRuntime(15400):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3551)
E/AndroidRuntime(15400):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3782)
E/AndroidRuntime(15400):        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
E/AndroidRuntime(15400):        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(15400):        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(15400):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
E/AndroidRuntime(15400):        at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(15400):        at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(15400):        at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(15400):        at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(15400):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15400):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(15400):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime(15400): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.simbrainsolutions.hydraulic_employee.MainActivity" on path: DexPathList[[zip file "/data/app/~~sq5QywKCAXbNrdsSe4bbbw==/com.simbrainsolutions.hydraulic_employee-XUEIJt1wNJ6QQDBmEYwMxQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~sq5QywKCAXbNrdsSe4bbbw==/com.simbrainsolutions.hydraulic_employee-XUEIJt1wNJ6QQDBmEYwMxQ==/lib/x86_64, /data/app/~~sq5QywKCAXbNrdsSe4bbbw==/com.simbrainsolutions.hydraulic_employee-XUEIJt1wNJ6QQDBmEYwMxQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]      
E/AndroidRuntime(15400):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
E/AndroidRuntime(15400):        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime(15400):        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime(15400):        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
E/AndroidRuntime(15400):        at androidx.core.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:45)
E/AndroidRuntime(15400):        at android.app.Instrumentation.newActivity(Instrumentation.java:1339)
E/AndroidRuntime(15400):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3538)
E/AndroidRuntime(15400):        ... 12 more

I updated the word example by simbrainsolutions.

this is the build.gradle file:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id 'com.google.gms.google-services'
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace "com.simbrainsolutions.hydraulic_employee"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {

        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.simbrainsolutions.hydraulic_employee"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true

    }

    // buildTypes {
    //     release {
    //         // TODO: Add your own signing config for the release build.
    //         // Signing with the debug keys for now, so `flutter run --release` works.
    //         signingConfig signingConfigs.debug
    //     }
    // }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release
       }
   }

}

flutter {
    source '../..'
}

dependencies {
    implementation "androidx.multidex:multidex:2.0.1"

    implementation platform('com.google.firebase:firebase-bom:30.2.0')

    implementation 'com.google.firebase:firebase-analytics'

}

and this is the google-services.json:

{
  "project_info": {
    "project_number": "xxx",
    "project_id": "hydraulic-748ae",
    "storage_bucket": "hydraulic-748ae.appspot.com"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:111178692999:android:3dc290cdf5ee57775c0e02",
        "android_client_info": {
          "package_name": "com.simbrainsolutions.hydraulic_employee"
        }
      },
      "oauth_client": [],
      "api_key": [
        {
          "current_key": "xxx"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": []
        }
      }
    }
  ],
  "configuration_version": "1"
}

this is the AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <application
        android:label="HE SARL"
        android:name="${applicationName}"
        android:networkSecurityConfig="@xml/network_security_config"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher"
        android:enableOnBackInvokedCallback="true">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <provider
            android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
            android:authorities="${applicationId}.flutter_downloader.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"

                android:resource="@xml/provider_paths"/>
        </provider>
<!--        <provider-->
<!--            android:name="androidx.startup.InitializationProvider"-->
<!--            android:authorities="${applicationId}.androidx-startup"-->
<!--            android:exported="false"-->
<!--            tools:node="merge">-->
<!--            <meta-data-->
<!--                android:name="androidx.work.WorkManagerInitializer"-->
<!--                android:value="androidx.startup"-->
<!--                tools:node="remove" />-->
<!--        </provider>-->

<!--        <provider-->
<!--            android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer"-->
<!--            android:authorities="${applicationId}.flutter-downloader-init"-->
<!--            android:exported="false">-->
<!--            &lt;!&ndash; changes this number to configure the maximum number of concurrent tasks &ndash;&gt;-->
<!--            <meta-data-->
<!--                android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS"--><!--                android:value="5" />--><!--</provider>-->
</application></manifest>

how can I fix the error ?
I am new to this kind of work ‘hosting’

I tried searching extensively on Google and Stack Overflow, but I couldn’t find the answer.

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution. I should find the MainActivity.kt and change the package name in it to be like this:

    package com.simbrainsolutions.hydraulic_employee
    
    import io.flutter.embedding.android.FlutterActivity
    
    class MainActivity: FlutterActivity() {
    }
    

  2. Hi Package name in you google-services json file needs to be update change this

    "package_name": "com.simbrainsolutions.hydraulic_employee"
    

    to new package name.

    I will suggest change package name on firebase console or create an new app and then download google-services.json file again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search