mapbox / mapbox-java

The Mapbox Java SDK – Java wrappers around Mapbox APIs and other location data
https://docs.mapbox.com/android/java/overview/
MIT License
415 stars 121 forks source link

Could not find androidx.annotation:annotation:1.0.0. #1140

Closed MalcolmScoffable closed 4 years ago

MalcolmScoffable commented 4 years ago

I'm attempting to use the latest version of this library for geocoding in a Kotlin based Spring Boot application. I can import the package 'mapbox-sdk-services' fine via Gradle (and Maven), however my application won't compile due to the following error:

Could not resolve all files for configuration ':compileClasspath'.
   > Could not find androidx.annotation:annotation:1.0.0.
     Required by:
         project : > com.mapbox.mapboxsdk:mapbox-sdk-services:5.1.0 > com.mapbox.mapboxsdk:mapbox-sdk-directions-models:5.1.0
         project : > com.mapbox.mapboxsdk:mapbox-sdk-services:5.1.0 > com.mapbox.mapboxsdk:mapbox-sdk-directions-refresh-models:5.1.0

It appears as if there is perhaps some dependency on Android libraries in here, as far as I know it shouldn't really matter that I'm using this in a Kotlin based application, rather than pure Java. Has anyone come across this issue, or am I perhaps misunderstanding something from the documentation. I am going to try older version of the library, but am a bit stuck with this one now.

Any help with this would be really appreciated.

MalcolmScoffable commented 4 years ago

Ok, so managed to fix this by including the following in my build.gradle:

repositories {
    ...
    google()
    ...
}

...

dependencies {
...
compile('androidx.annotation:annotation:1.0.0')
....
}

So, the main issue seems to have been the that androidx.annotation lib wasn't being found from the standard Maven repo... and I needed to include the Google repos. This is all fine, but there was nothing in the documentation to indicate this. The documentation also suggests that this library doesn't rely on any Android libraries - which is clearly not the case. Perhaps this should be updated. Not sure if this is correct though? Would be good to get feedback on this. I don't mind updating the documentation but want to make sure I am correct in thinking the above, and also aware that using this from Kotlin in a Spring application isn't really that normal....

tobrun commented 4 years ago

Perhaps this should be updated.

Yes, we should clarify that we don't rely on any Android SDK APIs but do use AndroidX annotations.

using this from Kotlin in a Spring application isn't really that normal

That is a totally valid use-case!

langsmith commented 4 years ago

Closing because https://docs.mapbox.com/android/java/overview/ has been updated to mention AndroidX annotations. @MalcolmScoffable's project is working. I don't think there are other actionable items at this point, but if anyone disagrees, please re-open and comment.

Thanks for the ticket, @MalcolmScoffable.

HosseinKurd commented 3 years ago

Same issue.