在 android studio 中导入 mapbox api 时出错

Error in Importing mapbox api in android studio

我已经创建了一个 android 地图,它根据从服务器发送的 n gps 数据给出了公交车的位置。最初它只显示来自服务器 api 的位置并将其发送到应用程序和应用程序只显示它..

现在我需要实现一个本地地图,它根据应用接收到的位置更新标记。 我发现了 mapbox api 并尝试使用它,但在编译时它给出了某些错误..任何人都可以帮助我清除它..

我的gradle.build(应用程序)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 22
    buildToolsVersion '24'

    defaultConfig {
        applicationId "com.juasoft.safebus"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.leo.simplearcloader:simplearcloader:1.0.+'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:recyclerview-v7:22.1.1'
    compile('com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE')
    compile 'com.github.amlcurran.showcaseview:library:5.4.3'
    compile 'com.github.gabrielemariotti.cards:library:1.9.1'
    compile 'com.google.firebase:firebase-core:9.0.2'
    compile 'com.google.firebase:firebase-messaging:9.0.2'
    compile 'com.github.clans:fab:1.6.4'

}
repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    // add the Mapbox SDK dependency below
    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.1@aar'){
        transitive=true
    }
}
apply plugin: 'com.google.gms.google-services'

错误:

****/app/build/intermediates/res/merged/debug/values-v23/values-v23.xml
Error:(4) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(33) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

v23/values-v23.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Base.TextAppearance.AppCompat.Widget.ActionBar.Menu" parent="android:TextAppearance.Material.Widget.ActionBar.Menu"/>
    <style name="Base.TextAppearance.AppCompat.Widget.Button.Inverse" parent="android:TextAppearance.Material.Widget.Button.Inverse"/>
    <style name="Base.Theme.AppCompat" parent="Base.V23.Theme.AppCompat"/>
    <style name="Base.Theme.AppCompat.Light" parent="Base.V23.Theme.AppCompat.Light"/>
    <style name="Base.V23.Theme.AppCompat" parent="Base.V22.Theme.AppCompat">
        <!-- We can use the platform styles on API 23+ -->
        <item name="ratingBarStyleIndicator">?android:attr/ratingBarStyleIndicator</item>
        <item name="ratingBarStyleSmall">?android:attr/ratingBarStyleSmall</item>

        <!-- We can use the platform drawable on v23+ -->
        <item name="actionBarItemBackground">?android:attr/actionBarItemBackground</item>
        <!-- We can use the platform styles on v23+ -->
        <item name="actionMenuTextColor">?android:attr/actionMenuTextColor</item>
        <item name="actionMenuTextAppearance">?android:attr/actionMenuTextAppearance</item>

        <item name="controlBackground">@drawable/abc_control_background_material</item>
    </style>
    <style name="Base.V23.Theme.AppCompat.Light" parent="Base.V22.Theme.AppCompat.Light">
        <!-- We can use the platform styles on API 23+ -->
        <item name="ratingBarStyleIndicator">?android:attr/ratingBarStyleIndicator</item>
        <item name="ratingBarStyleSmall">?android:attr/ratingBarStyleSmall</item>

        <!-- We can use the platform drawable on v23+ -->
        <item name="actionBarItemBackground">?android:attr/actionBarItemBackground</item>
        <!-- We can use the platform styles on v23+ -->
        <item name="actionMenuTextColor">?android:attr/actionMenuTextColor</item>
        <item name="actionMenuTextAppearance">?android:attr/actionMenuTextAppearance</item>

        <item name="controlBackground">@drawable/abc_control_background_material</item>
    </style>
    <style name="Base.Widget.AppCompat.Button.Colored" parent="android:Widget.Material.Button.Colored"/>
    <style name="Base.Widget.AppCompat.RatingBar.Indicator" parent="android:Widget.Material.RatingBar.Indicator"/>
    <style name="Base.Widget.AppCompat.RatingBar.Small" parent="android:Widget.Material.RatingBar.Small"/>
    <style name="Base.Widget.AppCompat.Spinner.Underlined" parent="android:Widget.Material.Spinner.Underlined"/>
</resources>

问题是因为您的编译SDK版本与支持库的主要版本不匹配。他们需要 两者 为 24 或 22。这应该可以解决错误。

附带说明一下,尽管此问题与 Mapbox 无关,但您可以通过将两个依赖项合并为一个来清理 build.gradle。它看起来像这样:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.leo.simplearcloader:simplearcloader:1.0.+'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile('com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE')
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.github.gabrielemariotti.cards:library:1.9.1'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.github.clans:fab:1.6.4'
testCompile 'junit:junit:4.12'

// add the Mapbox SDK dependency below
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.1@aar'){
    transitive=true
}
}