在android studio中导入mapbox api时出错

时间:2016-09-09 06:42:32

标签: android android-studio mapbox

我已经创建了一个android映射,它给出了从服务器发送的基于总线的n gps数据的位置。最初它只显示来自服务器api的位置并将其发送到应用程序,应用程序只显示它..

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

my gradle.build(app)

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 /值-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>

1 个答案:

答案 0 :(得分:1)

问题是因为您的编译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
}
}