@gorhom/bottom-sheet 模式无法在带有 apk 的 Android 上打开

问题描述 投票:0回答:1

我在 React Native 应用程序(带有 Expo)中使用 @gorhom/bottom-sheet 包,在按下按钮时打开底部表单模式。

在 iOS 和 Android 上使用 expo start 一切正常:当我单击按钮时,模式会显示,当我向下滑动时,模式会消失。

但是当我构建签名的 .apk 文件并将其安装到我的 Android 手机上时,模式不会显示。没有错误,没有消息,什么都没有。

我正在使用以下依赖项,并且我已遵循有关底部表单模式和react-native-gesture-handler/react-native-reanimated的额外说明:

  • “@gorhom/bottom-sheet”:“^4.4.7”
  • “反应本机”:“^0.72.4”
  • “react-native-gesture-handler”:“^2.12.1”
  • “react-native-reanimated”:“~3.3.0”
  • “react-native-safe-area-context”:“4.6.3”
  • “博览会”:“^49.0.8”

应用程序:

import { BottomSheetModalProvider, BottomSheetModal } from '@gorhom/bottom-sheet';
import { Button } from '@rneui/themed';
import { useRef, useCallback, useMemo } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

export default function App() {
    const bottomSheetModalRef = useRef(null);
    const snapPoints = useMemo(() => ['50%'], []);

    const handlePresentModalPress = useCallback(() => {
        bottomSheetModalRef.current?.present();
    }, []);

    const handleSheetChanges = useCallback((index) => {
        console.log('handleSheetChanges', index);
    }, []);

    // renders
    return (
        <GestureHandlerRootView style={{ flex: 1 }}>
            <BottomSheetModalProvider>
                <View style={styles.container}>
                    <Button
                        onPress={handlePresentModalPress}
                        title="Present Modal"
                        color="black"
                    />
                    <BottomSheetModal
                        ref={bottomSheetModalRef}
                        index={0}
                        snapPoints={snapPoints}
                        onChange={handleSheetChanges}
                    >
                        <View style={styles.contentContainer}>
                            <Text>Awesome 🎉</Text>
                        </View>
                    </BottomSheetModal>
                </View>
            </BottomSheetModalProvider>
        </GestureHandlerRootView>
    );
};

const styles = StyleSheet.create({
    container: {
        flex: 1,
        padding: 24,
        justifyContent: 'center',
        backgroundColor: 'grey',
    },
    contentContainer: {
        flex: 1,
        alignItems: 'center',
    },
});

知道可能是什么问题吗?

android react-native modal-dialog apk bottom-sheet
1个回答
0
投票

我也遇到了和你一样的问题 我建议你用 “eas build -p android --配置文件预览”

尝试构建 “EAS构建” 这将生成一个 .aab 文件 然后使用aab to apk app converter(从google play store下载)将生成的.aab文件转换为apk 安装 apk 就可以了

© www.soinside.com 2019 - 2024. All rights reserved.