Android项目构建与本地库内部使用maven



我有一个使用内部库的Maven Android项目。当我运行maven install时,so库不在生成的jar文件中,因此也不在生成的apk中。我使用Eclipse与maven和android maven插件v.3.7.0。

我的pom.xml是:

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

似乎nativeLibrariesDirectory标签不适合我。

有解决这个问题的办法吗?由于

如何在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>

Android for Maven Eclipse项目还不支持本地库。如果你想看到这个支持,请发送一个pull request。

相关内容

  • 没有找到相关文章

最新更新