skb1129 / react-native-change-icon

Change your application icon programmatically for React Native apps
MIT License
500 stars 92 forks source link

[Error: ICON_INVALID] #74

Open Ammarlio opened 2 years ago

Ammarlio commented 2 years ago

Platform

Description After Integrating and follow the same steps for Android, i am getting [Error: ICON_INVALID]. I did all the steps as the docs and all icons are valid. Anyway on IOS it works fine. Even if i am setting enable property to true in activity-alias for default icon, i am getting the same error.

To Reproduce Steps to reproduce the behavior:

  1. invoke changeIcon('blueicon');
  2. getting the error message [Error: ICON_INVALID]

Screenshots [Error: ICON_INVALID]

Device (please complete the following information):

Versions

Code Snippet <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.testdemo">

<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />

<application
    android:name=".MainApplication"
    android:allowBackup="false"
    android:icon="@mipmap/defaulticon"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/defaulticon_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <receiver
        android:name=".widgets.summaryWidget.summaryWidget"
        android:exported="true">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>

        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/summary_widget_info" />
    </receiver>
    <receiver
        android:name=".widgets.performanceWidget.PerformanceWidget"
        android:exported="true">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>

        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/testdemo_widget_info" />
    </receiver>

    <activity
        android:name=".widgets.performanceWidget.WidgetActivity"
        android:exported="false">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:exported="true"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustPan">
    </activity>

    <activity-alias
        android:name="com.testdemo.MainActivitydefaulticon"
        android:enabled="false"
        android:exported="true"
        android:icon="@mipmap/defaulticon"
        android:roundIcon="@mipmap/defaulticon_round"
        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:name="com.testdemo.MainActivityblueicon"
        android:enabled="false"
        android:exported="true"
        android:icon="@mipmap/blueicon"
        android:roundIcon="@mipmap/blueicon_round"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>
</application>

skb1129 commented 1 year ago

@Ammarlio please use v5 and try using the updated docs for the setup

mayyas-nakhli commented 1 year ago

@Ammarlio I was facing the same issue, the solution was to pass package name into the ChangeIconPackage constructor in MainApplication.java file

 @Override
    protected List<ReactPackage> getPackages() {
      List<ReactPackage> result = new ArrayList<ReactPackage>();

      result.addAll(Arrays.<ReactPackage>asList(
      ...
         new ChangeIconPackage("com.your.package")
         ));
     }

P.S: In my project library linking in both iOS and Android is manual.

MandaliyaPruthvi commented 1 year ago

Hello @skb1129

I tried using your package and getting the same error on the PROD. When I tried to display system generated error to get more detail about the error, I got below error: " java.lang.SecurityException: Attempt to change component state; pid=5326, uid=10523, component=ComponentInfo{com.package-name/{com.package-name.MainActivityExpressShipColor} "

@mayyas-nakhli I've tried your solution as well but that's also not working.

@skb1129 Also updated to V5 and got this error.

vimosan7 commented 1 year ago

Make sure your applicationId is correct in android/app/build.gradle. This mismatch can cause problems.

defaultConfig {
    applicationId "com.yourapplicationid"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    signingConfig signingConfigs.debug
    vectorDrawables.useSupportLibrary = true
}
MandaliyaPruthvi commented 1 year ago

Thanks for your response I'll have a look into it and get back to you if it helps or not.

On Mon, 2 Oct 2023, 8:07 pm vimosan7, @.***> wrote:

Make sure your applicationId is correct in android/app/build.gradle. This mismatch can cause problems.

defaultConfig { applicationId "com.yourapplicationid" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" signingConfig signingConfigs.debug vectorDrawables.useSupportLibrary = true }

— Reply to this email directly, view it on GitHub https://github.com/skb1129/react-native-change-icon/issues/74#issuecomment-1743141234, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE7ZQYKGEW2RZRGU35EE23DX5LGQZAVCNFSM6AAAAAARO6TK3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBTGE2DCMRTGQ . You are receiving this because you commented.Message ID: @.***>

vikasrai1502 commented 11 months ago

I'm facing issues to make changes in AndroidManifest.xml, when I'm having .SplashActivity (react-native-splash-screen). I tried multiple permutation-combination but either app is crashing or getting [Error:ICON_INVALID]. Current AndroidManifest.xml code is below and getting [Error:ICON_INVALID] error.

Thanks

<activity
        android:name=".SplashActivity"
        android:theme="@style/AppTheme"
        android:label="@string/app_name"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
      </activity>  
        <activity-alias 
            android:name="com.packagename.SplashActivityDefault"
            android:enabled="true"
            android:exported="true"
            android:icon="@mipmap/ic_launcher"
            android:roundIcon="@mipmap/ic_launcher"
            android:targetActivity=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
            </intent-filter>
        </activity-alias>
        <activity-alias 
            android:name="com.packagename.SplashActivityXmas"
            android:enabled="false"
            android:exported="true"
            android:icon="@mipmap/ic_launcher_xmas"
            android:roundIcon="@mipmap/ic_launcher_xmas"
            android:targetActivity=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
            </intent-filter>
        </activity-alias>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme"
        android:exported="true">
          <intent-filter android:autoVerify="true">
              <action android:name="android.intent.action.VIEW"/>
              <category android:name="android.intent.category.DEFAULT"/>
              <category android:name="android.intent.category.BROWSABLE"/>
              <data android:scheme="http" />
              <data android:scheme="https" />
          </intent-filter>
      </activity>
yunuskucuk11 commented 10 months ago

I use more than one variant. These types of applications give this error because of the package name, how should we use it?

jalvarez930 commented 8 months ago

tions give this error because of the package name, how

Have the same error. Do you resolve it

n76i commented 8 months ago

tions give this error because of the package name, how

Have the same error. Do you resolve it

Hello, I have the same error too, here is something can fix it:

sheriffmarley commented 3 weeks ago

I use more than one variant. These types of applications give this error because of the package name, how should we use it?

Had the same issue, this is because if you define a flavor with an applicationId, the packageName would become: com.example.myapp.dev but we need com.example.myapp

I could solve it by removing the flavor in ChangeIconModule.java on line 75 final String activeClass = this.packageName + ".MainActivity" + newIconName;

So i came up with this solution:

String activeClass = this.packageName + ".MainActivity" + newIconName;
        if (activeClass.contains(".dev.")) {
            activeClass = activeClass.replace(".dev.", ".");
        }

Guess we need a way to detect flavors properly so they can be removed.