【问题标题】:add the osmdroid library via Android Studio (Gradle)通过 Android Studio (Gradle) 添加 osmdroid 库
【发布时间】:2020-03-24 19:03:03
【问题描述】:

我对移动开发很陌生,并尝试开发一个简单的 android 应用程序。对于我的项目,我需要 OSM(打开街道地图或更准确的 osmdroid。我尝试按照以下说明操作:https://github.com/osmdroid/osmdroid/wiki/How-to-add-the-osmdroid-library-via-Gradle 但不幸的是,这对我不起作用。我想我只是将代码插入了错误的位置。

这就是它现在所在的地方。这是“build.gradle (:app)”中的代码:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'org.osmdroid:osmdroid-android:(6.1.6)'
    implementation 'org.osmdroid:osmdroid-wms:(6.1.6)'
    implementation 'org.osmdroid:osmdroid-mapsforge:(6.1.6)'
    implementation 'org.osmdroid:osmdroid-geopackage:(6.1.6)'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

如果我尝试同步,这是错误消息:

FAILURE: Build failed with an exception.

 * What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not find org.osmdroid:osmdroid-android:(6.1.6).
     Required by:
         project :app
   > Could not find org.osmdroid:osmdroid-wms:(6.1.6).
     Required by:
         project :app
   > Could not find org.osmdroid:osmdroid-mapsforge:(6.1.6).
     Required by:
         project :app
   > Could not find org.osmdroid:osmdroid-geopackage:(6.1.6).
     Required by:
         project :app

 * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

 * Get more help at https://help.gradle.org

【问题讨论】:

    标签: android android-studio build.gradle openstreetmap osmdroid


    【解决方案1】:

    您应该从库版本中删除括号 所以而不是这个

    implementation 'org.osmdroid:osmdroid-android:(6.1.6)'
    implementation 'org.osmdroid:osmdroid-wms:(6.1.6)'
    implementation 'org.osmdroid:osmdroid-mapsforge:(6.1.6)'
    implementation 'org.osmdroid:osmdroid-geopackage:(6.1.6)'
    

    写这个

    implementation 'org.osmdroid:osmdroid-android:6.1.6'
    implementation 'org.osmdroid:osmdroid-wms:6.1.6'
    implementation 'org.osmdroid:osmdroid-mapsforge:6.1.6'
    implementation 'org.osmdroid:osmdroid-geopackage:6.1.6'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-04
      • 2015-12-15
      • 2013-10-11
      • 1970-01-01
      • 2016-02-10
      相关资源
      最近更新 更多