简体   繁体   中英

Android project build with native libraries inside using maven

I have an Android project with Maven that uses internal libraries. When I run a maven install the so library is not inside the jar file generated and in consequence is not inside the apk generated. I'm using Eclipse with maven and android maven plugin v.3.7.0.

My pom.xml is:

    <build>
    <sourceDirectory>src</sourceDirectory>
    <finalName>../bin/${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <nativeLibrariesDirectory>${project.basedir}/libs</nativeLibrariesDirectory>
                <sdk>
                    <path>${env.ANDROID_HOME}</path>
                    <platform>15</platform>
                </sdk>
            </configuration>
            <extensions>true</extensions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

It seems that nativeLibrariesDirectory tag doesn't works for me.

Any idea to fix this problem? Thanks

Here is how to include native libraries in your apk:

    <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>com.simpligility.maven.plugins</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <manifest>
                    <debuggable>true</debuggable>
                </manifest>
                <!-- Where the native files are located; in the future we should use src/main/libs -->
                <nativeLibrariesDirectory>${project.basedir}/libs</nativeLibrariesDirectory>                
            </configuration>
            <executions>
                <execution>
                    <id>manifestUpdate</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>manifest-update</goal>
                    </goals>
                </execution>
                <execution>
                    <id>alignApk</id>
                    <phase>package</phase>
                    <goals>
                        <goal>zipalign</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The Android for Maven Eclipse project doesn't yet support native libraries. If you'd like to see this supported please send a pull request .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM