不针对Android的最新版本 [英] Not targeting the latest versions of Android

查看:226
本文介绍了不针对Android的最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个警告,试图测试主题时最新的Andr​​oid SDK包4​​.2。

下面是我的清单文件:

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.example.themetest
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <用途-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =16/>

    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppBaseTheme>
        <活动
            机器人:名称=com.example.themetest.MainActivity
            机器人:标签=@字符串/ APP_NAME>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>

< /舱单>
 

  

不针对Android系统的最新版本;兼容模式   应用。考虑测试和更新这个版本。咨询   android.os.Build.VERSION_ codeS的javadoc   详细信息。 AndroidManifest.xml中/ ThemeTest 7号线的Andr​​oid皮棉问题

我使用所谓的AppBaseTheme自定义主题。我的问题是,究竟是什么咨询android.os.Build.VERSION_ codeS的javadoc。。我怎么能解决这个问题?

解决方案

它说,这是因为 targetSdkVersion =16。 API 16杰利贝恩4.1和4.1.1,同时杰利贝恩4.2 API 17

请尝试使用:

 <使用-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =17/>
 

另外,请记住,这是一个皮棉警告。这些警告的存在是为了帮助你更好的code,使其易于维护,同时与最新的Andr​​oid变化兼容。忽略这不会给你任何直接的问题。

编辑:而对于Android 4.3,最新的SDK版本是现年18岁,所以你应该使用:

  ...
        机器人:targetSdkVersion =18/>
 

编辑2:随着Android 4.4系统,最新的SDK版本是现年19岁,所以你应该使用:

  ...
        机器人:targetSdkVersion =19/>
 

编辑3:利用Android L,则必须使用下面的值,如所描述的此处

  compileSdkVersion =机器人-L
的minSdkVersion =L的
targetSdkVersion =L的
 

编辑4:利用Android L的公开发行,则必须使用21来代替:

  ...
        机器人:targetSdkVersion =21/>
 

20用于4.4W,或的 Android Wear

编辑5:利用Android M的公开发行,则必须使用23来代替:

  ...
        机器人:targetSdkVersion =23/>
 

在今后请咨询href="https://source.android.com/source/build-numbers.html" rel="nofollow"> Android官方文档保持

I have a warning when trying to test theme on latest Android SDK Package 4.2.

Here is my manifest file:

<?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>

Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details. AndroidManifest.xml /ThemeTest line 7 Android Lint Problem

I am using a custom theme called 'AppBaseTheme'. My question is what exactly Consult the android.os.Build.VERSION_CODES javadoc.. How could I solve this problem?

解决方案

It says this because of targetSdkVersion="16". API 16 is Jellybean 4.1 and 4.1.1, while Jellybean 4.2 is API 17.

Try using:

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

Also, keep in mind that this is a Lint warning. These warning exist to help you better your code and make it easy to maintain, while being compatible with the latest Android changes. Ignoring this will not cause you any immediate problems.

EDIT: With Android 4.3, the latest SDK version is now 18, so you should use:

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

EDIT 2: With Android 4.4, the latest SDK version is now 19, so you should use:

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

EDIT 3: With Android L, you must use the following values, as described here:

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

EDIT 4: With Android L's public release, you must use 21 instead:

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

20 was used for 4.4W, or for Android Wear.

EDIT 5: With Android M's public release, you must use 23 instead:

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

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

这篇关于不针对Android的最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆