https://github.com/pawandubey/apkbuilder
https://github.com/pawandubey/apkbuilder
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pawandubey/apkbuilder
- Owner: pawandubey
- Created: 2014-05-22T10:56:46.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-01-03T12:57:36.000Z (almost 12 years ago)
- Last Synced: 2025-02-15T16:43:15.573Z (8 months ago)
- Language: Java
- Size: 223 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.asciidoc
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)
-------------------------------------