我通过 react native 创建了一个简单的应用程序。现在完成部署后,我想发布 apk,以便根据它的官方网站创建密钥:
"C:\Program Files\Java\jdk1.8.0_162\bin\keytool.exe" -genkeypair -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Run Code Online (Sandbox Code Playgroud)
我补充说:
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=mypass
MYAPP_UPLOAD_KEY_PASSWORD=mypass
Run Code Online (Sandbox Code Playgroud)
到android/gradle.properties文件最后我补充release部分到signingConfigs部分android/app/build.gradle文件:
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
Run Code Online (Sandbox Code Playgroud)
我将此标志配置添加到buildTypes部分:
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行 react-native run-android 但收到以下错误:
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:26: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
D:\Work\CS\Wms-Mobile\CS-WmsMobile\node_modules\@react-native-community\async-storage\android\src\main\java\com\reactnativecommunity\asyncstorage\AsyncStorageModule.java:34: error: cannot find symbol
@ReactModule(name = AsyncStorageModule.NAME)
^
symbol: class ReactModule
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-community_async-storage:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log …Run Code Online (Sandbox Code Playgroud) 运行时出现此错误 react-native run-android
日志:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Android Gradle Plugin Version - 3.6.3
Gradle Version- 6.0.1
Run Code Online (Sandbox Code Playgroud) android-studio android-sdk-manager react-native react-native-android
我正在尝试在 React Native 中制作翻译动画。
这是我的代码
const scrollX = React.useRef(new Animated.Value(0)).current;
<Animated.ScrollView
horizontal
snapToInterval={width}
onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { x: scrollX } } }],
{ useNativeDriver: false }
)}
scrollEventThrottle={16}
></Animated.ScrollView>
<Animated.View style={{ transform: [{ translateX: multiply(scrollX, -1) }] }}>
<Text>Some text</Text>
</Animated.View>
Run Code Online (Sandbox Code Playgroud)
我收到此错误 transform with key of translatex must be a number
如果我的变化multiply(scrollX, -1),以scrollX动画逆转,
我该如何解决这个问题?
我正在使用 React-native-dropdown-picker,但是我无法从下拉列表中选择任何项目,这些项目被下面的视图重叠。我试过添加 position:'absolute, zIndex:2 但仍然是 itemlist 重叠如下:

我已经编写了下拉组件的代码如下
return (
<View>
<View style={styles.container}>
{console.log('new array', dateArr)}
{console.log('arr', arr)}
<Icon
name="arrow-left"
size={20}
color="#fff"
style={{marginTop: 12}}
/>
{console.log('----------date', dateArr)}
{dateArr != null && (
<DropDownPicker
onValueChange={(value) => onValSelect(value)}
items={dateArr}
itemStyle={{
// justifyContent: 'flex-start',
flexDirection:'row'
}}
containerStyle={{height: 40,width:'80%',zIndex:2}}
/>
)}
</View>
<DaysInAWeek daysInAWeek={daysInAWeek} />
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#FE017E',
// height: 56,
width: '100%',
flexDirection: 'row',
padding: 10,
},
});
Run Code Online (Sandbox Code Playgroud)
onValSelect() 如下:
function onValSelect(val) {
if (val.length …Run Code Online (Sandbox Code Playgroud) 有人可以让我知道我哪里出错了。从我可以上看到的说明....世界上没有如果你只使用本地通知,并使用autolinking ....除了添加需要到Android特定文件修改googlePlayServicesVersion = "<Your play services version>" // default: "+"到android/build.gradle....,并<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>加<uses-permission android:name="android.permission.VIBRATE" />至AndroidManifest.xml
下面是我的主要源代码
PushNotification.configure({
// (optional) Called when Token is generated (iOS and Android)
onRegister: function(token) {
console.log('onRegister token:', token);
},
// (required) Called when a remote is received or opened, or local notification is opened
onNotification: function(notification) {
console.log('onNotification:', notification);
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
// Should the initial notification be popped automatically
popInitialNotification: true,
requestPermissions: true,
});
userNowInactive = …Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-push-notification
我想将基于React Native的模块集成到我现有的Android应用程序中。到目前为止,它的工作效果还不错,但我也想集成CodePush,以将更新部署到我的应用程序中。
重要的一点是,模块应该独立于特定的应用程序,因为我有多个应使用这些模块的不同应用程序。因此,模块本身是独立的React Native包,因此它们必须是单独的Code-Push应用程序(我想)。
当前,这样的React Native模块(实现为Fragment)的工作方式如下:
public class ReactFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
ReactRootView mReactRootView = new ReactRootView(getContext());
ReactInstanceManager mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getActivity().getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(false)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null);
return mReactRootView;
}
}
Run Code Online (Sandbox Code Playgroud)
因此,按照官方CodePush指南,我不知道如何在同一个Android应用程序中使用多个CodePush项目。但是我认为我内部一定有某种东西onCreateView可以让我注入CodePush包或至少一个自定义ReactNativeHost。
我正在使用React Native创建一个移动应用程序,我决定使用来自网站“ https://github.com/beefe/react-native-navigation-bar ” 的导航栏,但我不知道如何使用它在我的代码中。
我希望您向我发送网站“ https://github.com/beefe/react-native-navigation-bar ” 的导航栏示例。
每当我运行应用程序时,我总是会在开发人员工具中看到
DEV === true,开发级别警告为ON,性能优化为OFF
如何将“性能优化”设置为“开”并将DEV设置为“假”?
我正在努力寻找解决问题的方法,但是在任何地方都无法找到它。所以我的问题是如何从孩子那里调用父函数。该函数具有在将被传递onPress = {()}的子内
Parent.js
constructor(props) {
super(props);
this.state = { loading: true };
this.state = { active: 'active' };
this.openDrawer = this.openDrawerButtonFunction.bind(this);
this.callParent = this.callParent.bind(this)
}
callParent = () => {
console.log('I am your father') }
Run Code Online (Sandbox Code Playgroud)
Child.js
<Avatar
avatarStyle={{ height: 50 }}
onPress={() => { this.onPressAvatar() }}
source={require('../../assets/images/dav-r.jpeg')} />
onPressAvatar = () => {
console.log('press on avatar');
this.props.callParent.bind(this)
Run Code Online (Sandbox Code Playgroud)
}
javascript reactjs react-native react-native-android react-native-ios
react-native ×10
reactjs ×2
android ×1
animation ×1
asyncstorage ×1
code-push ×1
javascript ×1
react-native-push-notification ×1
transform ×1