[英]Android APK not working properly after build using Expo React Native
I've been working on an app, and I have been using both the Android emulator and my Android device for testing using Expo.我一直在开发一个应用程序,我一直在使用 Android 模拟器和我的 Android 设备来使用 Expo 进行测试。
It works great, everything goes perfect.效果很好,一切都很完美。 However, I just built an Android APK (I executed expo build:android
), and I can see the login of my app, but after introducing credentials, it kinda shows like it closes the app and then restores it, but now it keeps showing just a blank screen.但是,我刚刚构建了一个Android APK(我执行了expo build:android
),并且可以看到我的应用程序的登录信息,但是在引入凭据后,它有点显示关闭应用程序然后恢复它,但现在它一直显示只是一个空白的屏幕。
Here is a gif showing you exactly what happens.这是一个 gif,向您展示会发生什么。
https://giphy.com/gifs/hdtXNeM2s5Dx7FnbNJ https://giphy.com/gifs/hdtXNeM2s5Dx7FnbNJ
Also, here's the code of my App.js, which works showing the <AuthNavigator />
(The login screen), but it stops working when a user is set and then <AppNavigator />
does not appear.另外,这里是我的 App.js 的代码,它可以显示<AuthNavigator />
(登录屏幕),但是当设置用户时它停止工作,然后<AppNavigator />
没有出现。
import React, { useState } from "react";
import { StyleSheet } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { AppLoading } from "expo";
import AppNavigator from "./app/navigation/AppNavigator";
import AuthNavigator from "./app/navigation/AuthNavigator";
import AuthContext from "./app/auth/context";
import authStorage from "./app/auth/storage";
export default function App() {
const [user, setUser] = useState();
const [isReady, setIsReady] = useState(false);
const restoreUser = async () => {
const user = await authStorage.getUser();
if (user) setUser(user);
};
if (!isReady) {
return (
<AppLoading startAsync={restoreUser} onFinish={() => setIsReady(true)} />
);
}
return (
<AuthContext.Provider value={{ user, setUser }}>
<NavigationContainer>
{user ? <AppNavigator /> : <AuthNavigator />}
</NavigationContainer>
</AuthContext.Provider>
);
}
Also my app.json, just in case it's needed:还有我的 app.json,以防万一:
{
"expo": {
"name": "Agro-Mobile",
"slug": "Agro-Mobile",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./app/assets/icon.png",
"splash": {
"image": "./app/assets/splash.png",
"resizeMode": "cover",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.smartbase.agrocognitive",
"versionCode": 1
},
"web": {
"favicon": "./app/assets/favicon.png"
},
"description": ""
}
}
In app.json you need change:在 app.json 你需要改变:
"android": {
"package": "com.smartbase.agrocognitive",
"versionCode": 1
for this为了这
"android": {
"package": "com.agrocognitive.agrocognitive",
"versionCode": 1
in other words you need only change the name of company for the name of your app, make sure use only lowercase characters without simbol.换句话说,您只需要更改应用程序名称的公司名称,请确保仅使用小写字符而不使用 simbol。 The folder that your create have the same name of your app.您创建的文件夹与您的应用程序同名。 And for other people delete any commentary in App.js.对于其他人,删除 App.js 中的任何评论。
This works for me in bluestacks emulator and in my phone running apk file I hope help you这适用于我在 bluestacks 模拟器和我的手机中运行 apk 文件我希望能帮助你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.