добавить библиотеку osmdroid через Android Studio (Gradle) - PullRequest
1 голос
/ 24 марта 2020

Я новичок в разработке мобильных приложений и пытаюсь разработать простое приложение android. Для моего проекта мне нужен OSM (открыть карту улиц или более точный osmdroid. Я пытался следовать этим инструкциям: https://github.com/osmdroid/osmdroid/wiki/How-to-add-the-osmdroid-library-via-Gradle, но, к сожалению, это не сработало для меня. Я думаю, что я просто вставил код в неправильный place. enter image description here

Это то место, где оно сейчас находится. Вот код, который находится внутри "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'
}

Если я пытаюсь синхронизировать c, это сообщение об ошибке:

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

1 Ответ

4 голосов
/ 24 марта 2020

Вы должны удалить скобки из версии библиотеки, поэтому вместо этого

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'
...