An open API service indexing awesome lists of open source software.

https://github.com/pawandubey/apkbuilder


https://github.com/pawandubey/apkbuilder

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

== apkbuilder ==

IMPORTANT: This project is currently the proof of concept and its API will probably change!

=== Introduction ===

Apkbuilder is a simple Java library, primarily for use with http://arquillian.org[Arquillian] to test Android applications.

=== Setup ===

In your `pom.xml`, just add the following dependency:

[source,xml]

org.arquillian.android
apkbuilder-api
1.0-SNAPSHOT

If you are using Android resources in deployed classes, make sure the +R+ class does not contain final fields. This behavior can by achieved by +android-maven-plugin+ specifying the parameter +aaptExtraArgs+ for goal +android:generate-sources+ with value +--non-constant-id+. By this way, +aapt+ will not make fields in generated +R.java+ final. It is recommended to create new Maven profile for testing purposes, in which you will specify this parameter as you should have final fields in production Android APK!

=== Usage ===

==== With shrinkwrap-android ====

If you are using +shrinkwrap-android+ library (recommended), +apkbuilder+ is a piece of cake to use. All you have to do, is to create an archive through +shrinkwrap-android+ and pass it into static +init+ method of +ApkBuilder+.

[source,java]
-------------------------------------
AndroidArchive archive = ShrinkWrap.create(AndroidArchive.class);

// add resources, classes and AndroidManifest

ApkBuilder builder = ApkBuilder.init(archive);

File finalApk = builder.build();
-------------------------------------

And that's it! Simple, isn't it? There is also configuration, which you can access through +ApkBuilder#getConfiguration()+.

==== Without shrinkwrap-android ====

Of course you can use +apkbuilder+ without using +shrinkwrap-android+. The process is very similar to the previous one, except you have to specify a directory with content, which you want to get built.

[source, java]
-------------------------------------
ApkBuilder builder = ApkBuilder.init("/directory/with/content");

File finalApk = builder.build();
-------------------------------------
It seems simple, but there's more you have to do. You have to follow predefined directory structure or the ApkBuilder will not be able to work.

[source,java]
-------------------------------------
/asset - Android assets
/res - Android resources
/class - .class files you want to include in the APK
/java - .java files you want to get compiled and then included in the APK
/AndroidManifest.xml - valid AndroidManifest.xml (this is required, otherwise the package will not be built)
-------------------------------------