我正在工作的反应本机应用程序和安装的反应-本机启动包的启动屏幕。我得到了以下错误。我按照这里发布的说明为android安装,但不起作用。
https://github.com/zoontek/react-native-bootsplash
错误
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)
Caused by: android.view.InflateException: Binary XML file line #28 in com.myreactapp:layout/splash_screen_view: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f030208 a=-1}
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f030208 a=-1}
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:826)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:8231)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:8429)
at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:452)这是styles.xml文件
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColor">@android:color/black</item>
<item name="android:editTextStyle">@style/ResetEditText</item>
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
</style>
<style name="ResetEditText" parent="@android:style/Widget.EditText">
<item name="android:padding">0dp</item>
<item name="android:textColorHint">#c8c8c8</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="Theme.App.SplashScreen" parent="AppTheme">
<item name="android:windowBackground">@drawable/splashscreen</item>
</style>
<style name="BootTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/bootsplash_background</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>
</resources>这是MainActivity.Java文件
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.zoontek.rnbootsplash.RNBootSplash; // for splash screen
import expo.modules.ReactActivityDelegateWrapper;
public class MainActivity extends ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Set the theme to AppTheme BEFORE onCreate to support
// coloring the background, status bar, and navigation bar.
// This is required for expo-splash-screen.
setTheme(R.style.AppTheme);
RNBootSplash.init(this);
super.onCreate(null);
}colors.xml文件
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resources>
<color name="splashscreen_background">#FFFFFF</color>
<color name="bootsplash_background">#FFFFFF</color>
</resources>更新:
该问题与模块发生冲突,与反应本机引导。我已经从代码中删除了它的引用,并且很好地使用了android。
Styles.xml去除
<style name="Theme.App.SplashScreen" parent="AppTheme">
<item name="android:windowBackground">@drawable/splashscreen</item>
</style>MainActivity.Java去除
setTheme(R.style.AppTheme);AndroidManifest.xml去除
android:theme="@style/Theme.App.SplashScreen"发布于 2022-08-11 12:20:37
我在这个包中遇到了类似的问题,它在ios中运行得很好,但是与android没有关系。
因此,我决定在我的react-native-splash-screen上使用另一个名为it.and的包来管理它们。
反应-本机-飞溅屏幕(Android)
App.js
import SplashScreen from 'react-native-splash-screen';
useEffect(() => {
setTimeout(() => {
if (Platform.OS == 'ios') {
RNBootSplash.hide();
} else {
SplashScreen.hide();
}
}, 1000);
}, []);MainActivity.java
import org.devio.rn.splashscreen.SplashScreen;
@Override
protected String getMainComponentName() {
return "name";
}
// Screen
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
super.onCreate(null);
}反应-本机启动(Ios)
App.js
import RNBootSplash from 'react-native-bootsplash';
useEffect(() => {
setTimeout(() => {
if (Platform.OS == 'ios') {
RNBootSplash.hide();
} else {
SplashScreen.hide();
}
}, 1000);
}, []);AppDelegate.m
#import "RNBootSplash.h"
self.window = [[UIWindow alloc] initWithFrame:[UIScreen
mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];我希望这对你也有帮助。
https://stackoverflow.com/questions/73319284
复制相似问题