以下是我AndroidManifest.xml...
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".BeaconApp"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBqhOHH31FYObdzoVW9TmQsv62TOP0LSLI"/>
</application>
Run Code Online (Sandbox Code Playgroud)
如您所见,我添加了获取位置信息所需的适当权限.但是,当我运行我的应用程序时,我得到一个奇怪的错误...
Looks like the app doesn't have permission to access location.
Add the following line to your app's AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
throwLocationPermissionMissing
...etc
Run Code Online (Sandbox Code Playgroud)
我已经添加了这个,AndroidManifest.xml所以我为什么会收到这个错误.我尝试重启Android Studio.我试过从模拟器中擦除数据.我试过Gradle - > Clean.这些都没有帮助.这里发生了什么?
有可能我的Android模拟器阻止GPS或什么?
我正在尝试借助来在两个屏幕之间导航react-navigation。我可以navigate在render方法内部访问,因为它的范围也在该方法内部。
我应该在哪里声明,以便可以访问this的任何方法component。我正在尝试访问方法navigate内部,onPressButton但它给出了错误。
找不到变量:导航
import React, { Component } from "react";
import { View, Text, Image, Button, Alert, StyleSheet } from "react-native";
import styles from "./Styles";
import * as strings from "./Strings";
import RoundButton from "./RoundButton";
var DialogAndroid = require("react-native-dialogs");
import { StackNavigator } from "react-navigation";
export default class CreateMessageScreen extends Component {
render() {
const { navigate } = this.props.navigation;
return (
<View style={styles.container}>
<Image source={require("./img/create_message.png")} />
<Text …Run Code Online (Sandbox Code Playgroud) javascript android reactjs react-native react-native-android
我收到一个错误:“使用newLatLngBounds(LatLngBounds,int)时出错:地图大小不能为零。最有可能的布局尚未出现在地图视图中。要么等待布局发生,要么使用newLatLngBounds(LatLngBounds(LatLngBounds,int,int) ,int),它允许您指定地图的尺寸”。
但是我为getCurrentPosition设置了警报,并且正在从getCurrentPosition()接收坐标。
import React, { Component } from 'react';
import { View, Dimensions } from 'react-native';
import MapView from 'react-native-maps';
const {width, height} = Dimensions.get('window')
const SCREEN_HEIGHT = height
const SCREEN_WIDTH = width
const ASPECT_RATIO = width / height
const LATITUDE_DELTA = 0.0922
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO
class Map extends Component {
constructor(props) {
super(props)
this.state = {
isMapReady: false,
initialPosition: {
longitude: 0,
latitude: 0,
longitudeDelta: 0,
latitudeDelta: 0
},
markerPosition: {
longitude: 0,
latitude: 0 …Run Code Online (Sandbox Code Playgroud)android reactjs react-native react-native-android react-native-maps
我是React Native的新手。在开发本机模块时,我遇到了回调问题。以下是来自React Native的错误消息
02-05 17:43:26.387 32301-32570/com.awesomeproject2 E/ReactNativeJNI: Got JS Exception: Exception calling object as function: abc,function f1() {
_ToastExample2.default.show('1111', _ToastExample2.default.SHORT);
},72,73 is not usable as a native method argument (<unknown file>:1845)
02-05 17:43:26.387 32301-32570/com.awesomeproject2 E/ReactNativeJNI: Got JS Stack: invariant@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:1838:26
enqueueNativeCall@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:2259:20
fn@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:1999:40
onBtnPress@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:58362:32
proxiedMethod@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:34324:37
proxiedMethod@[native code]
touchableHandlePress@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:37170:47
touchableHandlePress@[native code]
_performSideEffectsForTransition@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:36821:36
_performSideEffectsForTransition@[native code]
_receiveSignal@http://localhost:8081/index.delta?platform=android&dev=true&minify=false:36754:46
_receiveSignal@[native code]
touchableHandleResponderRelease@http://localhost:8081/index.delta?platform=android&dev=true&
02-05 17:43:26.393 32301-32570/com.awesomeproject2 E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Error calling RCTEventEmitter.receiveTouches
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:135)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) …Run Code Online (Sandbox Code Playgroud) 我无法创建以相同方向嵌套在FlatList内的FlatList;
结果是父级是水平的,而子级是垂直的;
这是我的代码:
renderSlides(question) {
return <View key={question.item.code}
style={{flex: 1,width:350}}>
<FlatList
ref='scrollPick'
data={[{k:'A'},{k:'b'},{k:'c'}}]}
horizontal={true}
renderItem={(rate)=>{return (
<View >
<Text>{rate.item.k}</Text>
</View>);}}
keyExtractor={ (item, index) => index}
/>
</View>;
}
render() {
return (
<View style={CONTAINERS.MAIN_COLUMN_BLUE}>
<View style={[NAV.CONTAINER_GENERAL, NAV.CONTAINER_ASSESSMENT, {flex: 1}]}>
<TopBar barType="ex" title={I18n.t('assessment.title')} navigator={this.props.navigator}
closeFunction={this.handleClose}></TopBar>
</View>
<FlatList
ref={(ref) => { this.flatListRef = ref; }}
horizontal={true}
data={[{k:'1'},{k:'2'},{k:'3'},{k:'4'},{k:'5'},{k:'6'},{k:'q'}]}
renderItem={this.renderSlides}
keyExtractor={(item, index) => index}
horizontal={true}
getItemLayout={this.getItemLayout}
contentContainerStyle={{ flexGrow: 1}}
/>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
有人遇到过同样的问题吗? (而且我不能使用scrollView)
react-native react-native-scrollview react-native-android react-native-ios react-native-flatlist
我想创建一个用于获取用户坐标的函数,但我发现我不确定我的方法是否足够好.
我想知道其他人如何编写这个函数,以便在ios和android上100%确定.
现在我有这样的事情:
function getUserLocation(callback: func) {
Permissions.check('location')
.then(response => {
if (response == 'authorized') {
navigator.geolocation.getCurrentPosition(
(location) => {
callback({
latitude: location.coords.latitude,
longitude: location.coords.longitude
}, response);
},
(error) => {
callback(null);
},
Platform.OS === 'android' ? null : {enableHighAccuracy: true, timeout: 100000, maximumAge: 1000}
);
} else {
callback(null, response);
}
})
}
Run Code Online (Sandbox Code Playgroud)
因此,您可以看到我想使用此函数,因此调用者可以知道是否允许使用位置以及是否获取当前坐标.
我正在尝试的是学习如何:
1.使这样的功能等待.
2.其他人如何使这样的功能(对于两种操作系统)和100%相同的功能.
ecmascript-6 react-native react-native-android react-native-ios
我一直在寻找一种限制用户的解决方案,只需点击一下本机就可以退出应用程序.
double-click exit react-native react-native-android react-native-ios
我正在研究react-native来开发一个示例应用程序.在我使用backHandlerreact-native side-menu组件时,我遇到了一个问题.
实际上,侧边菜单包含更多页面!但是当单击侧面菜单页面中的Android后退按钮时,只有后退处理程序工作.在这里,我使用react-native router-flux.
这里的后退按钮动作只调用一次!
这是我的代码:
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
}
handleBackPress = () => {
let {isGoback} = this.props.isGoback
//alert("Hi " + isGoback)
if(isGoback === "Contact Us"){
//alert("Hi: " + isGoback)
Actions.BasicSideMenuMain({selectedItem:'Home'});
//Actions.replace('BasicSideMenuMain')
}
}
Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-router-flux react-native-navigation
我在React Native Android项目上工作,但我被卡在这个错误上
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: androidx.versionedparcelable.NonParcelField
FAILURE: Build failed with an exception.
Run Code Online (Sandbox Code Playgroud)
我试图在build.gradle中将multi dex更改为false
defaultconfig {...
multiDexEnabled false
...}
Run Code Online (Sandbox Code Playgroud)
我不想迁移到androidx,我只想摆脱androidx&这个错误; 请帮助我,在此先感谢
您能帮我吗,我很想在react-native这样的屏幕截图中创建一个新项目。我能够运行旧项目。但我无法运行新项目
我已按照以下步骤操作:
react-native init projectName cd projectName react-native run-projectName但是我得到以下错误:
error Failed to install the app. Make sure you have the Android development environment set up:
Run Code Online (Sandbox Code Playgroud)
react-native ×9
android ×5
javascript ×2
reactjs ×2
double-click ×1
ecmascript-6 ×1
exit ×1
google-maps ×1
java ×1