找不到com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.浅谈MapBox的全新安装 [英] Could not find com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0. on fresh installation of MapBox

查看:254
本文介绍了找不到com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.浅谈MapBox的全新安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个全新的本机反应项目,并使用yarn add @react-native-mapbox-gl/maps添加了MapBox。

请注意,如果您使用的是默认的Mapbox Android SDK(与该库一起打包) 并使用较新的Android操作系统版本(API 30+), 您将遇到致命异常: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上启动了App。我收到以下错误:

找不到com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0. 需要满足以下条件: 项目:REACT-NATIVE-MAPBOX-gl_map>;com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0 在build.gradle文件中搜索

这是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' }
    }
}

失败:生成已完成,有8次失败。

%1:任务失败,出现异常。

  • 哪里出了问题: 任务":app:mergeDebugAssets"执行失败。
无法解析配置‘:app:debugRuntimeClasspath’的所有文件。 找不到com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0. 已在以下位置搜索: -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.pom 需要满足以下条件: 项目:APP>;项目:Reaction-Native-MapBox-gl_Maps>;com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0

  • 试试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。运行--扫描以获得完整的洞察力。 ==

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

我得了404.

推荐答案

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

将以下内容添加到allprojects/repositoriesandroid/build.gradle下的android/build.gradle

    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

这篇关于找不到com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0.浅谈MapBox的全新安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆