Change application name on android platform

i use capacitor in my ionic/vuejs application.
i only want to change the name of the generated android app.
i have changed in capacitor.config.ts but itdoes not work!

i’m new to capacitor, can you please give me a hand ?

4 Likes

These are the other places:

  • applicationId in android/app/build.gradle
  • android/app/src/main/res/values/strings.xml

If you want to update the package name to match, then you need to update the following items. For the example our new package is com.awesome.app

android/app/src/main/AndroidManifest.xml

  • manifest -> package
  • manifest -> application -> activity -> android:name
<?xml version='1.0' encoding='utf-8'?>
<manifest package="com.awesome.app" xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="com.awesome.app.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- Other Stuff -->
    </application>
</manifest>

android/app/src/main/java/com/awesome/app/MainActivity.java

Notice you also have to update the path. Before it was android/app/src/main/java/io/ionic/starter/MainActivity.java

package com.awesome.app;

Reference

5 Likes

thanks alot. it relly helps

1 Like

I made the following steps

  1. rm android
  2. rm www
  3. Change capacitor.config.ts to
const config: CapacitorConfig = {
  appId: 'yourappid',
  appName: 'yourappname
  webDir: 'www',
  bundledWebRuntime: false
};
  1. ionic capacitor build android
  2. ionic capacitor sync

It works for me

4 Likes