首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >react本机应用程序没有运行-启动屏幕显示

react本机应用程序没有运行-启动屏幕显示
EN

Stack Overflow用户
提问于 2022-07-24 15:58:41
回答 1查看 498关注 0票数 0

我已经在VS代码中创建了一个反应本地应用程序。该应用程序在使用世博的浏览器中运行良好。生成一个keystore文件,并使用gradlew assembleRelease创建一个assembleRelease。

.apk可以安装在我的安卓平板电脑上。但是在启动应用程序之后,它没有运行,而是显示了启动屏幕(见下图)。

平板电脑(30)上的SDK版本高于应用程序的minSdkVersion (21)。

还将<uses-feature android:name="android.hardware.telephony" android:required="false" />添加到AndroidManifest.xml文件中。

代码如下。

index.js:

代码语言:javascript
复制
import { registerRootComponent } from 'expo';

import App4 from './App4';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App4);

附录4.js:

代码语言:javascript
复制
import React from 'react'
import List from './List.js'

const App = () => {
   return (
      <List />
   )
}
export default App

List.js:

代码语言:javascript
复制
import React, { Component } from 'react'
import { Text, View, TouchableOpacity, StyleSheet, Image } from 'react-native'
   
class List extends Component {
   state = {
      products: []
   }

   componentDidMount() {
      this.GetAllProducts();
   }

   GetAllProducts() {
      //fetch("http://192.168.2.14:3000/getallproducts")
      fetch("https://categoriesexpress444.herokuapp.com/getallproducts")
         .then(res => res.json())
         .then(jsonresult => {
            this.setState({
                  products: jsonresult
            });
            console.log(this.state.products);
         });
   }

   getsrcPath(string) { // this function distinguishes between images in UserImages folder and images on Cloudinary
      var firstChar = string.charAt(0);
      if (firstChar == '~') { // image is in UserImages folder and item.picture path starts wih ~/UserImages/
         return string.substring(1, string.length);
      }
      else { // image is at Cloudinary and item.picture starts with http://
         return string;
      }
   }

   render() {
      return (
         <View>
            {
               this.state.products.map((item, index) => (
                  <TouchableOpacity
                     key = {item.id}
                     style = {styles.container}>
                     <Text style = {styles.text}>{item.productname}</Text>
                     <Text>{item.description}</Text>
                     <Text>€ {item.price}</Text>
                     <img src={this.getsrcPath(item.picture)} />
                     <Text style = {styles.text}>
                        {item.name}
                     </Text>
                  </TouchableOpacity>
               ))
            }
         </View>
      )
   }
}
export default List

const styles = StyleSheet.create ({
   container: {
      padding: 10,
      marginTop: 3,
      backgroundColor: '#ffffff',
      alignItems: 'center',
      cursor: 'none'
   },
   text: {
      color: '#4f603c'
   }
})
EN

回答 1

Stack Overflow用户

发布于 2022-07-26 07:57:58

如果您使用expo来创建本机应用程序,那么您必须使用以下命令在expo上构建一个应用程序

expo build:adroidexpo build:ios

一旦构建成功,您将获得一个URL,然后您可以使用URL安装应用程序在您的设备上。

如果您正在使用are本机-cli创建are本机应用程序,那么您必须使用以下命令在expo上构建一个应用程序。

MacOs中的./gradlew assembleRelease or ./gradlew assembleDebug

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73099938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档