Android 33 - issues in manifest and layout files in Android Studio
Asked Answered
O

5

34

Currently in my Android app I have targetSdkVersion 32 and in my AndroidManifest.xml file I have:

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

Everything is fine and working well.

However now when I am updating my app, Android Studio (Chipmunk | 2021.2.1) suggests to use targetSdkVersion 33. After I do that, there are issues in AndroidManifest.xml:

unknown attribute android:supportsRtl
unknown attribute android:screenOrientation
unknown attribute android:windowSoftInputMode 

and also multiple issues in XML layout files. e.g.:

unknown android:contentDescription
unknown android:layout_toEndOf

and much more...

I already tried to invalidate caches, rebuild the project, nothing helps. Only switching back to target version 32 helps. Are those attributes really deprecated or is there any issue? It doesn't say deprecated, just unknown.

I also deleted physically the files from cache folders, I also reinstalled the API 33 SDK, nothing helped.

I even reinstalled Android Studio, with no luck. Seems something is wrong with API 33 vs Android Studio.

Overtly answered 17/6, 2022 at 19:37 Comment(4)
Not sure, but how about cleaning gradle & AS stuff.Pyrrhuloxia
unfortunately it did not help, after I cleared the cache folders and inspected the whole project, there are much more issues also in xml layout files e.g. unknown android:contentDescription, unknown android:layout_toEndOf etc. Very strangeOvertly
I'm having the same issue. I had to use <!--suppress ALL --> to keep calmCherin
Same issue, even with last SDK33 released today !Parental
W
5

I have the same issue, with targetSdkVersion 33. Then I update Android Studio to (Android Studio Dolphin | 2021.3.1).

Issue is solved.

Waler answered 20/9, 2022 at 9:59 Comment(3)
I dont know if this solved the mentioned problem. But when I removed Bumblebee and installed Dolphin, I can targetSdkVersion 33 and see source code of some general Android Class based on SDK 33 which is good.Isatin
Yes Solved the issue!! Thank you.Shiksa
yes, seems your mentioned version, also the most current version of Android Studio solved the issueOvertly
D
11

According to this issue tracker bug, Android Studio Chipmunk before Patch 2 does not support Android 13. Patch 2 did seemingly add support. However, Android Studio Chipmunk does not have support for Android Gradle Plugin 7.3.0-beta05, which is also required for Android 13 support.

On my end, I've found doing this will work:

  1. Switch to Android Studio Electric Eel (Yes, the Canary version). I would say to switch to Dolphin, but that has apparently not been patched to have Android 13 support yet.
  2. Upgrade the AGP version to 7.4.0-alpha09, which supports Android 13. I would upgrade to 7.3.0-beta05, but Electric Eel does not support that version.

This probably isn't the best solution for most people, but if you are willing to tolerate unstable versions of development tools it should be fine.

Edit: Android Studio Dolphin should work now. Use that.

Davide answered 4/8, 2022 at 17:50 Comment(2)
Resolve by only installing Electric Eel (2022.1.1) Canary 10, no need to upgrade AGP.Airy
I don't know, Android Eel threw an error at me if i didn't use 7.4.0.Davide
H
7

I recently rolled back a project from version 33 to 32 of the SDK tools because of multiple erroneous issues with XML files, including lack of autocomplete of valid attributes.

Although rolling back goes against general best practice, the project I'm maintaining uses Lint warnings as a secondary code quality metric, so all of the erroneous Unknown attribute warnings was polluting our reports, making it look like code quality had dipped when in reality it hadn't changed; at this time version 33 of the build-tools really do appear to be broken and quite buggy.

To temporarily fix the issue, I made the following changes to <app module>/build.gradle, and the code completion, and Lint warning count are functioning as they were before the "upgrade" to 33.

  1. Revert to 32 from 33 for compileSdkVersion and targetSdkVersion fields.
  2. Add //noinspection OldTargetApi comment.
android {

    compileSdkVersion 32

    defaultConfig {

        //noinspection OldTargetApi
        targetSdkVersion 32

    }
}

Optional Step

Whenever using //noinspection comments or annotations to temporarily disable code inspection for a known reason, it's good practice to add a ticket to your issue tracking system to ensure that it's checked and removed once the root cause has been fixed.

In my case because I don't want this to ship to production with //noinspection tag in place, I added a ticket to the issue tracker, and added a StopShip comment right above it. If you have Lint configured to failOnError, this will prevent a release from being built and shipped to production, but won't block development or debug builds in the meantime.

Here's what that looks like:

android {

    compileSdkVersion 32

    defaultConfig {

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

    }

    lint {
        abortOnError true
        fatal 'StopShip'
    }
}

That will result in an error if you try to create a release build, which looks something like this:

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

This last step is only necessary if you don't want to ship until SDK Tools for 33 are fixed.

Hak answered 2/7, 2022 at 22:0 Comment(0)
W
5

I have the same issue, with targetSdkVersion 33. Then I update Android Studio to (Android Studio Dolphin | 2021.3.1).

Issue is solved.

Waler answered 20/9, 2022 at 9:59 Comment(3)
I dont know if this solved the mentioned problem. But when I removed Bumblebee and installed Dolphin, I can targetSdkVersion 33 and see source code of some general Android Class based on SDK 33 which is good.Isatin
Yes Solved the issue!! Thank you.Shiksa
yes, seems your mentioned version, also the most current version of Android Studio solved the issueOvertly
O
4

I found out, that under SDK The Android 33 API is missing Sources for Android 33, while Android 32 and lower each has this component there. Not sure, but this may be the cause of the issue.

For now I will stay with 32 API. Seems the Android Studio Lint is in a hurry to use 33 version.enter image description here

Overtly answered 17/6, 2022 at 21:14 Comment(0)
F
2

Have the same issue, xml attribute such as padding, textColor, etc is missing in Android 33 SDK. You have to hardcode the attributes. I have switch back to 32. Think it is a bug of Android studio.

Fantasia answered 7/8, 2022 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.