Skip to content

Android 12 support #9659

@sebj54

Description

@sebj54

Is your feature request related to a problem? Please describe.

Hi NativeScript maintainers :)

I'm currently trying to target and compile my NativeScript with Android 12 (SDK Platform 31).

Describe the solution you'd like

The ideal would be to have this out of the box, but I thinked it was possible by changing only a few configurations (I was wrong).

Describe alternatives you've considered

Here is what I did so far:

Install latest SDK and build tools

sdkmanager --install "platforms;android-31" "build-tools;31.0.0"

I also removed previous versions for platforms and build-tools.

Change target and compile SDK versions in app.gradle:

project.compileSdk = 31
project.targetSdk = 31

android {
  // no change in this object
}

Here is the error I get when trying to compile:

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

I found this related issue: #9639. @rigor789 suggested to uninstall build-tools and reinstall them with version 30. If I do that, I'm still not able to compile. The error is now:

Unable to apply changes on device: 0xxxxxxxxxx4. Error is: The parser encountered some structural problem in the manifest..

I think it's because build-tools 31 are mandatory to compile with platform 31.

I found this related StackOverflow issue: https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted

This issue suggests to rename or add a symlink for two files missing in the latest version (dxand lib/dx.jar). I tested this solution but it does not work. There is also a less upvoted suggestion:

The point is not to downgrade target API level, but to build exactly for API level 31 to prepare and test an app for Android 12!

It looks like DX is removed from SDK in favor of D8.

It looks like that Android Gradle plugin 4.x is not aware of that.

At the moment I see only two solutions:

  • To stay with AGP 4.x, one should copy DX from 30.0.3 to 31.0.0
  • Upgrade AGP to 7.x

I think this is the correct way to support Android 12 but I don't know if this "Android Gradle Plugin" is part of NativeScript or not. My installed Gradle version is 7.2 so I would say yes.

Anything else?

I would be very happy to help as I have an Android 12 phone with me (it's a custom ROM though).

Also, what are the plans for the official support?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions