【问题标题】:Mapbox sdk with androidx?带有androidx的Mapbox sdk?
【发布时间】:2021-05-30 08:07:23
【问题描述】:

根据https://docs.mapbox.com/android/maps/guides/install/添加所有依赖项后,当我尝试运行应用程序时出现此错误:

同步错误:

无法解决:legacy-support-core-utils-1.0.0 受影响的模块: 应用

构建错误:

任务“:app:compileDebugJavaWithJavac”执行失败。

无法解析配置“:app:debugCompileClasspath”的所有文件。 找不到 legacy-support-core-utils-1.0.0.jar (androidx.legacy:legacy-support-core-utils:1.0.0)。 在以下位置搜索: https://dl.google.com/dl/android/maven2/androidx/legacy/legacy-support-core-utils/1.0.0/legacy-support-core-utils-1.0.0.jar

可能的解决方案:

这是我的 build.gradle 模块级:

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.0"

    defaultConfig {
        applicationId "com.hamimap.android"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 2
        versionName "1.1"
    }

    buildTypes {
        release {
            minifyEnabled true
            debuggable false
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            debuggable true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.1'
}

这是我的 build.gradle 项目级:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        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'] ?: 'my secret token'
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

    标签: android mapbox androidx mapbox-android


    【解决方案1】:

    乍一看,您的 gradle 配置看起来还不错。 api 'com.theartofdev.edmodo:android-image-cropper:2.8.+' 和 Mapbox 依赖项之间可能不兼容。您是否尝试过删除依赖项以查看是否可以解决问题?

    另外,你是在 Kotlin 开发吗?如果是,你应该添加

    kotlinOptions {
            jvmTarget = '1.8'
        }

    到您的应用程序级别 build.gradle。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-04
      • 1970-01-01
      • 2022-08-03
      • 1970-01-01
      • 2019-05-15
      • 2020-12-17
      • 2021-08-15
      • 1970-01-01
      相关资源
      最近更新 更多