This is ant android

Автоматическая сборка Android-проектов в Ant

Достался мне на новой работе в поддержку и разработку средних размеров проект Android приложения, которое контора планирует выпустить как дополнение к десктопной версии. После ознакомления с фронтом работ, руководство дало задание сделать автоматическую сборку realise-версии «в один клик». До этого все мои проекты прекрасно собирались в IDE, а предстояло сделать безИДЕшную реализацию, поэтому пришлось пройти путь граблей и шишек. Соли добавляло обстоятельство что в проекте используется зависимость от ActionBarSherlock (Maven-проект, apklib).

Аутсорсеры, делавшие проект до меня, использовали Intelij IDE, я же в основном использую в работе NetBeans и Eclipse. Открыть и собрать проект в Eclipse не составило особого труда, только путь к ABS пришлось указать. Компиляция, сборка и запуск готового apk прошла без проблем. А вот с NetBeans такой фокус не прошел. Он упорно отказывается принимать ABS как библиотеку. Погуглив, выяснилось что это баг в НетБинс (к примеру как тут у человека), нашел даже тикет на официальном багрепорте. Так же нашел парочку способов собрать из под НетБинса (изменение pom.xml, копирование исходников ABS в папку основного проекта), но они мне не подходили (дана была четкая установка сделать так, чтобы зависимости основной проект вообще брал с внешнего репозитория и никак не влиял на них).

Поигравшись с IDE, начал реализовывать автосборку. Гугление вывело на эту и эту статью. После нескольких экспериментов был написан такой мануал:

1. Устанавливаем (вдруг у кого не стоит) JAVA_HOME и ANDOID_HOME (к примеру C:\Program Files (x86)\Java\jdk1.7.0_07 и D:\android\android-sdk)
2. Устанавливаем в Path пути к Android tools и Ant (у меня Ant отдельно, последняя версия). Что-то вроде такого должно быть
D:\android\android-sdk\tools;D:\android\android-sdk\platform-tools;D:\android\android-sdk\bin;D:\android\apache-ant-1.9.0\bin
3. Для ленивых открываем проект в NetBens, он создаст основные файлы, для остальных выполняем команду android rebuild , она должна создать необходимые файлы.
4. Поскольку собираем realise-версию, ложим наш файл key.keystore (или как он у вас называется) в папку проекта. В файл ant.properties добавляем:

key.store=key.keystore
key.alias=mykey
key.store.password=pass1
key.alias.password=pass2

5. В project.properties добавляем пути к нашей apklib-зависимости:

android.library.reference.1=../ActionBarSherlock
android.library=false

Сама папка проекта ABS лежит рядом с папкой нашего проекта.

6. Если нужно запускать ProGuard, в том же файле пишем (или раскомментируется):

6. Поскольку у меня задача была сделать сборку «в один клик», создаем батник с содержимым:

echo Build
call ant release
pause

(первая и последняя строчки опционально)

Итогом мы должны получить такую структуру проекта:

ActionBarSherlock/
src/
res/
bin/
libs/
pom.xml
AndroidManigest.xml

Читайте также:  Автомобильный режим для андроид

MyProject/
src/
res/
bin/
jni/
libs/
project.properties
ant.properties
build.xml
build.bat
AndroidManigest.xml

Если все сделано правильно, по нажатию на батник мы увидим консоль сборки

Источник

ANT Forum

Welcome guest, please Login or Register

Getting Started with Development of ANT+ Android Apps

31 March 2011 11:49 AM

Total Posts: 140

Joined 2008-12-09

If you are new to ANT and ANT+, the following post contains several useful resources to learn about the protocol, as well the different development tools that are available. While most of the information is aimed towards development of PC applications, the concepts are the same and will help you ramp up on ANT.
http://www.thisisant.com/component/option,com_fireboard/Itemid,146/func,view/catid,25/id,1169/

You can find the Android API for ANT, along with a list of supported handsets, here
http://www.thisisant.com/pages/developer-zone/android-api

Decoding raw ANT messages corresponding to a device profile requires bitwise operations and unsigned arithmetic. Java does not have unsigned types, so keep this in mind when developing your app.

Signature

For a complete list of frequently asked questions and answers, please view the FAQ user profile by clicking on the FAQ user name.

16 January 2012 03:23 AM #1

Total Posts: 524

Joined 2012-11-15

13 March 2012 09:27 AM #2

Total Posts: 0

Joined 2012-11-29

I found in the document «ANT+ Device Profile/Heart Rate Monitor» some helpful code snippets. Helpful because they make things easy to understand. Less helpful because they’re written in C, whereas I’m writing an App for Android and therefore use the Android API in Java.

Question now comes down to one thing: How do I implement the «WaitAck» C-function you use in the snippet on page 10, figure 3? Is there a similar method in the Java interface? Which?

A first example to get heart rate from a Garmin belt is running but does not look very stable, so I need further assistance to get into a good working state.

Thank you for your help!
Juergen

13 March 2012 09:32 AM #3

Total Posts: 662

Joined 2012-10-09

The code snippets in the device profile document are outdated, and will be removed in the next release.

Please refer to the source code of ANTPlusDemo (included with the Android SDK) for an example of decoding heart rate using the Android API.

13 March 2012 01:39 PM #4

Total Posts: 0

Joined 2012-11-29

Hmmm, that explains a lot.

It took me more than a week to even roughly understand, what the Demo-Code does. AntPlusManager.java is the central implementation and with over 1.700 lines of code it is really really difficult to read.
For a Demo App it’s a problem. A Function to wait for acknowledge would help a lot.

Any ideas how to implement such? Especially with Android and its single-threaded model?

Any ideas welcome.

14 March 2012 05:03 AM #5

Читайте также:  Файл apk для обновления андроида

Total Posts: 117

Joined 2010-10-25

Android is not single threaded. As said previously the demo code is the way to go but I think you need to improve your Android understanding as well. Coming from an old style C coding style Android is quite a big learning curve I would recomend going though some of that Android tutorials.

14 March 2012 03:26 PM #6

Total Posts: 0

Joined 2012-11-29

You’re maybe right. I hope I never stop to learn.
This time I would like to learn more about the ANT API for Android, than about Android itself.

Has anybody a good explanation for these pairs of statements:
init/releaseService, claim/releaseInterface, assign/unassignChannel, open/closeChannel and enable/disbale?

What are they doing internally? When does the designer expect they’re called?

15 March 2012 07:56 AM #7

Total Posts: 213

Joined 2011-05-02

Prior to starting, I suggest taking a look here. It gives you everything you need to know to get started with Android.

As for open/close channel etc., these details can be found in ANT Message Protocol and Usage.

For more information on the claim/release interface and enable/disable etc, you will need to look at the documentation accompanying the Android SDK. The Android SDK can be found here.

I strongly recommend becoming familiar with Android, how it works, etc before jumping right into the ANT API. There are some really great ‘Hello, Android’ tutorials available on the site mentioned above to help get you familiar with the various aspects of Android development.

Источник

Developing ANT in Android

The Android ANT SDK and Android ANT+ SDK make it simple for developers to connect ANT and ANT+ devices to Android.

Universal Mobile Connectivity:

Adding ANT or ANT+ communication to Android app development allows apps to monitor and control ‘the real world’. Android ANT and ANT+ SDK features include:

  • Allows apps to extend across all smartphone vendors without fragmentation across Android versions
  • Android smartphones can network with sensors, displays, PC’s, bike computers, watches, tablets and other phones simultaneously
  • All apps can work seamlessly with manufacturer-enabled ANT+ handsets (60 million currently) as well as with Android devices utilizing the USB Host feature (via an ANT USB)
  • Services, plugins, apps and sample apps are available from the Google Play store

Android ANT SDK

READY TO GET STARTED?

The Android ANT SDK enables developers to connect Android apps to ANT devices. It is provided to allow you to connect to proprietary devices and build complex topologies utilising advance ANT features such as background scanning and phone-phone applications.

Note that if you are developing apps to connect to ANT+ devices, it is strongly recommended that you use the Android ANT+ SDK.

Android ANT+ SDK

READY TO GET STARTED?

Building an Android app to take advantage of your ANT+ sensors makes it easy for consumers to use and share their data. The Android ANT+ SDK (notice the ’+’!) enables developers to connect Android apps to ANT+ devices and take advantage of the interoperable sports, fitness and wellness data available from more than 60 million ANT+ devices owned by consumers today. The Android ANT+ SDK includes the ANT+ plugins which remove the need for developers to understand the ANT protocol (i.e. the ANT+ Network Key and ANT+ channel parameters are built into the ANT+ plugins).

Читайте также:  Айфон не подключается блютуз андроид

Implemented Profiles:

The ANT+ Android SDK is designed to allow the ANT+ API to grow dynamically. ANT+ plugins will be continually added to support all current and future ANT+ device profiles.

The Android ANT+ SDK version P.B2 includes plugins for these ANT+ device profiles:

Note that ANT+ Members can also download the member early release Android ANT+ SDK version P.B2. MO1, which also contains support for FE-C.

If you need to use the ANT+ network for an application not yet covered by the ANT+ plugins please contact us.

ANT+ Certification:

Certify your app for authorization to brand and market it as ANT+ compatible. Type 1 certification should be used for new apps, and type 2 for variations on apps that have previously been certified. Software certification is quick and inexpensive, verifies ANT+ compliance, and provides a listing on the ANT+ Product Directory; – a great tool to promote your app to consumers, brands and other partners.

ANT+ Plugins enable concurrent Multi Sensors, Multi Apps:

The Android ANT+ SDK is designed so that apps can use data from any device at the same time. Data can be real time or stored, sent or received.

Use Case Examples:

1. Someone using an ANT+ continuous glucose monitor can utilize their device 24/7 and will not have to exit or stop their app in order to add for example a Heart Rate monitor while heading out for a run. That same person could also be monitoring their heart rate and pace on separate applications simultaneously. All of these data sets can be tracked independently — to monitor progress or share with workout buddies.

2. Someone tracking their run data on a fitness app, can also listen to music on a separate app using the ANT+ Controls Device Profile. The app can send data such as the track title and elapsed time to an ANT+ watch with ANT+ Controls capability which can also be used to send back volume control and next track commands.

Intro Video

This is the video that was created when the ANT+ plugins were first launched, and it still gives a good overview of the Android ANT and ANT+ SDKs.

Источник

Оцените статью