目前,在我的安卓应用程序中,我有targetSdkVersion 32
,在我的AndroidManifest.xml文件中有:
<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中出现了一些问题:
unknown attribute android:supportsRtl
unknown attribute android:screenOrientation
unknown attribute android:windowSoftInputMode
以及XML布局文件中的多个问题。例如:
unknown android:contentDescription
unknown android:layout_toEndOf
还有更多的..。
我已经试图使缓存失效,重建项目,没有任何帮助。只有切换回目标版本32有帮助。这些属性是否真的不受欢迎,还是有任何问题?它并没有说反对,只是不知道。
我还从缓存文件夹中实际删除了文件,我还重新安装了API33SDK,没有任何帮助。
我甚至重新安装了Android,没有运气。API 33和Android似乎有些问题。
发布于 2022-08-04 17:50:37
据这个问题追踪器错误称,Android在修补程序2之前不支持安卓13,而补丁2似乎增加了支持。然而,不支持Android插件7.3.0-beta05,这也是Android 13支持的必要条件。
在我看来,我发现这样做是可行的:
对于大多数人来说,这可能不是最好的解决方案,但是如果您愿意容忍不稳定版本的开发工具,这应该是可以的。
编辑:Android现在应该可以工作了。用那个。
发布于 2022-07-02 22:00:49
最近,由于33
文件中存在多个错误问题(包括缺少有效属性的自动完成),我将一个项目从SDK的32
版本回滚。
虽然回滚违背了一般的最佳实践,但我所维护的项目使用Lint警告作为次要的代码质量度量,因此所有错误的Unknown attribute
警告都在污染我们的报告,使得代码质量看起来好像在实际上没有改变时已经下降;此时,build-tools
的33
版本看起来确实是坏了,而且非常错误。
为了暂时解决这个问题,我对<app module>/build.gradle
做了以下更改,代码完成和Lint警告计数与“升级”到33
之前一样起作用。
32
还原到33
中的compileSdkVersion
和targetSdkVersion
字段。//noinspection OldTargetApi
注释。android {
compileSdkVersion 32
defaultConfig {
//noinspection OldTargetApi
targetSdkVersion 32
}
}
可选步骤
每当出于已知的原因使用//noinspection
注释或注释暂时禁用代码检查时,最好将票证添加到问题跟踪系统中,以确保一旦解决了问题的根本原因,就会检查和删除它。
在我的例子中,因为我不想在//noinspection
标记到位的情况下发布产品,所以我给问题跟踪器添加了一张票子,并在上面添加了一个StopShip
注释。如果您将Lint配置为failOnError
,这将防止生成一个版本并将其发送到生产中,但同时不会阻止开发或调试构建。
如下所示:
android {
compileSdkVersion 32
defaultConfig {
//STOPSHIP
// See issue #378 in Jira for details
//noinspection OldTargetApi
targetSdkVersion 32
}
lint {
abortOnError true
fatal 'StopShip'
}
}
这将导致一个错误,如果您试图创建一个发行版构建,如下所示:
> 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工具是固定的。
发布于 2022-09-20 09:59:26
对于targetSdkVersion 33
,我也有同样的问题。然后将Android更新为(AndroidStudioDolphin2021.3.1)。
问题解决了。
https://stackoverflow.com/questions/72664051
复制相似问题