programing

최신 버전의 Android를 타겟팅하지 않음

copyandpastes 2021. 1. 18. 22:14
반응형

최신 버전의 Android를 타겟팅하지 않음


최신 Android SDK 패키지 4.2에서 테마를 테스트하려고 할 때 경고가 표시됩니다.

내 매니페스트 파일은 다음과 같습니다.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.themetest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppBaseTheme" >
        <activity
            android:name="com.example.themetest.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

최신 버전의 Android를 대상으로하지 않습니다. 호환 모드가 적용됩니다. 이 버전을 테스트하고 업데이트하십시오. 자세한 내용은 android.os.Build.VERSION_CODES javadoc을 참조하세요. AndroidManifest.xml / ThemeTest 7 행 Android Lint 문제

'AppBaseTheme'라는 사용자 지정 테마를 사용하고 있습니다. 내 질문은 정확히 android.os.Build.VERSION_CODES javadoc을 참조하십시오. . 이 문제를 어떻게 해결할 수 있습니까?


때문에 이렇게 말합니다 targetSdkVersion="16". API 16은 Jellybean 4.1 및 4.1.1이고 Jellybean 4.2는 API 17입니다.

다음을 사용해보십시오.

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

또한 이것은 Lint 경고임을 명심하십시오. 이러한 경고는 최신 Android 변경 사항과 호환되는 동시에 코드를 개선하고 유지 보수를 쉽게하기 위해 존재합니다. 이것을 무시해도 즉각적인 문제가 발생하지는 않습니다.

수정 : Android 4.3에서 최신 SDK 버전은 이제 18이므로 다음을 사용해야합니다.

...
        android:targetSdkVersion="18" />

편집 2 : Android 4.4에서 최신 SDK 버전은 이제 19이므로 다음을 사용해야합니다.

...
        android:targetSdkVersion="19" />

편집 3 : Android L에서는 여기에 설명 된대로 다음 값을 사용해야합니다 .

compileSdkVersion="android-L"
minSdkVersion="L"
targetSdkVersion="L"

편집 4 : Android L의 공개 릴리스에서는 대신 21을 사용해야합니다.

...
        android:targetSdkVersion="21" />

20은 4.4W 또는 Android Wear 에 사용되었습니다 .

편집 5 : Android M의 공개 릴리스에서는 대신 23을 사용해야합니다.

...
        android:targetSdkVersion="23" />

In the future please consult the official Android documentation to keep yourself up-to-date with the latest Android API Levels.


You should not use android:maxSdkVersion="17" because it means that if someone using your app updates its android OS to a version greater than 17, your app will be removed.


This lint message is telling you that compatibility mode will be automatically applied to any features you may have used that are not available in later versions than your declared targetSdkVersion of 16 (and, it is also telling you that there are such later versions - e.g., 17).

These automatic compatibility mode adjustments may not be as ideal as what you could accomplish yourself by using whatever features were added in later (than level 16) versions to replace the functionality of the level 16 ones that you may have used, which have been removed in later versions (if any). But everything should still continue to work in later versions (due to the adjustments made by the compatibility code that is automatically applied for running on versions higher than your declared targetSdkVersion's API level); it just may not work as well as your own custom detection of, and use of, the new features (when your app detects that it is running in the later versions that have those features) would have worked.

Here is a discussion, with examples, of minSdkLevel vs. targetSdkLevel:

Android Min SDK Version vs. Target SDK Version

Another thing you will want to consider is the relationship of the Project Build Target (the level of the SDK used to compile your app) to the targetSdkLevel:

Difference between "Build Target SDK" in Eclipse and android:targetSdkVersion in AndroidManifest.xml?


I had the same problem happen to me, it turns out that there is now a new (usually unused) parameter in the manifest that you will also want to use. Add android:maxSdkVersion="16" to your uses-sdk like I have below:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17"
    android:maxSdkVersion="17" />

This will give you no warning when saved (since version 17 is the current maximum version of the SDK)

The maxSdkVersion isn't necessary, but will help in the event that something in version 17 is changed. If you're using standard ADK platform components, you will not need the maxSdkVersion.


Its a warning message if you want to solve it then you can set android:maxSdkVersion="17" but you have to take care of the fact that if someone currently using your app and upgrade his android OS to greater version than 17 then your app will automatically remove because of unsupported version.. So take care of this fact also..


Add xmlns:tools="http://schemas.android.com/tools" tools:ignore="OldTargetApi".

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.themetest"
    android:versionCode="1"
    android:versionName="1.0" xmlns:tools="http://schemas.android.com/tools" tools:ignore="OldTargetApi">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

From: Stuck on why my android app wont work?

ReferenceURL : https://stackoverflow.com/questions/13431722/not-targeting-the-latest-versions-of-android

반응형