gpt4 book ai didi

android - 找不到 com.mapbox.mapboxsdk :mapbox-android-accounts:0. 7.0。全新安装 MapBox

转载 作者:行者123 更新时间:2023-12-01 23:15:39 49 4
gpt4 key购买 nike

我建立了一个新的 react-native 项目并使用 yarn add @react-native-mapbox-gl/maps 添加了 Mapbox。

这个

Notice, that if you're using the default Mapbox Android SDK (which is packed in with this lib)and are on newer Android OS version (API 30+),you'll encounter Fatal Exception: java.lang.SecurityException: getDataNetworkTypeForSubscriber.

据我了解不适用,因为我的目标是 Android 上的 API 29。另外,这不是我遇到的错误。

我添加了提供的演示代码

import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import MapboxGL from '@react-native-mapbox-gl/maps';

MapboxGL.setAccessToken('<YOUR_ACCESSTOKEN>');

const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
container: {
height: 300,
width: 300,
backgroundColor: 'tomato'
},
map: {
flex: 1
}
});

export default class App extends Component {
render() {
return (
<View style={styles.page}>
<View style={styles.container}>
<MapboxGL.MapView style={styles.map} />
</View>
</View>
);
}
}

并在 Android 上启动应用程序。我收到以下错误:

Could not find com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.Required by:project :react-native-mapbox-gl_maps > com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0Search in build.gradle files

这是app/android/build.gradle

buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
}
}

allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
url("$rootDir/../node_modules/react-native/android")
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
maven { url 'https://www.jitpack.io' }
}
}

FAILURE: Build completed with 8 failures.

1:任务因异常而失败。

  • 出了什么问题:任务“:app:mergeDebugAssets”执行失败。

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.Could not find com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.Searched in the following locations:- https://repo.maven.apache.org/maven2/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom- file:/Users/macosx/.m2/repository/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom- file:/Users/macosx/Documents/mapstar-current/MapStar/node_modules/react-native/android/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom- file:/Users/macosx/Documents/mapstar-current/MapStar/node_modules/jsc-android/dist/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom- https://dl.google.com/dl/android/maven2/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom- https://www.jitpack.io/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pomRequired by:project :app > project :react-native-mapbox-gl_maps > com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。================================================ ============================

当我点击提供的链接时 https://repo.maven.apache.org/maven2/com/mapbox/mapboxsdk/mapbox-android-accounts/0.7.0/mapbox-android-accounts-0.7.0.pom

我得到一个 404...

404

最佳答案

我不确定为什么(可能是因为 react-native-mapbox-gl 正在更新),this需要添加到您的代码中:

将以下内容添加到 android/build.gradle 部分 allprojects/repositories

    maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}

从这里得到这个提示https://github.com/react-native-mapbox-gl/maps/issues/1501#issuecomment-906158991

关于android - 找不到 com.mapbox.mapboxsdk :mapbox-android-accounts:0. 7.0。全新安装 MapBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68934036/

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