You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Manifest报错:uses-sdk元素必须是manifest根元素的直接子元素

Fixing "The uses SDK element must be a direct child of the manifest root element" Error

Hey there! I’ve dealt with this exact problem before when setting up SDK versions for libraries like Helpshift—super common issue, and easy to fix once you know what’s going on.

What’s causing the error?

The Android manifest has strict rules about where certain tags can live. The <uses-sdk> tag cannot be nested inside any other elements (like <application>, <activity>, or <permission>). It has to be a direct child of the root <manifest> element. Chances are you accidentally placed it somewhere else in your manifest file.

How to fix it

  1. Open your AndroidManifest.xml file in Android Studio.
  2. Locate your <uses-sdk> tag—right now it’s probably inside another element (most likely <application>).
  3. Cut that entire <uses-sdk> block.
  4. Paste it right after the opening <manifest> tag (before any other elements like <application> or <uses-permission>).

Here’s what your corrected manifest should look like (with placeholder package name):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.your.app.package">

    <!-- Correct placement: Direct child of <manifest> -->
    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="26"
        android:compileSdkVersion="26"
        android:buildToolsVersion="26" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <!-- Your activities, services, receivers go here -->
    </application>

</manifest>

Quick check

After moving the tag, sync your project with Gradle (click the "Sync Project with Gradle Files" button in Android Studio). The error should disappear immediately if the placement is correct. Also, double-check that Helpshift’s SDK requirements align with your minSdkVersion—Helpshift typically supports minSdk 14+, which matches your setup, so that should be good to go.

内容的提问来源于stack exchange,提问作者Sam Wilson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:37:30