Skip to content

AppIcon.change('icon_name') returns -1 #26

@ghonche

Description

@ghonche

Describe the bug

I'm using @capacitor-community/app-icon version 3.1.0-beta.0 in my android project.
Following code returns -1 as response:

AppIcon.change({name: 'ic_launcher2', suppressNotification: true}).then(response =>{
console.log(response);
});

And app icon doesn't change.

I added activity and activity-alias to AndroidManifest.xml like this:

  <activity
        android:exported="true"
        android:name="pro.lifa.app.MainActivity"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
        android:hardwareAccelerated="true"
        android:label="@string/title_activity_main"
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBarLaunch"
        android:supportsPictureInPicture="true"
        android:windowSoftInputMode="adjustResize"
         tools:targetApi="n">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>

            <data android:host="web.lifa.pro"
                  android:scheme="https"/>

            <data android:host="web.lifa.pro"
                  android:scheme="http"/>
        </intent-filter>
    </activity>



    <activity-alias
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:name=".ic_launcher"
        android:enabled="true"
        android:exported="true"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>




    <activity-alias
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher2"
        android:roundIcon="@mipmap/ic_launcher2_round"
        android:name=".ic_launcher2"
        android:enabled="false"
        android:exported="true"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>

Expected behavior
AppIcon.change('icon_name') must change the app icon.

Screenshots
Console log:
Screenshot 2023-01-16 at 12 08 29 PM

Smartphone

  • Device: Pixel 6 Emulator
  • OS: android API 31

Additional context

  • minSdkVersion = 22
  • compileSdkVersion = 32
  • targetSdkVersion = 32

Any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions