Ant build does not include Android support library jar
<p>I have a cmake script for cross compiling our code. To compile for Android we use Ant which runs cmake for the native parts. Ant handles the Android/java part. Since we have imports like <code>import android.support.v4.app.ActivityCompat;</code> on the java side I took the support library jar at <code>/my/sdk/folder/extras/android/m2repository/com/android/support/support-v4/24.0.0/support-v4-24.0.0-sources.jar</code> and stuck it in my <code>libs</code> folder. I am pretty sure this has worked for older SDK versions before, but now it does not work. (It also seems that the filename of the jar has changed, don't know if it matters in any way.)</p>

<p>The problem is that, even though I have the jar in my <code>libs</code> folder, I still get loads of errors like <code>error: package android.support.v4.content does not exist</code> when building the code. Shouldn't it be as easy as to drop the support library jar in the <code>libs</code> folder and off we go? Before including the support libraries everything compiled fine.</p>

<p>What can I possibly be doing wrong here? What other things can I try/check?</p>

<p><strong>What have I tried:</strong></p>

<ol>
<li>Unzipping the jar to see that the Android files are there. They are, and everything seems to be in order.</li>
<li>Take the unzipped files from the jar and add it to my <code>src</code> folder so that, in addition to my own files, we have <code>src/com/android/support/v4/...</code>. Most of the support library compiled, but there were other errors. This is really beside the point, since the inclusion of a jar should be simple.</li>
<li>Force Ant to include the jar directly by using <code>&lt;path&gt;</code> with <code>&lt;fileset&gt;</code>, see the attempt in <code>build.xml</code> below.</li>
<li>Various other small things.</li>
</ol>

<p><strong>build.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;project name="myApp" default="debug" xmlns:if="ant:if" xmlns:unless="ant:unless"&gt;
    &lt;property environment="env" /&gt;
    &lt;path id="sdk.dir_path"&gt;
        &lt;pathelement path="${env.ANDROID_SDK}" /&gt;
    &lt;/path&gt;
    &lt;path id="ndk.dir_path"&gt;
        &lt;pathelement path="${env.ANDROID_NDK}" /&gt;
    &lt;/path&gt;
    &lt;pathconvert targetos="unix" property="sdk.dir" refid="sdk.dir_path"/&gt;
    &lt;pathconvert targetos="unix" property="ndk.dir" refid="ndk.dir_path"/&gt;

    &lt;property file="ant.properties" /&gt;
    &lt;loadproperties srcFile="local.properties" /&gt;
    &lt;loadproperties srcFile="project.properties" /&gt;

    &lt;!-- Attempting to force inclusion of jar. Does not help. --&gt;
    &lt;property name="project.lib.dir" value="${basedir}/libs"/&gt;
    &lt;path id="lib.path"&gt;
        &lt;fileset dir="${project.lib.dir}" includes="support-v4-24.0.0-sources.jar" /&gt;
    &lt;/path&gt;

    &lt;fail
        message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'."
        unless="sdk.dir"
        /&gt;

    &lt;target name="clean" depends="android_rules.clean"&gt;
        &lt;delete dir="obj"/&gt;
        &lt;delete dir="libs/x86"/&gt;
        &lt;delete dir="libs/armeabi-v7a"/&gt;
        &lt;delete dir="build_x86"/&gt;
        &lt;delete dir="build_armeabi-v7a"/&gt;
    &lt;/target&gt;


    &lt;!-- Not relevant --&gt;
    &lt;target name="build-jni"&gt;
        &lt;!-- Snip --&gt;
    &lt;/target&gt;

    &lt;target name="-pre-build" depends="build-jni"&gt;
    &lt;/target&gt;

    &lt;!-- Include Android build.xml --&gt;
    &lt;import file="${sdk.dir}/tools/ant/build.xml"/&gt;

&lt;/project&gt;
</code></pre>

<p><strong>Folder structure</strong></p>

<pre><code>.
├── AndroidManifest.xml
├── ant.properties
├── build_cmake.xml
├── build.xml
├── jni
│   ├── Android.mk
│   └── Application.mk
├── libs
│   └── support-v4-24.0.0-sources.jar
├── local.properties
├── project.properties
├── README.txt
├── res
│   └── values
│       └── strings.xml
└── src
    └── com
        └── mycompany
            └── myApp
                └── myApp.java

8 directories, 12 files
</code></pre>

<p>There isn't really anything special about the other files - they contain just normal stuff. I'll post them here anyway in case I have missed something silly.</p>

<p><strong>AndroidManifest.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mycompany.myApp"
    android:versionCode="1"
    android:versionName="1.0.0" &gt;

    &lt;uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="15" /&gt;

    &lt;uses-permission android:name="android.permission.INTERNET"/&gt;

    &lt;uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" /&gt;

    &lt;application
        android:label="@string/app_name"
        android:debuggable="true"&gt;

        &lt;activity
            android:name="com.mycompany.myApp.myApp"
            android:label="@string/app_name"
            android:screenOrientation="portrait"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN"/&gt;
                &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;

&lt;/manifest&gt;
</code></pre>

<p><strong>project.properties</strong></p>

<pre><code>target=android-15
</code></pre>

<p><strong>local.properties</strong></p>

<pre><code>Empty file
</code></pre>

<p><strong>ant.properties</strong></p>

<pre><code>// An attempt to force Ant to include libs folder
jar.libs.dir=libs
</code></pre>

<p><strong>jni/Android.mk</strong></p>

<pre><code>// Not really used, cmake sets target platform.
APP_ABI := all
</code></pre>

<p><strong>jni/Application.mk</strong></p>

<pre><code>// Not really used, cmake sets target platform.
APP_ABI := x86
</code></pre>

<p><code>strings.xml</code> is not relevant and the only thing we need to know from <code>myApp.java</code> is that it has the include statements above to use the support libraries. <code>build_cmake.xml</code> is just another ant script called from <code>build.xml</code> to run <code>cmake</code>.</p>