Page 1 of 1

APK zeigt einen leeren Bildschirm an, wenn ich Navigator verwende

Posted: 03 Jun 2025, 10:18
by Anonymous
Ich bin neu bei React Native und ich habe eine App in RN codiert. Ich habe es mit NPX Expo Start und Expo -Go -App auf meinem Telefon getestet. Alles funktioniert. Ich habe eine .APK -Datei mit Eas Build erstellt. Als ich den .APK heruntergeladen und die App installierte, sah ich leer Bildschirm. Ich habe herausgefunden, dass die APK -Datei funktioniert, wenn ich Navigator in meiner App nicht verwende (als ich eine App mit meinem Startbildschirm erstellt habe, aber ohne Navigator alles funktioniert hat). (docs.expo.com) [docs.expo.com], aber ich habe Eas.json Datei geändert.

Code: Select all

node --version
v18.19.1

npm expo --version
9.2.0
und es gibt alle wichtigen (wahrscheinlich) Dateien:
app.js

Code: Select all

import { Text, View } from 'react-native';
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import Home from "./screens/Home";
import About from './screens/About';
const Stack=createNativeStackNavigator();

export default function App() {
return (








);
}
home.js . About.js sieht ähnlich aus

Code: Select all

import { Button, Text, View } from "react-native";

export default function Home({navigation}){
return (

Home
navigation.navigate("About")} title="Go to about"/>

);
}
app.json

Code: Select all

{
"expo": {
"name": "app1",
"slug": "app1",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"newArchEnabled": true,
"splash": {
"image": "./assets/splash-icon.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"edgeToEdgeEnabled": true,
"package": "com.kardimon57.app1"
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "7d4011bb-176d-4861-bb81-fa7f9f0c4cc9"
}
}
}
}
eas.json

Code: Select all

{
"cli": {
"version": ">= 16.7.0",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"android": {
"buildType": "apk"
},
"distribution": "internal"
},
"production": {
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}
Erstellen Sie die APK -Datei, die ich mit dem Befehl Eas Build -p Android -Profile -Vorschau verwendet habe. Ich fand, dass das Entfernen von Alignitems: "Center" < /code> Parameter im Hauptcontainer in app.js helfen sollte, aber dies nicht.npm install react-native-screens react-native-safe-area-context< /code>, aber auch nichts passiert.
Ich habe auch die .APK -Datei auf zwei Geräten getestet. Ich bekomme den leeren Bildschirm.