首页 > 解决方案 > 应用上传到 Slideme - 有效的 targetSdkVersion 未设置错误

问题描述

我正在尝试将我的第一个应用程序上传到 Slideme 并遇到以下错误:您的应用程序必须具有有效的 targetSdkVersion 集。要解决此问题,您需要编辑 AndroidManifest.xml 文件并再次上传 .apk 文件。

所以我将 targetSdkVersion 添加到我的清单文件中,并将其从我的 gradle 文件中删除,但仍然没有运气。我还尝试了仍然在 gradle 文件中设置的 targetSdkVersion 但也没有运气。我玩了很多,但我一直收到同样的错误。我已经多次重置 android studio,并且尝试关闭并重新打开 slideme 上传网页而没有任何变化。

这是我的 manifest.xml 文件:

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

        <uses-sdk android:targetSdkVersion="29" />

        <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">
            <activity android:name=".GameActivity"/>
            <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>

这是我的 Gradle 文件:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.cards.doublerun"
        minSdkVersion 15
        //targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

我看过这个问题:为什么 AndroidManifest.xml 有无效的 targetSdkVersion? 和这个问题:Valid sdkVersion for slideme.org 但两者中提供的建议对我不起作用。任何帮助将不胜感激。

标签: javaandroidbuild.gradleandroid-manifest

解决方案


将此粘贴到您的清单文件中

<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="29"/>

推荐阅读