使用maven构建本机android库

时间:2013-10-25 18:59:42

标签: android maven android-ndk

我已经成功构建了运行ndk-build manualy的android本机库。完成后,我在/ libs /目录中拥有所有定义平台的库。

然后我尝试使用maven插件构建相同的内容。在pom.xml中我定义了下一个插件:

<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>${android-maven-plugin.version}</version>
    <configuration>
         <ndk>
            <path>${env.ANDROID_NDK_HOME}</path>
         </ndk>
         <clearNativeArtifacts>false</clearNativeArtifacts>
         <ndkArchitectures>armeabi armeabi-v7a x86</ndkArchitectures>
         <sdk>
             <platform>${android.api.version}</platform>
             <path>${env.ANDROID_HOME}</path>
         </sdk>                  
         <ndkBuildAdditionalCommandline>NDK_APP_OUT=${project.basedir}/obj/${android.liboutdir
         </ndkBuildAdditionalCommandline>
         <unndeployBeforeDeploy>false</undeployBeforeDeploy>
     </configuration>
</plugin>

运行:mvn compile。 Libs已经建立,已被定位到/ libs //并且不幸的是已被删除。这是日志:

[WARNING] Excluding native dependency attached by this build
[INFO] executing 24 parallel jobs
[INFO] /home/user/android/android-ndk-r9/ndk-build [-C,     /home/user/workspace/webrtc/trunk/android/voice-client-native,     NDK_APPLICATION_MK=jni/default_debug.mk, -j, 24, NDK_TOOLCHAIN=arm-linux-androideabi-4.6,     APP_ABI=armeabi-v7a, NDK_APP_OUT=/home/user/workspace/webrtc/trunk/android/voice-    client-native/obj/default_debug, all]
[INFO] Building jar: /home/user/workspace/webrtc/trunk/android/voice-client native/target/voice-native-1.0-SNAPSHOT.har
[INFO] Cleaning up extracted include directories used for build
[INFO] Creating native output directory /home/user/workspace/webrtc/trunk/android/voice-client-native/libs/x86

目录libs为空,但是库位于target/ndk-libs/,这对我来说是正确的。

当我运行mvn install时,我有下一个输出:

Failed to install artifact com.tuenti.voice:voice-native:so:armeabi-v7a:1.0-SNAPSHOT: /home/user/workspace/webrtc/trunk/android/voice-client-native/libs/armeabi-v7a/libvoiceclient.so (No such file or directory) -> [Help 1]

我做错了什么?

1 个答案:

答案 0 :(得分:0)

请更改pom.xml中的以下行

NDK_APP_OUT = $ {project.basedir} / OBJ / $ {android.liboutdir}

NDK_OUT = $ {project.basedir} / obj / $ {android.liboutdir} APP_ABI =所有NDK_TOOLCHAIN =“”

还请注释掉nativeLibrariesDependenciesHardwareArchitectureOverrides标记。