0

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

Sixjac
  • 339
  • 4
  • 16
  • 1
    The `ant` build system was depreciated from general Android use when [Android Studio became standard](https://android-developers.googleblog.com/2016/11/support-ended-for-eclipse-android.html) for supporting various features like AAR libraries/maven dependencies. I would suggest migrating to `gradle` as that is supported. – Morrison Chang Mar 11 '22 at 07:51
  • @MorrisonChang re Gradle, thanks but no thanks. – Sixjac Mar 11 '22 at 07:53
  • Then you should show your `ant` code/build scripts as any functions that existed were prior to recent Android ecosystem changes like 64-bit support. – Morrison Chang Mar 11 '22 at 07:56
  • Given that [The ant/ folder is suddenly missing from Android SDK. Did Google remove it?](https://stackoverflow.com/q/42912824/295004) you should confirm which version of tools/ant/build.xml you are using. Also you are trying to build for Android 10 (released in 2019), I wish you luck. – Morrison Chang Mar 11 '22 at 08:46
  • Thanks yeah I am using tools version 25 with the build.xml in it, using ant installation from MSFT that comes with VS install, and yes building Android10. – Sixjac Mar 11 '22 at 08:53
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/242839/discussion-between-morrison-chang-and-sixjac). – Morrison Chang Mar 11 '22 at 08:54

0 Answers0