Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

android - Why does AndroidManifest.xml have invalid targetSdkVersion?

I build an app using android studio 3, but when I want to publish it, market said "Your application must have a valid targetSdkVersion set. To solve this problem, you need to edit your AndroidManifest.xml file and upload again the .apk file." I thought proguard make this problem so add -keep AndroidManifest.xml to rules. But it doesn't resolve my problem. could you help me please? I forgot to say I didn't have targetSdkVersion in my manifest. I added it manually but didn't resolve my problem. my manifest:

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

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" /><!--optional-->
    <uses-permission android:name="android.permission.VIBRATE" /><!--optional-->

    <application 
        android:name=".G"
        android:allowBackup="true"
        android:icon="@drawable/icon128"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/AppTheme">
        <activity android:name=".Main_Activity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".Relaxing_Activity" />
        <activity android:name=".Setting_Activity" />
        <activity android:name=".Info_Activity" />
        <activity android:name=".Absorption_Activity" />
        <activity android:name=".Capacity_Activity" />
        <activity android:name=".Control_Activity" />
        <activity android:name=".Program_Activity" />
        <activity android:name=".Contact_Activity" />
        <activity android:name="ir.tapsell.sdk.TapsellAdActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" >
        </activity>
    </application>
</manifest>

my gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "ir.farshidete.breathefree"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            minifyEnabled false
            // Uses new built-in shrinker http://tools.android.com/tech-docs/new-build-system/built-in-shrinker
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro'
        }

        release {
            minifyEnabled false
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguardTest-rules.pro'
        }
    }
}

dependencies {
    api(name:'tapsell-sdk-android', ext:'aar')
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Finally I solved it by: removing:

minSdkVersion 15
targetSdkVersion 28

from gradle. and adding :

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="26" />

to manifest! It seems slideme.org isn't up to date...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...