简体   繁体   English

MapBox SDK无法正常工作

[英]MapBox SDK not working android

I just started to use the MapBox SDK but its not working I was following the steps on the documentation but Im not getting any classes from their SDK here is my code: 我刚开始使用MapBox SDK,但无法正常工作,我正在按照文档中的步骤进行操作,但是我没有从其SDK中获取任何类,这是我的代码:

build.gradle build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.mapp.hello"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    mavenCentral()
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.2@aar'){
        transitive=true
    }
}

AndroidManifest.xml AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.mapp.hello"
          xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>
    </application>

</manifest>

The com.mapbox.mapboxsdk.telemetry.TelemetryService is shown in red and I cannot import the MapboxAccountManager com.mapbox.mapboxsdk.telemetry.TelemetryService显示为红色,并且我无法导入MapboxAccountManager

I know it's an old question, but I just had the same error while trying to update from Mapbox 4.x to 5.x and it turns out you have to change: 我知道这是一个古老的问题,但是在尝试从Mapbox 4.x更新到5.x时遇到了同样的错误,结果您必须进行以下更改:

<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>

to

<service android:name="com.mapbox.services.android.telemetry.service.TelemetryService" />

Update : Turns out in the latest version (5.x) you don't have to declare it in the Manifest at all, as Mapbox now makes use of Manifest merge feature. 更新 :有了最新版本(5.x),您根本不需要在清单中声明它,因为Mapbox现在使用了清单合并功能。

我不知道怎么办,但是即使gradle生成由于皮棉而停止,应用程序也正在运行,我一切都正常了,只是停止了皮棉停止生成过程:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM