Ant 忽略 Android 打包中的 .so 库
我用 NDK 在 C++ 中构建了一个 lib.so,我如何告诉 Ant 分解 .so 和 .so? .a libs 放入包中,它会生成一个 apk 文件,但它生成的 libs 目录是空的...
我读到需要有一个 armabi 文件夹,我将 libs 放在 arm64-v8a 中,但仍然没有任何改变。
谢谢
project.properties
target=android-29
has.keystore=true
key.store=C:/path
key.alias=mykey
source.dir=.
gen.dir=gen
resource.dir=res
asset.dir=assets
external.libs.dir=.
out.dir=Package/bin
key.store.password=pw
key.alias.password=pw
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="help">
<property file="ant.properties" />
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail message="sdk.dir is missing. Make sure ANDROID_HOME
environment variable is correctly set."
unless="sdk.dir"/>
<import file="custom_rules.xml" optional="true" />
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<target name="-pre-compile">
<path id="project.all.jars.path">
<path path="${toString:project.all.jars.path}"/>
<fileset dir="${jar.libs.dir}">
<include name="*.jar"/>
</fileset>
</path>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<target name="clean">
<delete dir="Package"/>
<delete dir="gen"/>
<delete dir="libs"/>
</target>
<xmlproperty file="AndroidManifest.xml" prefix="custom"
collapseAttributes="true" />
<condition property="version.code" value="${env.BUILD_NUMBER}"
else="${custom.manifest.android:versionCode}">
<isset property="env.BUILD_NUMBER" />
</condition>
<property name="version.name"
value="${custom.manifest.android:versionName}.${version.code}" />
<target name="-set-mode-check" depends="android_rules.-set-mode-
check, -release-prompt-for-password, -set-apk-filenames" />
<target name="-set-apk-filenames">
<condition property="custom.tag" value="release">
<contains string="${ant.project.invoked-targets}"
substring="release" />
</condition>
<condition property="custom.tag" value="debug">
<contains string="${ant.project.invoked-targets}"
substring="debug" />
</condition>
<condition property="custom.tag" value="instrumented">
<contains string="${ant.project.invoked-targets}"
substring="instrument" />
</condition>
<condition property="custom.suffix" value="unsigned"
else="unaligned">
<contains string="${ant.project.invoked-targets}"
substring="release" />
</condition>
</target>
</project>
一定有办法做到这一点,Visual Studio 使用 Ant 来打包 .so & 。 .a 文件适用于 ARM64,但它们有一些配方中间步骤,仅保存所有 lib 资源的路径。
谢谢
I built a lib.so in C++ with NDK, how do I tell Ant to factor .so & .a libs into the package, it makes an apk file but the libs directory it makes is empty...
I read that there needs to be an armabi folder, I put the libs in arm64-v8a but nothing changed still.
Thanks
project.properties
target=android-29
has.keystore=true
key.store=C:/path
key.alias=mykey
source.dir=.
gen.dir=gen
resource.dir=res
asset.dir=assets
external.libs.dir=.
out.dir=Package/bin
key.store.password=pw
key.alias.password=pw
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="help">
<property file="ant.properties" />
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail message="sdk.dir is missing. Make sure ANDROID_HOME
environment variable is correctly set."
unless="sdk.dir"/>
<import file="custom_rules.xml" optional="true" />
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<target name="-pre-compile">
<path id="project.all.jars.path">
<path path="${toString:project.all.jars.path}"/>
<fileset dir="${jar.libs.dir}">
<include name="*.jar"/>
</fileset>
</path>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<target name="clean">
<delete dir="Package"/>
<delete dir="gen"/>
<delete dir="libs"/>
</target>
<xmlproperty file="AndroidManifest.xml" prefix="custom"
collapseAttributes="true" />
<condition property="version.code" value="${env.BUILD_NUMBER}"
else="${custom.manifest.android:versionCode}">
<isset property="env.BUILD_NUMBER" />
</condition>
<property name="version.name"
value="${custom.manifest.android:versionName}.${version.code}" />
<target name="-set-mode-check" depends="android_rules.-set-mode-
check, -release-prompt-for-password, -set-apk-filenames" />
<target name="-set-apk-filenames">
<condition property="custom.tag" value="release">
<contains string="${ant.project.invoked-targets}"
substring="release" />
</condition>
<condition property="custom.tag" value="debug">
<contains string="${ant.project.invoked-targets}"
substring="debug" />
</condition>
<condition property="custom.tag" value="instrumented">
<contains string="${ant.project.invoked-targets}"
substring="instrument" />
</condition>
<condition property="custom.suffix" value="unsigned"
else="unaligned">
<contains string="${ant.project.invoked-targets}"
substring="release" />
</condition>
</target>
</project>
Must be a way to do it, Visual Studio uses Ant for packaging with .so & .a files for ARM64 but they have some recipe intermediary step that just saves paths to all lib resources.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论