Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes after changing colors #12

Closed
ronitkrshah opened this issue Apr 22, 2024 · 5 comments
Closed

App crashes after changing colors #12

ronitkrshah opened this issue Apr 22, 2024 · 5 comments

Comments

@ronitkrshah
Copy link

I'm using bare react native project not expo.
Android Version: 12L

ThemeProvider.tsx

import { useMemo } from "react";
import type { FC, PropsWithChildren } from "react";
import { useColorScheme } from "react-native";
import { useMaterial3Theme } from "@pchmn/expo-material3-theme";

import {
  Provider as MaterialYouTheme,
  MD3LightTheme,
  MD3DarkTheme,
} from "react-native-paper";

export const MaterialYouThemeProvider: FC<PropsWithChildren> = ({
  children,
}) => {
  const colorScheme = useColorScheme();
  const { theme } = useMaterial3Theme();

  // Material You Theme
  const materialTheme = useMemo(
    () =>
      colorScheme === "dark"
        ? { ...MD3DarkTheme, colors: theme.dark }
        : { ...MD3LightTheme, colors: theme.light },
    [colorScheme, theme],
  );

  // Render
  return <MaterialYouTheme theme={materialTheme}>{children}</MaterialYouTheme>;
};

Video

screen-20240422-135628.mp4

Github Project Repo - Link

@pchmn
Copy link
Owner

pchmn commented Apr 26, 2024

Some questions to address the bug :

  • If you don't change the colors it works well ?
  • It only crashes when changing colors ?
  • Do you have an error log that you can share ?

@ronitkrshah
Copy link
Author

If you don't change the colors it works well ?

Yes It working fine if I don't change colors

It only crashes when changing colors ?

Yes, Only After changing colors

Do you have an error log that you can share ?

Here's adb logcat

04-26 15:11:02.164 E/unknown:ReactNative( 8927): Tried to remove non-existent frame callback
04-26 15:11:02.179 E/AndroidRuntime( 8927): FATAL EXCEPTION: main
04-26 15:11:02.179 E/AndroidRuntime( 8927): Process: com.weather, PID: 8927
04-26 15:11:02.179 E/AndroidRuntime( 8927): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.weather/com.weather.MainActivity}: androidx.fragment.app.Fragment$f: Unable to instantiate fragment com.swmansion.rnscreens.t: calling Fragment constructor caused an exception
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3822)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3963)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5988)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5884)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:76)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2468)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.os.Handler.dispatchMessage(Handler.java:106)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.os.Looper.loopOnce(Looper.java:205)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.os.Looper.loop(Looper.java:294)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread.main(ActivityThread.java:8244)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at java.lang.reflect.Method.invoke(Native Method)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
04-26 15:11:02.179 E/AndroidRuntime( 8927): Caused by: androidx.fragment.app.Fragment$f: Unable to instantiate fragment com.swmansion.rnscreens.t: calling Fragment constructor caused an exception
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.Fragment.j0(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.g.d(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.m$e.a(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.s.<init>(SourceFile:3)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.m.e1(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.h.w(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.e$b.a(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at b.a.c(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.activity.ComponentActivity.onCreate(Unknown Source:7)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at androidx.fragment.app.e.onCreate(Unknown Source:0)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at com.facebook.react.n.onCreate(Unknown Source:0)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.Activity.performCreate(Activity.java:8621)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.Activity.performCreate(Activity.java:8599)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1450)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3804)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	... 15 more
04-26 15:11:02.179 E/AndroidRuntime( 8927): Caused by: java.lang.reflect.InvocationTargetException
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at java.lang.reflect.Constructor.newInstance0(Native Method)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	... 30 more
04-26 15:11:02.179 E/AndroidRuntime( 8927): Caused by: java.lang.IllegalStateException: Screen fragments should never be restored. Follow instructions from https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067 to properly configure your main activity.
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at com.swmansion.rnscreens.p.<init>(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	at com.swmansion.rnscreens.t.<init>(SourceFile:1)
04-26 15:11:02.179 E/AndroidRuntime( 8927): 	... 32 more

@pchmn
Copy link
Owner

pchmn commented Apr 26, 2024

Ok thanks, strange.

Did it work before using @pchmn/expo-material3-theme ?

And there is no "react-native" error logs when the app crashes ?

@ronitkrshah
Copy link
Author

Seems like this issue coming from somewhere else .... I just Commented everything with @pchmn/expo-material3-theme but still app crashes after changing colors .... Looks like there's an issue with react-native-screens

@pchmn
Copy link
Owner

pchmn commented Apr 26, 2024

Ah yes, there are some issues (#1697, #1644) about that in react-native-screens repo.

I'm closing this issue if you don't mind since it is not related to @pchmn/expo-material3-theme

@pchmn pchmn closed this as completed Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants