我创建了一个新的 React Native 项目并运行react-native run-android。
但是,我收到此错误:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
这是我的android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories …Run Code Online (Sandbox Code Playgroud) 我正在使用react-native-maps,版本是"react-native-maps": "0.27.1".
我能够在2021 年 10 月 1 日星期五查看地图。
然而,今天(2021 年 10 月 4 日星期一)我收到带有 Google 徽标的空白地图,只有位置标记。
我尝试从react-native-maps(即google_maps_api.xml,PROVIDER_GOOGLE )进行故障排除,但它没有解决问题。
它还提到这可能是 API 密钥问题,但我在这个项目第一次工作时一直使用相同的 API 密钥(我也启用了计费)。
我没有对文件进行任何更改,也没有添加任何新内容,但地图仍然无法加载
我有另一个具有相同版本的项目
"react-native-maps": "0.27.1",它似乎运行良好并显示地图。
这是我的代码片段和其他文件:
地图屏幕.js:
import React, {Component} from 'react';
import {View, StyleSheet} from 'react-native';
import MapView, {Marker} from 'react-native-maps';
class DeliveryRoute extends Component {
constructor(props) {
super(props);
this.state = {
region: {
latitude: parseFloat(5.3302),
longitude: parseFloat(103.1408),
latitudeDelta: 0.002,
longitudeDelta: …Run Code Online (Sandbox Code Playgroud) javascript android google-maps react-native react-native-maps
我正在使用NavigationEvents自动加载我的列表。
到目前为止,它确实有效,并且加载了我更新的列表,但在控制台上,它继续在无限循环上运行 API 调用函数。
但是,每当我打开列表屏幕时,我只想加载 API 调用函数一次。
因此,如果有更好的解决方案,请随时提供帮助。
代码片段如下:
import { NavigationEvents } from 'react-navigation';
import NameActionBar from '../components/mNameActionBar';
import FreelancerList from '../components/mFreelancerList';
export default class MasterScreen extends Component {
componentDidMount() {
this.getFreelancerList();
console.log('ComponentDidMount()');
}
getFreelancerList() {
console.log('Freelancer List');
let self = this;
AsyncStorage.getItem('my_token').then((keyValue) => {
console.log('Master Screen (keyValue): ', keyValue); //Display key value
axios({
method: 'get',
url: Constants.API_URL + 'user_m/freelancer_list/',
responseType: 'json',
headers: {
'X-API-KEY': Constants.API_KEY,
'Authorization': keyValue,
},
})
.then(function (response) {
//console.log('Response Data: ', response.data.data); …Run Code Online (Sandbox Code Playgroud)