Build android with ant

Автоматическая сборка 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

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

Источник

Build android with ant

This repository provides instructions on how to integrate ANT support into an Android platform build, and is targeted towards device manufacturers looking to add ANT support into their Android devices.

How to Add ANT to Android

Before you begin, talk to your chipset vendor to ensure your chip is ANT capable, and to obtain ANT enabled firmware as well as any other chip-specific customizations you may require.

  1. Clone this repository locally.
  2. Copy the appropriate manifest, into the .repo/local_manifests/ directory of your Android Platform source, creating the local_manifests directory if needed. The following manifests are available:
    • ANT_manifest.xml — This is the recommended package for most platforms as it pulls in the latest stable components of the ANT Android System Layer.
    • ANT_hidl_preview_manifest.xml — This package pulls in versions of the components that have been modified to be treble-compatible. Should be used when developing for android 8.0+
    • Android_System_Package_2-3-0 — This package is ideal for adding ANT to Android 4.1.2 using chipsets that do not have a dedicated ANT channel (see System under Components, below). This package is available under legacy/android-4.1.2_r1/.
  3. Execute repo sync in a shell. This will pull in the following components into your platform:
    • ANT HAL
    • ANT HAL Service
    • ANT Radio Service
    • ANT+ Plugins Service
Читайте также:  Создание внешней компоненты 1с android

See «Components» section below for more details. 4. Verify that ANT was synced by checking if the directory external/ant-wireless/ exists.

Configure ANT to build:

i. Add the following to device/ / /BoardConfig.mk :

Where is the chipset code provided to you by your chip vendor. Note the double quotes in the above line, they are important to include. This step is not nescessary if using the hidl-preview.

ii. Add the following to device/ / /device.mk :

Add ANT as an airplane mode radio:

  1. Copy ToggleableANTRadio.patch from the ANT In Android repository, from under android_patches/airplane_mode into frameworks/base/ .
  2. In frameworks/base/ :

Apply any other customizations required for proper operation on your device such as:

  • Proprietary firmware scripts
  • Integration with Bluetooth stack
  1. Build the system following your platform’s build steps.
  2. Verify that ANT functions:

    Check that ANT built. After a build has been performed, the following should be present in the resulting image:

    • /system/lib/libantradio.so
    • /system/app/AntHalService.apk
    • /system/app/ANTRadioService.apk
    • /system/app/AntPlusPluginsService.apk
    • /system/xbin/antradio_app (on debug builds)

    Test ANT functionality.

    1. Test basic ANT communication by executing antradio_app .
    2. Validate ANT functionality by running through the ANT Validation Procedure. Contact Dynastream Innovations for the latest ANT Verification Package.

This section describes the components that make up an Android build with ANT support.

These components are the underlay of the ANT Software stack, and are necessary for ANT support. ANT Wireless does not provide these components.

  • Chipset — ANT support can be added to devices using one of many ANT enabled multi-mode communication chipsets. Ask your chip vendor about which chips support ANT.
  • Firmware — Proprietary firmware scripts (or custom kernel modules for certain chips) are required for all supported chipsets. Ask your chip vendor for ANT enabled firmware for your chipset.
  • Android OS — ANT support is available for Android Platform Version 2.1 and greater.

ANT Wireless provides an open source implementation of this layer which is suitable for most devices. Some chipsets require a custom implementation of this layer as they do not provide a dedicated ANT channel. For such chipsets, integration with the Bluetooth stack is required to communicate with and control the chip. Talk to your chipset provider for more details.

  • Legacy Compatibility Library — This library is required to be installed in system builds that support ANT. Its presence in the system indicates built-in ANT support for some compatibility checks, specifically for apps using the legacy AntLib interface.
  • Airplane Mode Patch — ANT radio requires wireless signal transmission and so should be added to the airplane mode radios list. We recommend ANT also be added to the airplane mode toggleable radios list to allow ANT to behave in the same way as Wi-Fi in that ANT is disabled when Airplane mode is turned on, but can be re-enabled subsequently by the user. Apply the ToggleableANTRadio.patch to enable suggested airplane mode behaviour, or the Non-ToggleableANTRadio.patch to add ANT to only the airplane mode radios list.
  • ANT HAL — This C library communicates with the firmware to send and receive messages as well as control the chipset.
  • ANT HAL Service — This Android application is a JNI wrapper for ANT HAL.
Читайте также:  Как отменить подписку мульт андроид

These are applications that will be pre-installed on your device to allow Android Applications that use ANT and ANT+ technology to operate using an easy to use API. These applications are also available through the PlayStore and are not required to be system applications.

  • ANT Radio Service — This Android service allows apps to use a simplified interface to communicate using the ANT protocol.
  • ANT+ Plugins Service — This Android service allows apps to use a simplified interface to communicate using ANT+ Profiles.

Источник

Android Ant Build

I would like to build two versions of my Android application using an Apache ant file. The problem is, that both versions are identical except the advertisement in the lite version. I read about using Configurations with ant to build debug versions.

The following class defines some constants that can be referenced within the application.

And here is an example on how to use this constants to determine if logging is enabled or not.

Now i can enable and disable logging in my properties file.

That does not work, because before using this config I have to create a second config file and use filterset and copy.

That’s pretty easy, but how I could use this to build two versions of my application with and without advertisement. And how could I change the package names using ant, so the android market would accept both packages (Full and Lite).

Thank you, for your suggestions, but I still have some problems.

I managed to write some basic targets that cleanup my builds and copy all files needed to build the application in two folders /full and /lite. So I have two directories with the same content. Now I rename all matches of the applications package name in all *.java files and the AndroidManifest file (target prepare).

To really build two different version I would now have to include the code from my first post. But how do I have to do this and how can I build both versions in the release target and write the resulting *.apk files into the build directoy?

Finally . Would that be all I have to do to build running *.apks that would be accepted by the android market?

Источник

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
Читайте также:  Прошивка для андроида lg e612

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.

Источник

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