如何修复Android Manifest文件中的‘Unsupported type 'uses-permission'’错误
Hey there, I’ve dealt with this exact frustrating error before when building Android apps that connect to remote databases. Let’s break down what’s probably causing it and how to fix it step by step:
1. Verify the Placement of <uses-permission> Tags
The most common issue is putting the permission tags in the wrong spot. They must be placed outside the <application> tag, directly under the root <manifest> element. Here’s the correct structure:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.your.app.package"> <!-- Permissions go HERE, before <application> --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <!-- Your activities, services, receivers go here --> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
If your permissions are nested inside <application> or another tag, Android Studio won’t recognize them properly, throwing that "Unsupported type" error.
2. Fix Syntax & Spelling Mistakes
Double-check for silly typos that can break the XML:
- Make sure the tag is spelled correctly:
<uses-permission>(notuse-permissionoruses-permissions) - Don’t add extra namespace prefixes to the tag (like
<android:uses-permission>— this is wrong) - Ensure the
xmlns:androidattribute is present in the root<manifest>tag (this tells the system how to interpret Android-specific attributes)
3. Clear Android Studio’s Cache (Old Version Quirk)
Since you’re using Android Studio 3.0.1 (a fairly old release), the IDE might be showing a false positive error. Try this:
- Go to
File > Invalidate Caches / Restart - Select Invalidate and Restart
Once the IDE reloads, the error often disappears if it was just a cache glitch.
4. Confirm Your Build Configuration
Check your module-level build.gradle file to ensure your SDK versions are compatible:
android { compileSdkVersion 28 // Or a higher version supported by your app defaultConfig { applicationId "com.your.app.package" minSdkVersion 21 targetSdkVersion 28 // ... other configs } }
Older compileSdkVersion values might have issues parsing modern permission tags, so updating to a more recent version (while keeping minSdkVersion compatible with your target users) can help.
Give these steps a try — odds are one of them will resolve that annoying error so you can get back to building your MySQL-connected app.
内容的提问来源于stack exchange,提问作者YasJ

