error: unexpected element <uses-sdk> found in <manifest><application>
error: unexpected element <uses-sdk> found in <manifest><application>
我正在尝试构建 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.jar6069e667720c031ae71c30fd5dfaa7\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
请注意,错误中提到的清单XML(AndroidManifest.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>
这张图片也可能有用:
谢谢。
error: unexpected element <uses-sdk>
found in <manifest><application>
因此,删除
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
来自 <application/>
。它不属于那里,因此是意外的。
并且 Manifest.xml
不应自动生成。可能存在多个 Manifest.xml
,正在合并。 /src/debug/Manifest.xml
可能包含放错位置的元素。
有问题的 Manifest 文件实际上是在这个 .aar 文件中找到的:
vlctest-master\vlctest-master\libvlc-3.0.0\libvlc-3.0.0.aar
.aar 文件只是一个带有自定义扩展名的 .zip 文件。因此,将其重命名为 .zip,解压,从 Manifest 文件中删除 "uses-sdk" 行,重新压缩,重命名为 .aar,就大功告成了! Gradle 完成所有这些后,为我成功同步了。
我正在尝试构建 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.jar6069e667720c031ae71c30fd5dfaa7\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
请注意,错误中提到的清单XML(AndroidManifest.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>
这张图片也可能有用:
error: unexpected element
<uses-sdk>
found in<manifest><application>
因此,删除
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
来自 <application/>
。它不属于那里,因此是意外的。
并且 Manifest.xml
不应自动生成。可能存在多个 Manifest.xml
,正在合并。 /src/debug/Manifest.xml
可能包含放错位置的元素。
有问题的 Manifest 文件实际上是在这个 .aar 文件中找到的:
vlctest-master\vlctest-master\libvlc-3.0.0\libvlc-3.0.0.aar
.aar 文件只是一个带有自定义扩展名的 .zip 文件。因此,将其重命名为 .zip,解压,从 Manifest 文件中删除 "uses-sdk" 行,重新压缩,重命名为 .aar,就大功告成了! Gradle 完成所有这些后,为我成功同步了。