Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

You are here: Forum Home → ANT+ Forums → ANT+ Heart Rate Monitor → Thread

   

Sample code to be used in IntelliJ?

Rank

Total Posts: 5

Joined 2017-01-24

PM

I've got an ANT+ compatible heart rate monitor. I haven't been able to find an app that does exactly what I want it to, so I'm wanting to play around with writing my own. I have a Android (galaxy s7).

I've started playing around with Android app development and I've created the little hello world app using Android Studio (which appears to use JetBrains IntelliJ).

I see there is sample code for ANT+ but it appears to use Eclypse, which I am totally unfamiliar with. Are there any ANT+ sample code projects that use IntelliJ? One that is based on a heart rate monitor would be even better!

Thanks.      
Rank

Total Posts: 14

Joined 2012-09-04

PM

Hi DeanHensler,

Android Studio (https://developer.android.com/studio/index.html) will happily convert existing Eclipse projects into IntelliJ format for you. After extracting the sample code, you can follow the instructions here to convert them into the proper format: https://developer.android.com/studio/intro/migrate.html - Migrating from Eclipse

-Mike      
Rank

Total Posts: 5

Joined 2017-01-24

PM

I'm trying to import the ANT+ Plugin Sampler that comes with the ANT+ Android SDK. I'm getting an error on the last step:

* Project AntPlusPluginSampler:C:\ANT Development\ANT+_Android_SDK\Sample\ANT+ Plugin Sampler\source\project.properties:
Library reference ..\AntPluginLib could not be found
Path is C:\ANT Development\ANT+_Android_SDK\Sample\ANT+ Plugin Sampler\source\..\AntPluginLib which resolves to C:\ANT Development\ANT+_Android_SDK\Sample\ANT+ Plugin Sampler\AntPluginLib

The ANT+ Android SDK appears to come with a antpluginlib_3-5-0.jar file. I tried renaming that to AntPluginLib.jar and placing it in the C:\ANT Development\ANT+_Android_SDK\Sample\ANT+ Plugin Sampler\ folder and then tried to import the project again, but I still get the same error.

It kind of seems like the ANT documentation on this website is our of date. I tried to read through the Android Apps Workshop documentation but it's all based on Eclipse as well. It kind of feels like the Android Studio used to be in Eclipse and now it's in IntelliJ?

Any help would be appreciated. I would love to get the ANT+ Plugin Sampler app working in IntelliJ (Android Studio)      
Rank

Total Posts: 14

Joined 2012-09-04

PM

Hi DeanHensler,

I downloaded the latest AntPlus_Android_SDK_v.P.B4.zip from the website and imported the project into Android Studio 2.2. Here are the steps I went through:

1. Import an existing project (Eclipse, ADT etc)
2. Accept default choices - instead of choosing importing project from external model "Gradle", I just picked "importing existing source code".
3. The import project wizard may prompt you to select where the source files are located, I picked the actual directory where they are located, namely ..\Sample\ANT+ Plugin Sampler\source\src, while leaving ..\Sample\ANT+ Plugin Sampler\source unchecked. (attachment: 1.png)
4. Accept default selection for the rest of the import steps. (attachment 2.png)
5. When you're in the project view, right click on the module icon in Project subpane and open module settings (or hit F4)
6. Navigate to Modules -> Dependencies subpane, then click '+' in the list then add antpluginlib_3-5-0.jar and fit_14.10.jar to the project and it should build. (attachment: 3.png)

I think the AntPluginLib.jar in project.properties is probably meant to be a reminder or placeholder to add reference to any version of the AntPluginLib jar library.
     

Image Attachments

1.png2.png3.png

Click thumbnail to see full-size image

Rank

Total Posts: 5

Joined 2017-01-24

PM

Michael,

Thank you so much for the detailed instructions. I started over and followed them and I've got the project loaded just as you did. I believe the problem is that I was trying to use Gradle rather than just importing the existing code. But now I'm on to the next problem. With my Hello World app I created in Android Studio I could hook my ANT+ enabled phone to my computer with a USB cable and run the Hello World app from Android Studio on my phone. Without Gradle how can I do this with the ANT+ Plugin Sampler project?

Your help is greatly appreciated.      
Rank

Total Posts: 14

Joined 2012-09-04

PM

No problem at all.

I suppose adb sees your phone given that it has the proper adb usb driver installed. So you should see logs coming from your phone into logcat (you can find them in 'Android monitor' subpane of Android Studio).

Certain version of android may connect the phone in PPT mode, you can go to settings -> storage -> usb connection and change it to Camera mode so that adb can detect the device. After building the project, hit the play button, then select your phone from the list that pops up (assuming that adb sees your device) to install the apk to it. When installation completes, the app should be shown in foreground and you can start playing with it. This should work the same as your Hello World App.

Additional info, in case you want to use gradle instead:
1. select import from existing project (Eclipse, etc)
2. pick import from external model "Gradle"
3. While selecting the source code directory of the project, do not choose the top level directory "ANT+ Plugin Sampler", instead navigate into this directory and choose "source"
4. Do anything to make the import wizard happy, mine nagged about AntPluginLib.jar missing, so I removed that line from project.properties then accept all default options.
5. At the project window, hit F4 to open module settings then add all of the necessary jar references, namely: android-support-v4.jar, antpluginlib_<version>.jar and fit_16.00.jar. Note that the jars need to be placed somewhere within the project directory, so I made a libs subdirectory within source. The first image shows how my gradle file looks like.

Note: If you want a better name for the directory instead of 'source', you can rename the source directory to something else before starting step 3.

Hope this works for you.      

Image Attachments

4.png

Click thumbnail to see full-size image

Rank

Total Posts: 5

Joined 2017-01-24

PM

Thanks so much Mike! Working like a dream now!      
Rank

Total Posts: 14

Joined 2012-09-04

PM

Sweet, glad to be able to help smile