MapBox SDK 不工作 android

MapBox SDK not working android

我刚开始使用 MapBox SDK,但它不起作用我按照文档中的步骤操作,但我没有从他们的 SDK 中获得任何 类 这是我的代码:

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

<?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>

com.mapbox.mapboxsdk.telemetry.TelemetryService 显示为红色,我无法导入 MapboxAccountManager

我不知道是怎么回事,但是应用程序正在变得 运行 即使 gradle 构建因为 lint 而停止,我只是阻止了 lint 停止构建过程现在一切正常 :)

我知道这是一个老问题,但我在尝试从 Mapbox 4.x 更新到 5.x 时遇到了同样的错误,结果你必须更改:

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

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

更新: 在最新版本 (5.x) 中你根本不需要在 Manifest 中声明它,因为 Mapbox 现在使用 Manifest 合并功能。