gpt4 book ai didi

react-native - react native 签名的 APK 崩溃

转载 作者:行者123 更新时间:2023-12-03 17:12:15 28 4
gpt4 key购买 nike

启动后签名的 APK 崩溃,在 logCat 中我得到了 requiring unknown module 'React'
调试应用程序工作正常,但在 logCat 中我得到 >> 仅支持按名称要求模块“React”,并且将在生产中中断!

react v15.4.1, react 原生 v0.39.2 ?

对不起我的英语不好

最佳答案

这是我的 index.android.js

import React from 'react';
import {AppRegistry} from 'react-native';

import myapp from './index_start.js';

AppRegistry.registerComponent('myapp', () => myapp);

和 index_start.js
import React, { Component } from "react";
import {
StyleSheet,
AppRegistry,
Text,
Image,
View,
AsyncStorage,
NetInfo,
StatusBar,
Navigator,
Dimensions
} from 'react-native';

// Window dismensions
const { width, height } = Dimensions.get('window');

// Device infos
import DeviceInfo from 'react-native-device-info';
// Native SplashScreen
import SplashScreen from 'react-native-splash-screen';
// Spinner
import Spinner from 'react-native-spinkit';

// Models
import User from './model/UserModel';
// Json data for initial launch
var DB = require('./DB.json');

// Components
import Stage from './components/stage/stage.js'
import Player from './components/player/player.js'
import Settings from './components/settings/settings.js'
import House from './stages/house/house.js'


// LocalStorage key
var USER_KEY = 'user_key';

const routes = [
{name: 'loading'},
{name: 'stage', component: Stage},
{name: 'house', component: House},
{name: 'settings', component: Settings}
];

const _navigator = null;

export default class myapp extends Component {

constructor(props) {
super(props);

this.state = {
isConnected: false,
isLoading: true,
_navigator: null,
stages: null
}
}

componentWillMount() {
// check if connected
this._checkConnexionType();
}

componentDidMount() {
SplashScreen.hide();

this._loadInitialData();
}

componentDidUpdate() {
// console.log(this.state.stages)

if (!this.state.isLoading && this.state.stages !== null) {
_navigator.push({
name: 'stage',
passProps: {
data: this.state.stages
}
})
}
}

/**
* Load localStorage Data
*/
async _loadInitialData() {
// GET User LocalStorage

if (this.state.stages == null) {

var localData;
//AsyncStorage.removeItem(USER_KEY)

AsyncStorage.getItem(USER_KEY).then((data) => {
if (data !== null) {
var localData = JSON.parse(data);
// User.uuid = localData.uuid;
User.setStages(localData.stages)

this.setState({
'stages' : localData.stages
})
} else {
var storage = {};
storage.setUiid = DeviceInfo.getUniqueID();
storage.stages = DB.stages;
AsyncStorage.setItem(USER_KEY, JSON.stringify(storage));

this.setState({
'stages' : DB.stages
})
}

})

}

if (this.state.isConnected) {
// var rStages = this._loadRemoteStages();
// console.log(rStages);
}

// Change state
setTimeout((function() {
this.setState({
'isLoading': false
})
}).bind(this), 1500);

}


/**
* GET stages from remote DB
*/
async _loadRemoteStages() {
await fetch(API_URL)
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
return responseJson;
})
.catch((error) => {
console.error(error);
});
}

/**
* CHECK IF user is connected to Network
* SET bool to state isLoading
*/
_checkConnexionType() {
NetInfo.isConnected.fetch().then(response => {
this.setState({ isConnected: response})
})
}

_renderScene(route, navigator) {

_navigator = navigator;

if (route.name == 'loading') {
return (
<View style={styles.container}>
<StatusBar hidden={true} />
<Image
style={{width: width, height: height}}
source={require('./img/screen.jpg')}
/>

<View style={styles.loading}>
<Text style={styles.loadingText}>CHARGEMENT</Text>
<Spinner type="ThreeBounce" color={'#fff'}/>
</View>

</View>
)
} else if (route.name == 'stage') {
return (
<Stage navigator={_navigator} {...route.passProps}/>
)
} else if (route.name == 'player') {
return (
<House navigator={_navigator} {...route.passProps}}/>
)
} else if (route.name == 'settings') {
return (
<Settings navigator={_navigator} {...route.passProps}/>
)
}
}

render() {

return (

<Navigator
initialRoute={{name: 'loading'}}
configureScene={() => Navigator.SceneConfigs.FloatFromBottomAndroid}
renderScene={this._renderScene.bind(this)}
/>


);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
},
loading: {
flex: 1,
position: 'absolute',
bottom: 50,
left: 0,
right: 0,
alignItems: 'center',
},
loadingText:{
flex: 1,
fontFamily: 'CarterOne',
fontSize: 20,
color: '#fff'
}
});

关于react-native - react native 签名的 APK 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41778108/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com