Skip to content

Omarorj3/apkbuilder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 Arquillian to test Android applications.

Setup

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

<dependency>
	<groupId>org.arquillian.android</groupId>
	<artifactId>apkbuilder-api</artifactId>
	<version>1.0-SNAPSHOT</version>
</dependency>

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.

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.

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.

/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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%