我正在尝试构建this android vlctest应用程序示例,但是出现以下错误:
Android resource linking failed
Output: C:\Program Files\android\workspace\vlctest-master\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml:42: error: unexpected element <uses-sdk> found in <manifest><application>.
Command: C:\Program Files\android\android-studio\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\466069e667720c031ae71c30fd5dfaa7\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
E:\android\Sdk\platforms\android-28\android.jar\
--manifest\
C:\Program Files\android\workspace\vlctest-master\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
C:\Program Files\android\workspace\vlctest-master\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@C:\Program Files\android\workspace\vlctest-master\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
C:\Program Files\android\workspace\vlctest-master\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.sxx.vlctest\
-0\
apk\
--output-text-symbols\
C:\Program Files\android\workspace\vlctest-master\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
请注意,错误( AndroidManifest.xml )中提到的清单XML是构建目录下的自动生成的文件,因此对其进行任何更改都会在同步后重置。
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sxx.vlctest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="com.sxx.vlctest.VLCApplication"
android:allowBackup="true"
android:appComponentFactory="android.support.v4.app.CoreComponentFactory"
android:debuggable="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity
android:name="com.sxx.vlctest.MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="26" />
</application>
</manifest>
我认为我的app gradle
也可能会有所帮助:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.sxx.vlctest"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:+'
implementation 'com.android.support:design:28.0.0'
implementation project(':libvlc-3.0.0')
}
编辑:
下面是我的主清单文件,位于“ app / src / main / AndroidManifest.xml”下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sxx.vlctest">
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:name="com.sxx.vlctest.VLCApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
此图像也可能有用:
答案 0 :(得分:2)
有问题的清单文件实际上是在此.aar文件中的以下位置:
vlctest-master\vlctest-master\libvlc-3.0.0\libvlc-3.0.0.aar
.aar文件只是带有自定义扩展名的.zip文件。因此,将其重命名为.zip,解压缩,从清单文件中删除“ uses-sdk”行,将其重新压缩,重命名为.aar,就可以完成了!完成所有这些操作后,Gradle为我成功同步。
答案 1 :(得分:0)
错误:在
<uses-sdk>
中发现意外元素<manifest><application>
因此,删除
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
从<application/>
内部。它不属于其中,因此是意外的。
和Manifest.xml
不应自动生成。可能有几个Manifest.xml
正在合并。 /src/debug/Manifest.xml
可能包含错误放置的元素。