首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android 33 - Android Studio中的清单和布局文件中的问题

Android 33 - Android Studio中的清单和布局文件中的问题
EN

Stack Overflow用户
提问于 2022-06-17 19:37:51
回答 5查看 4.9K关注 0票数 29

目前,在我的安卓应用程序中,我有targetSdkVersion 32,在我的AndroidManifest.xml文件中有:

代码语言:javascript
运行
复制
<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_nameshort"
    android:supportsRtl="false"
    android:theme="@style/AppTheme">
    
    <activity android:name=".MainActivity"
        android:screenOrientation="portrait"
        tools:ignore="LockedOrientationActivity"
        android:windowSoftInputMode="adjustPan"
        android:exported="true">

一切都很好,运转良好。

然而,现在当我更新我的应用程序时,Android (花栗鼠,2021.2.1)建议使用targetSdkVersion 33。在我这样做之后,AndroidManifest.xml中出现了一些问题:

代码语言:javascript
运行
复制
unknown attribute android:supportsRtl
unknown attribute android:screenOrientation
unknown attribute android:windowSoftInputMode 

以及XML布局文件中的多个问题。例如:

代码语言:javascript
运行
复制
unknown android:contentDescription
unknown android:layout_toEndOf

还有更多的..。

我已经试图使缓存失效,重建项目,没有任何帮助。只有切换回目标版本32有帮助。这些属性是否真的不受欢迎,还是有任何问题?它并没有说反对,只是不知道。

我还从缓存文件夹中实际删除了文件,我还重新安装了API33SDK,没有任何帮助。

我甚至重新安装了Android,没有运气。API 33和Android似乎有些问题。

EN

回答 5

Stack Overflow用户

发布于 2022-08-04 17:50:37

这个问题追踪器错误称,Android在修补程序2之前不支持安卓13,而补丁2似乎增加了支持。然而,不支持Android插件7.3.0-beta05,这也是Android 13支持的必要条件。

在我看来,我发现这样做是可行的:

  1. 切换到(是的,金丝雀版本)。我想说的是改用Dolphin,但这显然还没有得到Android 13的支持。
  2. 将AGP版本升级到7.4.0-alpha 09,它支持Android 13,我会升级到7.3.0-beta05,但Electric不支持该版本。

对于大多数人来说,这可能不是最好的解决方案,但是如果您愿意容忍不稳定版本的开发工具,这应该是可以的。

编辑:Android现在应该可以工作了。用那个。

票数 9
EN

Stack Overflow用户

发布于 2022-07-02 22:00:49

最近,由于33文件中存在多个错误问题(包括缺少有效属性的自动完成),我将一个项目从SDK的32版本回滚。

虽然回滚违背了一般的最佳实践,但我所维护的项目使用Lint警告作为次要的代码质量度量,因此所有错误的Unknown attribute警告都在污染我们的报告,使得代码质量看起来好像在实际上没有改变时已经下降;此时,build-tools33版本看起来确实是坏了,而且非常错误。

为了暂时解决这个问题,我对<app module>/build.gradle做了以下更改,代码完成和Lint警告计数与“升级”到33之前一样起作用。

  1. 32还原到33中的compileSdkVersiontargetSdkVersion字段。
  2. 添加//noinspection OldTargetApi注释。
代码语言:javascript
运行
复制
android {

    compileSdkVersion 32

    defaultConfig {

        //noinspection OldTargetApi
        targetSdkVersion 32

    }
}

可选步骤

每当出于已知的原因使用//noinspection注释或注释暂时禁用代码检查时,最好将票证添加到问题跟踪系统中,以确保一旦解决了问题的根本原因,就会检查和删除它。

在我的例子中,因为我不想在//noinspection标记到位的情况下发布产品,所以我给问题跟踪器添加了一张票子,并在上面添加了一个StopShip注释。如果您将Lint配置为failOnError,这将防止生成一个版本并将其发送到生产中,但同时不会阻止开发或调试构建。

如下所示:

代码语言:javascript
运行
复制
android {

    compileSdkVersion 32

    defaultConfig {

        //STOPSHIP
        // See issue #378 in Jira for details
        //noinspection OldTargetApi
        targetSdkVersion 32

    }

    lint {
        abortOnError true
        fatal 'StopShip'
    }
}

这将导致一个错误,如果您试图创建一个发行版构建,如下所示:

代码语言:javascript
运行
复制
> Task :app:lintRelease FAILED
Lint found 1 errors. First failure:
/src/app/build.gradle:25: Error: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip]
        //STOPSHIP
          ~~~~~~~~
   Explanation for issues of type "StopShip":
   Using the comment // STOPSHIP can be used to flag code that is incomplete
   but checked in. This comment marker can be used to indicate that the code
   should not be shipped until the issue is addressed, and lint will look for
   these. In Gradle projects, this is only checked for non-debug (release)
   builds.
   In Kotlin, the TODO() method is also treated as a stop ship marker; you can
   use it to make incomplete code compile, but it will throw an exception at
   runtime and therefore should be fixed before shipping releases.

这最后一步是必要的,只有当你不想发布之前,33的SDK工具是固定的。

票数 7
EN

Stack Overflow用户

发布于 2022-09-20 09:59:26

对于targetSdkVersion 33,我也有同样的问题。然后将Android更新为(AndroidStudioDolphin2021.3.1)。

问题解决了。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72664051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档