skb1129 / react-native-change-icon

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

Android app crashes after changing icon and trying to get native premission #53

Closed ToniLloyds closed 1 year ago

ToniLloyds commented 2 years ago

Platform

Description App crashes after changing icon and asking for permission or opening in app browser

To Reproduce Steps to reproduce the behavior:

  1. After installing the app change the icon
  2. Try to ask for permission for example using react-native-permissions package request method
  3. App crashes after showing native modal for 1 sec

If app doesn't change the icon everything works

Expected behavior App should not crash

Device (please complete the following information):

Versions

Code Snippet AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.cbre.exampleName">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/delftsepoort"
      android:roundIcon="@mipmap/delftsepoort_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </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" />
           <!-- Accepts URIs that begin with "cbre:// -->
          <data android:scheme="cbre" android:host="cbre" />
      </intent-filter>
      </activity>
      <!-- App Change Icons -->
      <!--  App has to be com.appName.MainActivityIconName -->
      <activity-alias
        android:name="com.cbre.exampleName.MainActivitydelftsepoort"
        android:enabled="false"
        android:icon="@mipmap/delftsepoort"
        android:roundIcon="@mipmap/delftsepoort_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.cbre.exampleName.MainActivitysecondary"
        android:enabled="false"
        android:icon="@mipmap/secondary"
        android:roundIcon="@mipmap/secondary_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.cbre.exampleName.MainActivitywtcutrecht"
        android:enabled="false"
        android:icon="@mipmap/wtcutrecht"
        android:roundIcon="@mipmap/wtcutrecht_round"
        android:targetActivity=".MainActivity">
        <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity-alias>
      <meta-data
        android:name="com.google.android.gms.wallet.api.enabled"
        android:value="true" 
      />
    </application>
</manifest>

Logcat

com.exampleName.elevate E/unknown:ReactNative: Tried to remove non-existent frame callback

...

2022-02-02 12:08:26.295 9237-9254/com.cbre.exampleName W/System: A resource failed to call release. 
2022-02-02 12:08:26.295 9237-9254/com.cbre.exampleName W/System: A resource failed to call release. 
2022-02-02 12:08:39.955 9237-9237/com.cbre.exampleName D/AppCompatDelegate: Exception while getting ActivityInfo
    android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{com.cbre.exampleName/com.cbre.exampleName.MainActivity}
        at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:467)
        at androidx.appcompat.app.AppCompatDelegateImpl.isActivityManifestHandlingUiMode(AppCompatDelegateImpl.java:2663)
        at androidx.appcompat.app.AppCompatDelegateImpl.updateForNightMode(AppCompatDelegateImpl.java:2511)
        at androidx.appcompat.app.AppCompatDelegateImpl.applyDayNight(AppCompatDelegateImpl.java:2386)
        at androidx.appcompat.app.AppCompatDelegateImpl.onCreate(AppCompatDelegateImpl.java:497)
        at androidx.appcompat.app.AppCompatActivity$2.onContextAvailable(AppCompatActivity.java:131)
        at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.java:99)
        at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:313)
        at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:273)
        at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)
        at com.cbre.exampleName.MainActivity.onCreate(MainActivity.java:9)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
ToniLloyds commented 2 years ago

Here is a minimal reproducible example with fresh install of react native and very similar package rn-dynamic-app-icon but same thing happens with this one

To reproduce git clone https://github.com/ToniLloyds/example-cahnge-icon-bug cd into project directory install dependencies yarn Run it yarn android After app opens click on "change UK" or "change US" Click Request permission App crashes

omerakyol commented 2 years ago

@ToniLloyds You can follow this fix: https://github.com/skb1129/react-native-change-icon/pull/66/commits/7542e96b830d2d4df38c5599213be18735709565

skb1129 commented 2 years ago

@ToniLloyds can you please try using v4.0.0 I can see you have action MAIN & category LAUNCHER in your MainActivity XML, try removing that. Also you need to android:exported="true" to both you activity-alias Try running the example application on your device

skb1129 commented 1 year ago

closing this issue due to inactivity

TierryBr commented 7 months ago

this problem still persists