Getting started with Strava API for Android

319 views
Skip to first unread message

klam...@gmail.com

unread,
Jan 23, 2019, 12:33:43 AM1/23/19
to Strava API
Hi everyone!

I'm trying to create a kind of dummy-app just to practice using Strava's API with Android and I'm having issues getting it set up to the point where I can even write the "import com.strava.api.v3.*" into my code. Where I'm at it says "cannot resolve symbol 'strava'". I've downloaded and installed swagger-codegen just as the api documentation prescribes. I've done all the steps to run swagger and generate the API and I've got the file structure with folders "api", "auth", "model", and a variety of API-related .java files, as well as more API-related .java files within the three folders. I'm just not sure where to put these/what to do with them so that I can use the import statement and include them in my project? All the tutorials I've seen about installing APIs imply that I need a .jar file but following the instructions that Strava gave I only ended up with .java files.

Has anyone gone through this process and knows where I'm going wrong?

Many thanks!

Ronan Maron

unread,
Jan 23, 2019, 2:45:37 AM1/23/19
to strav...@googlegroups.com

Hello,

You need to compile your Java files.

Ronan

--
You received this message because you are subscribed to the Google Groups "Strava API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strava-api+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

klam...@gmail.com

unread,
Jan 23, 2019, 3:58:52 PM1/23/19
to Strava API
Thank you! I assume this is compiling into the .jar file that I need? How exactly do I do this? Below are the files that I have, how exactly do I put all of them into a single .jar file?

Ronan Maron

unread,
Jan 23, 2019, 4:19:36 PM1/23/19
to strav...@googlegroups.com
It's called packaging:
https://docs.oracle.com/javase/tutorial/deployment/jar/

Personally I use an IDE (Spring Tool Suite 4) in which I import the
source files generated by Swagger Codegen and then export the project to
JAR file.

George Shafik

unread,
Jan 23, 2019, 4:36:55 PM1/23/19
to Ronan Maron, strav...@googlegroups.com
Hey Ronan,

Hope you're doing well.

Please send me the tutorial link or material you are working from and I’ll see what I can do from my end.

Also, do you have a git repository you can share publicly so I can make/recommend changes to your codebase ?

Cheers,
George

Ronan Maron

unread,
Jan 24, 2019, 6:08:34 AM1/24/19
to George Shafik, strav...@googlegroups.com

Hi George,

I don't have a tutorial link to share. All I can say is starting an app with Stava API is done in 3 steps :


1. Generating a Strava API Client with Swagger Codegen

swagger-codegen generate -i https://developers.strava.com/swagger/swagger.json -l java -o strava-api-client

You may want to use other options.


2. Packaging the API client (with Maven or Gradle)

mvn package in the directory generated during the first step.

Be careful, you'll probably have to had 1 dependency or more.


3. Adding the Strava API Client JAR to the dependencies of your project (probably with Gradle if you work on an Android app)


I hope it'll help you starting your project.

You don't share anything publicly yet. I'm working on a web app automaticly generating routes using segments for MTB or road bike.


Cheers,

Ronan

George Shafik

unread,
Jan 24, 2019, 3:14:08 PM1/24/19
to Ronan Maron, strav...@googlegroups.com
Hi Ronan,

The main reason for asking for the source and associated jar files was to see how your manifest file was configured, specifically the Main-Class and Class-Path parameters.

Generating the API Client side interface from Swagger on great approach!

Not sure if you have this  link, it  comes with some useful sample code supporting the Strava API

Please keep me posted on your progress as I am scheduled to update my fitness tracker application over the next few weeks for both iOS and Android devices.

Cheers,
George

Gabriel Landais

unread,
Jan 24, 2019, 3:56:23 PM1/24/19
to George Shafik, Ronan Maron, Strava API
Hi!
Is there not any java strava lib compatible with android on maven central? Just add it to your gradle thingy and you're done (you'll have to code at least an android activity anyway... And handle the infamous oauth flow with applications urls!)

Anyway, handling the strava api on the device sounds terrible to me. As soon as you change or reset your phone (it's android right?), the user will have to restart from scratch. I think that a PWA (progressive web application) is the right way to do things, with a server part handling all the real time updates, computations or notifications. Think about iPhone and desktop users, will you redevelop your application three times?
You may check the stravalib flask sample and deploy it to Google appengine.

Disclaimer : I'm a pro dev using Kafka/Cassandra/Spring Boot/kubernetes everyday for my work but using a python3/stravalib/numpy/mongodb/kafka/redis/docker stack for a hobby project : www.brevets.bike

Regards
Gabriel


George Shafik

unread,
Jan 24, 2019, 4:21:28 PM1/24/19
to Gabriel Landais, Ronan Maron, Strava API
Hi Gabriel,

Firstly and formost I prefer developing natively on each device. Far too many bad experiences with other frameworks like React and Xamarin that I will not go into in this post.
If you are supporting mobile applications in production I highly recommend you stick to the hardware vendors native supported language.

Your point in abstracting functionality out for reuse across a number of devices is a sound engineering design practise. My approach addressing this key requirement is to extend my REST/SOAP APIs complementing those provided by third parties like Strava.

Cheers,
George

Gabriel Landais

unread,
Jan 24, 2019, 4:40:18 PM1/24/19
to George Shafik, Ronan Maron, Strava API
I agree!
If you have the budget, go native.  But in anycase, try to get a backend callable through APIs. All pages from www.brevets.bike are generated from json available on api.brevets.bike on same path!

George Shafik

unread,
Jan 24, 2019, 5:04:18 PM1/24/19
to Gabriel Landais, Ronan Maron, Strava API
Unfortunately the misalignment with frameworks like React and Xamarin is intentional, no accident, forms a core business strategy that good software engineers often get burnt on at the 11th hour.
So find the money as quick as you can, as it can derail a brilliant app if left uncheck for too long.

On a separate note Gabriel and Ronan :-)
I am a big fan of mountain bike riding, personally ride s Cannondale lefty whenever I can find the time.
If you're ever in Australia Melbourne, flick me a email and more than happy to test your app live at Lysterfield or You Yangs.
Can even organise bikes on the day from the folks at bikeNow,com.au in case you are travelling light.

Cheers,
George
Reply all
Reply to author
Forward
0 new messages