尝试使用 aapt2 而不是 aapt。编译似乎没问题,但我遇到了一个问题:
+ 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.
这是清单,您可以看到明确定义的属性 android:compileSdkVersion:
<?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>
怎么会这样?
编辑:在 AndroidManifest.xml 上使用了 xmllint。没运气。然后我刚刚从清单中删除了 android:compileSdkVersion 。它链接成功。我很困惑。