apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

[feature-request] change the default target sdk to (API Level 30) #1006

Closed mosabab closed 3 years ago

mosabab commented 3 years ago

Feature Request

Motivation Behind Feature

The latest version of Android Studio allow you to set the latest API level available which is API LEVEL 30.

Feature Description

It is good idea to increase the default target sdk to 30.

Alternatives or Workarounds

breautek commented 3 years ago

This is considered a breaking change so it won't be in the cordova-android@9 release (which is currently in the voting process).

If you want to target SDK 30 in your app however, you can do so by using the android-targetSdkVersion preference for the time being.

jcesarmobile commented 3 years ago

SDK 30 is not even released yet, is at beta stage. Won’t be released until some point of Q3

mosabab commented 3 years ago

I am not sure if it still in beta or not, because I can see it added recently to the latest version of Android Studio as API LEVEL 30 (Android 10+ R)

mosabab commented 3 years ago

If you install a new clean version of Android Studio, you will see that Android 10+ (R) API LEVEL 30 is the default version, I don't think it is beta release.

Please check this image for details: (New clean installed version of Android Studio v.4 ): Untitled-1

breautek commented 3 years ago

It's misleading, it's still a beta release. You can view their release timeline here: https://developer.android.com/preview/overview

The expected final release is sometime in Q3.

mosabab commented 3 years ago

It's misleading, it's still a beta release. You can view their release timeline here: https://developer.android.com/preview/overview

The expected final release is sometime in Q3.

Thanks for clarification

barkermn01 commented 3 years ago

@breautek you shared a link to the android 11 version "Android 11 Developer Preview" (the title on the page).

SDK 30 is not exclusively for Android 11 but also for Android 10.0, I would assume this is because of the changes Google are making to the Bluetooth API because of COVID19 track & trace app problems. so it appears they have rushed out SDK 30 to work with Android 10.0+ and if they need more or exclusive to 11 SDK features, it will come out as 31. as the image above shows, it is for Android 10.0+ also as the AVD Manager shows it.

image

mosabab commented 3 years ago

@breautek you shared a link to the android 11 version "Android 11 Developer Preview" (the title on the page).

SDK 30 is not exclusively for Android 11 but also for Android 10.0, I would assume this is because of the changes Google are making to the Bluetooth API because of COVID19 track & trace app problems. so it appears they have rushed out SDK 30 to work with Android 10.0+ and if they need more or exclusive to 11 SDK features, it will come out as 31. as the image above shows, it is for Android 10.0+ also as the AVD Manager shows it.

image

That what i mentioned before API level 30 is not only for android 11, it is also for new version of android 10+ R

We can see it in Androod Studio SDK manager

timbru31 commented 3 years ago

Nevertheless a default target SDK bump needs to happen in a major version (i.e., cordova-android@10) and given that we've just release v9 this is not likely to happen any time soon and rather around the general release of Android 11.
Like Norman said, you can already use the android-targetSdkVersion pref.

But yes, we are aware of this new SDK version and Android 11 being in development.

barkermn01 commented 3 years ago

@mosabab yeah, I agree with you and think the claim below is wrong

It's misleading, it's still a beta release. You can view their release timeline here: https://developer.android.com/preview/overview

I was just pointing out, that SDK 30 is not a Beta, and what's more likely Google accidentally released something that was beta and changed it to 10.0+ to mislead people, or it was a deliberate action by Google for a reason and I speculated on what that reason could be.

@timbru31 are versions, not branches? would it not be possible to fork/branch from v9 and create a v10 alpha with just the SDK support update in?

breautek commented 3 years ago

It's not misleading at all, it's clearly described in the timeline. Just saying the Android Studio UI is misleading. The API is in a "final preview" state. It's still a beta release. Things can still change from now and the final release targeting Q3 then (although should not be breaking). Changes at this current time will be mainly for incompatibility fixes.

You see the update in Android Studio because as of Beta 1 (Which was June), apps can now be published targeting API 30, but the API is still in a beta state. Beta 3 (August) will be release candidate, and an undisclosed date (sometime in Q3) for the final release of SDKs as well as the Android 11 platform. Cordova doesn't support beta packages.

would it not be possible to fork/branch from v9 and create a v10 alpha with just the SDK support update in?

I personally don't see the need for that unless if there are many changes required to support API 30, which may or may not be the case. I'd personally just start off by using the android-targetSdkVersion. If it works then :+1: otherwise, feel free to report bugs, I'll add them to the cordova-android@10 milestone.

NitzDKoder commented 3 years ago

any update on this? I use cordova and have below issue when target==30. https://bugs.chromium.org/p/chromium/issues/detail?id=1101250

dpogue commented 3 years ago

any update on this? I use cordova and have below issue when target==30. https://bugs.chromium.org/p/chromium/issues/detail?id=1101250

Ooof, that sounds bad. If Google is actually going to require using WebViewAssetsLoader then we have no choice but to move Cordova to AndroidX, which will break a tonne of plugins 😞

jcesarmobile commented 3 years ago

as an alternative you can use cordova-plugin-ionic-webview, as it uses http/https to serve the content it's not affected by this problem, but it requires to convert the file:// urls to http/https urls with window.Ionic.WebView.convertFileSrc()

Anyway, next cordova major should move to AndroidX, some plugins will break, but a lot of other plugins are holding back because they don't want to update to use AndroidX until it's the default on Cordova and that makes the plugin use out of date support libraries. Or some plugin authors are maintaining two versions of the same plugin, one for AndroidX and another for the old support libraries.

jbfrequence commented 3 years ago

Hi all,

Any updates on this issue ?

"If you want to target SDK 30 in your app however, you can do so by using the android-targetSdkVersion preference for the time being." It does not work if I changed the config.xml or even any build-extras.gradle

    <platform name="android">
        <preference name="android-targetSdkVersion" value="30" />

or/and (build-extras.gradle)

android {

    compileSdkVersion 30

    defaultConfig {
    targetSdkVersion 30

When adding platform android@9.0.0, the following is still displayed

Adding android project... Creating Cordova project for the Android platform: Path: platforms\android Package: com.jby.frequence Name: FREQUENCE Activity: MainActivity Android target: android-29

Thanks

NitzDKoder commented 3 years ago

@breautek any plans to update target to 30? Please confirm.. We have blocker when target 30 is made..

https://bugs.chromium.org/p/chromium/issues/detail?id=1101250

ath0mas commented 3 years ago

(to track it here) Google recently blogged about future Google Play requiring targetSdk update to 30 to be August and November 2021: https://android-developers.googleblog.com/2020/11/new-android-app-bundle-and-target-api.html

wearcheck commented 3 years ago

I have a brand new Pixel 4a 5G and I can't install my API level 29 cordova app. Not compatible. When will we be able to target API 30?

Fever905 commented 3 years ago

I have a brand new Pixel 4a 5G and I can't install my API level 29 cordova app. Not compatible. When will we be able to target API 30?

You can still target 30 - I use these preferences:

    preference name="android-minSdkVersion" value="19" 
    preference name="android-maxSdkVersion" value="30" 
    preference name="android-targetSdkVersion" value="30"

My app works on Android 11 and shows the targer SDK as 30 (see pic) image

breautek commented 3 years ago

FYI: By specifying android-maxSdkVersion you're intentionally making your app unavailable to newer releases (e.g. whenever SDK 31 devices comes out) unless you make an update with the bumped max sdk. Maybe this is what you want, but if you want to make your app available automatically you can omit the android-maxSdkVersion preference. Google does not recommend specifying the max SDK version for this reason.

Fever905 commented 3 years ago

@breautek Thanks for the tip! :) :+1:

lunedam-git commented 3 years ago

I have a strange problem around targeting SDK 30. I'm using cordov-android@9 and setting the Adndroid SDK via preferences:

preference name="android-minSdkVersion" value="24" 
preference name="android-targetSdkVersion" value="30"

The app builds, is successfully signed and zip aligned. However the APK will not install on any Android 11 device I have (Galaxy S10 with developer mode and emulator). I've tried sideloading and also using adb install. When sideloading there's no useful feedback, just "App not installed", but using adb it reports that the APK isn't signed. Despite the fact that it most certainly is.

If I drop the targetSdkVersion back down to 29 then all is sweetness and light again.

gjsalot commented 3 years ago

@lunedam-git you are likely signing with the signature scheme v1, as of api 30 you must sign with signature scheme v2

lunedam-git commented 3 years ago

@gjsalot Thankyou!

mobilemarines commented 3 years ago

The preference <preference name="android-targetSdkVersion" value="30" /> in the config.xml has no effect because node_modules\cordova-android\bin\templates\project\build.gradle sets defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default which will always overwrite your config.xml setting. The overwrite is done in node_modules\cordova-android\bin\templates\project\app\build.gradle

// Set property defaults after extension .gradle files.
ext.cdvCompileSdkVersion = cdvCompileSdkVersion == null ? (
    defaultCompileSdkVersion == null
        ? privateHelpers.getProjectTarget()
        : defaultCompileSdkVersion
) : Integer.parseInt('' + cdvCompileSdkVersion);

As workaround you can modify your build-extra.gradle as follows:

allprojects {
    // Overwrite Cordova fixed target SDK 29
    project.ext {
      defaultTargetSdkVersion=30
      defaultCompileSdkVersion=30
    }
}

When building your project there is still displayed Android target: android-29 (which is not true). But when analyzing the APKs AndroidManifest.xml in Android Studio (Build/Analyze APK) you can see that platformBuildVersionCode="30" now.

EinfachHans commented 3 years ago

See this Android Blog:

From August 2021, the Google Play Console will require all new apps to:

Publish with the Android App Bundle format. Utilize Play Asset Delivery or Play Feature Delivery to deliver assets or features that exceed download size of 150MB. Expansion files (OBBs) will no longer be supported for new apps. Target API level 30 (Android 11) or above and adjust for behavioral changes. Requirements for updates to existing apps

From November 2021, updates to existing apps will be required to target API level 30 or above and adjust for behavioral changes in Android 11. Existing apps that are not receiving updates are unaffected and can continue to be downloaded from the Play Store.

erisu commented 3 years ago

Merged to master: https://github.com/apache/cordova-android/pull/1182

infacto commented 3 years ago

Since Google is enforcing API 30, we should publish a corresponding Cordova version as soon as possible.

Starting August 2021, new apps will be required to target API level 30 (Android 11) and use the Android App Bundle publishing format. Starting November 2021, all app updates will be required to target API level 30 (Android 11).

This message appears on Play Store Console. Also see the Google News.

erisu commented 3 years ago