我已经在VS代码中创建了一个反应本地应用程序。该应用程序在使用世博的浏览器中运行良好。生成一个keystore文件,并使用gradlew assembleRelease创建一个assembleRelease。
.apk可以安装在我的安卓平板电脑上。但是在启动应用程序之后,它没有运行,而是显示了启动屏幕(见下图)。
平板电脑(30)上的SDK版本高于应用程序的minSdkVersion (21)。
还将<uses-feature android:name="android.hardware.telephony" android:required="false" />添加到AndroidManifest.xml文件中。

代码如下。
index.js:
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:
import React from 'react'
import List from './List.js'
const App = () => {
return (
<List />
)
}
export default AppList.js:
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'
}
})发布于 2022-07-26 07:57:58
如果您使用expo来创建本机应用程序,那么您必须使用以下命令在expo上构建一个应用程序
expo build:adroid或expo build:ios
一旦构建成功,您将获得一个URL,然后您可以使用URL安装应用程序在您的设备上。
如果您正在使用are本机-cli创建are本机应用程序,那么您必须使用以下命令在expo上构建一个应用程序。
MacOs中的./gradlew assembleRelease or ./gradlew assembleDebug
https://stackoverflow.com/questions/73099938
复制相似问题