我正在尝试在React Native中构建一个发行版.apk文件但没有成功.我按照这里的所有说明操作,但gradlew assembleRelease在/ my-project/android路径中运行后总是得到相同的结果:
:app:validateSigningRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release
Run Code Online (Sandbox Code Playgroud)
我正在使用Windows 10,我怀疑它是编辑文件〜/ .gradle/gradle.properties的东西
从我的理解〜是c:\ Users\User我甚至得到了ac:\ Users\User.gradle文件夹内置.
我正在使用React Native 0.46编写原生Android模块,但我无法从模块中获取当前活动实例.
我有一个扩展ReactContextBaseJavaModule的类,它包含一个内置的getCurrentActivity()方法.但是,每次调用此方法时,我都会得到一个null.
我想这是因为我在我的模块构造函数中调用它,它在Android应用程序的开头执行,可能在Activity实例化之前?
如果你们知道从模块中访问当前Activity实例的干净方法(如果可能的话,不必在某个时刻存储一个Activity实例并传递它),我会很高兴的!
我最近开始反应原生和跟随教程指南有2个选项一个是通过"create-react-native-app myproject"创建项目,另一个是"react-native init myproject".
第一个(create-react-native-app)只生成app.js而另一个生成index.android.js和index.ios.js ..
我知道他们在做同样的工作,但这里真正的不同之处是什么?我应该选择哪一个开始,哪一个更有用?
我已经把android后退按钮退出我的主屏幕中的反应本机应用程序中的应用程序功能.但是当我在其他屏幕上按下android后退按钮时,它也会被调用.
componentDidMount() {
if (Platform.OS == "android") {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
}
this._setupGoogleSignin();
this._getUserDetails();
const { navigate } = this.props.navigation;
console.log("object url is", this.state.postsArray[0].url);
}
handleBackButton = () => {
Alert.alert(
'Exit App',
'Exiting the application?', [{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel'
}, {
text: 'OK',
onPress: () => BackHandler.exitApp()
}, ], {
cancelable: false
}
)
return true;
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
}
Run Code Online (Sandbox Code Playgroud) 我们正在构建一个React Native应用程序,它使用redux-persist来存储应用程序状态,包括导航状态.我想这个应用程序在导航方面表现得像本机应用程序:
当原生Android应用程序进入后台时,最终会被操作系统停止,然后移动到前台,它将在用户之前停止的活动中恢复.如果同一个应用程序被用户杀死(或崩溃),它将在主Activity上打开.
对于RN应用程序,这意味着redux-persist应该持久化并恢复应用程序的componentWillMount中的导航状态,但前提是应用程序未被用户杀死.
以下代码有效:
componentWillMount() {
if (global.isRelaunch) {
// purge redux-persist navigation state
}
global.isRelaunch = true;
...
Run Code Online (Sandbox Code Playgroud)
但它看起来很乱,我也不明白为什么全球范围仍然存在.
检测RN应用程序是否从后台重新打开的正确方法是什么?(理想情况下支持iOS)
嗨,我正在开发基于FlatList的示例应用程序,这是我的代码.实际上我显示了整个记录,比如我有50条记录到我的账户.但现在我显示了整整50条记录.Bur我需要在添加10条记录后显示10.但我不知道添加到FlatList.
这是我的代码:
<FlatList
data={this.state.profiles}
renderItem={({ item, index }) => this.renderCard(item, index)}
keyExtractor={item => item.id}
ItemSeparatorComponent={() => <Divider style={{ marginTop: 5, marginLeft: width * 0.2 + 20 }} parentStyle={{ backgroundColor: globalStyles.BG_COLOR, alignItems: 'baseline' }} />}
/>
renderCard (profile, index) {
console.log('rendercard', profile);
//
return (
<View key={profile.id}>
<ProfileCard
profile={profile}
style={styles.card}
onPress={() => this.props.screenProps.rootNavigation.navigate('Profile', { profile: this.state.profile, id: profile.id })}
// onPress={() => alert('PROFILE')}
onAddClick={() => this.setState({ connectionPageVisible: true, cardProfile: profile })}
connectedIds={(this.props.screenProps && this.props.screenProps.connectedIds) || this.props.connectedIds}
/>
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
请告诉我使用活动指标加载更多记录.提前致谢
react-native react-native-android react-native-ios react-native-flatlist
是否可以将prop添加nativeID到如下视图中:
<View nativeID="viewId">...</View>
然后使用该id在我的原生android和iOS代码中查找视图,以便我可以在其上应用一些本机方法.如果它是一个例子将不胜感激.
编译到android并通过Store下载后,出现错误:
"TypeError: Invalid attempt to spread non-iterable instance"
Run Code Online (Sandbox Code Playgroud)
但是使用“react-native run-android”不会产生任何错误消息,因此我找不到调试它的好方法。
fetch(url)
.then(response => response.json())
.then(response => {
if (this._mounted) {
// let dataSource = this.state.articlesDataSource.cloneWithRows(response.data || [])
//var rowCount = dataSource.getRowCount();
var rowCount = Object.keys(response.data).length;
if (refresh == true) {
prevData = {};
} else {
prevData = this.state.articlesData;
}
if (propSearch == "" || propSearch == null) {
newArticlesData = [...prevData, ...response.data];
} else {
newArticlesData = response.data;
}
if (response.meta.next_page != null) {
var rowCount = true;
} …Run Code Online (Sandbox Code Playgroud) 当 TextInput 被聚焦并且用户滚动直到输入离开可见框架时,输入变得模糊并且键盘消失。我该如何解决?
我在 Android 模拟器中运行代码。在 iOS 上不会出现此问题。如果您尝试点击 FlatList 底部的 TextInput,则键盘会立即关闭,这可能是因为 Input 在打开后位于键盘下方。任何线索将不胜感激
这是要重现的代码
import React from 'react';
import { TextInput, FlatList } from 'react-native';
export default class App extends React.Component {
render() {
return (
<FlatList
data={["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"]}
keyExtractor={item => item}
renderItem={({item}) => (
<TextInput placeholder="0.0"
keyboardType='decimal-pad'
onFocus={() => {void(0)}}
/>
)}
/>
);
}
}
Run Code Online (Sandbox Code Playgroud)

Input 应该保持焦点并且用户应该能够输入文本,即使 Input 不可见。这使得整个应用程序无法在 Android …
android-softkeyboard react-native react-native-android react-native-flatlist