3

I have two .so files that I need to be packaged with an apklib, with this structure:

- libs
-- armeabi
--- libvinit.so
-- armeabi-v7a
--- libvinit.so

I know I can use install-file to upload this to my local repo and declare them as dependencies in my pom, but the problem is that they have the same name, and are inside different folders, which is important. How do I ensure that when Maven packages the apklib that this structure will be enforced?

Jason Robinson
  • 31,005
  • 19
  • 77
  • 131
  • Do you need to have just one release artifact? Why not have two different builds, one for each architecture? – noahlz Apr 15 '13 at 02:09
  • @noahz Yes, just one release artifact. This is for an APK (Android executable). – Jason Robinson Apr 15 '13 at 07:14
  • Why do you need both architectures in one download? Why not have two different install packages, one for each architecture? – noahlz Apr 15 '13 at 14:26
  • @noahz Because that's not how Google Play works. One application per package. Changing packages would mean having two apps, which is not ideal. In smartphone app world, you want what's called a "universal app". – Jason Robinson Apr 15 '13 at 20:01

2 Answers2

0

I was struggling to find the answer to a similar question (including a third-party provided shared library). I ended up with using the ndk-build directly via the exec-maven-plugin:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
        <execution>
            <phase>compile</phase>
             <goals>
                <goal>exec</goal>
             </goals>
        </execution>
    </executions>
    <configuration>
        <workingDirectory>jni</workingDirectory>
        <executable>$ANDROID_NDK_HOME/ndk-build</executable>
    </configuration>
</plugin>

This ends up placing the resulting libraries in the libs directory of your native project. The android-maven-plugin will use the libs directory as the source of your native libraries to be bundled into the resulting apk (or apklib).

You may want to add a clean up task for both the libs and obj directory produced by the ndk-build.

Peter Schwarz
  • 332
  • 3
  • 10
0

To get all architectures just add ndkArchitecture configuration onto your pom.xml:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
       <artifactId>android-maven-plugin</artifactId>
         <configuration>
             <sdk>
                <platform>${sdk.platform}</platform>
             </sdk>
             <ndkArchitecture>armeabi armeabi-v7a x86</ndkArchitecture>
         </configuration>
 </plugin>

But in order to work maven android plugin version must be: 3.8.2 (with maven 3.1.1)

M Penades
  • 1,572
  • 13
  • 24