aapt2

aapt2 link failure: compileSdkVersion not found


Trying to use aapt2 instead of aapt. Compilation seems to be OK, but I am having an issue:

+ aapt2 link -R build/mipmap-xhdpi_ic_launcher.png.flat -R build/values_public.arsc.flat -R build/mipmap-xxhdpi_ic_launcher.png.flat -R build/mipmap-hdpi_ic_launcher.png.flat -R build/mipmap-mdpi_ic_launcher.png.flat -R build/values_strings.arsc.flat -R build/mipmap-xxxhdpi_ic_launcher.png.flat --manifest AndroidManifest.xml -I /opt/android-sdk/platforms/android-26/android.jar -o javasrv2.apk --auto-add-overlay
AndroidManifest.xml:2: error: attribute android:compileSdkVersion not found.
error: failed processing manifest.

Here is the manifest, as you can see the attribute android:compileSdkVersion clearly defined:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.javasrv"
android:minSdkVersion="23"
android:compileSdkVersion="26"
android:targetSdkVersion="26"
android:versionCode="6"
android:versionName="1.0.0">
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <application xmlns:android="http://schemas.android.com/apk/res/android" android:icon="@mipmap/ic_launcher" android:label="@string/app_name">
                                <activity android:name="com.javasrv.MainActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
                          <service android:name=".MyTestService">
                                </service>
        <service android:name=".MyJobService" android:permission="android.permission.BIND_JOB_SERVICE">
                                        </service>
                                <receiver android:name="Boot">
                                                <intent-filter>
                                                                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                                                </intent-filter>
                                </receiver>
    </application>

</manifest>

How can it be?

Edit: used xmllint on AndroidManifest.xml. No luck. Then I just deleted android:compileSdkVersion from the manifest. It linked successfully. I am confused.


Solution

  • android:compileSdkVersion seems to be used only by gradle. In the AndroidManifest.xml itself tag uses-sdk should be used instead as specified in the documentation.