apache / cordova-android

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

7.1.4 defaults to android-27 #588

Closed maurocolella closed 4 years ago

maurocolella commented 5 years ago

It seems that the android-targetSdkVersion is ignored in 7.1.4 if it exceeds android-27.

Some libraries have started to require android-28.

Please advise.

janpio commented 5 years ago

Please define "some libraries". Was this different in 7.1.3 (or 7.1.2, 7.1.1, ...)? How can this be reproduced?

maurocolella commented 5 years ago

1) For example, dependencies of cordova-plugin-crosswalk-webview such as the android support library.

See: https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/issues/207 https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/issues/205#issuecomment-371669478

2) Not sure.

3) In your config.xml, add:

    <plugin name="cordova-plugin-device" spec="^2.0.2">
        <variable name="android-minSdkVersion" value="19" />
        <variable name="android-targetSdkVersion" value="28" />
    </plugin>

Then cordova add platform android.

Build files are generated for an android-27 compile target.

jcesarmobile commented 5 years ago

Those should be preferences, not plugin variables, and they should be on the root, not inside a plugin

<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="28" />
maurocolella commented 5 years ago

Thank you for the clarification. Build files are still generated for android-27.

jcesarmobile commented 5 years ago

which files?

maurocolella commented 5 years ago

The build.gradle at the root of my cordova project.

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        maven {
             url "https://jitpack.io"
        }
        jcenter()
    }
    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="26.0.1" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
    }
}
brodybits commented 5 years ago

@maurocolella what you see in build.gradle are default values. You should see the correct values in the uses-sdk element in platforms/android/app/src/main/AndroidManifest.xml.

When I tried with the recommended preferences along with cordova-plugin-crosswalk-webview, I got platforms/android/app/src/main/AndroidManifest.xml with the correct values:

    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />

In case you continue to see an issue a demo project would be really helpful.

dpogue commented 5 years ago

I'll just note here that Cordova-Android 7.x is not compatible with the Android API 28 build tools, so you might run into issues trying to target them.

maurocolella commented 5 years ago

Well, thank you @dpogue .

It appears that the android support library mentioned above doesn't explicitly declare targets. cordova/platforms/android/app/src/main/cordova-android-support-gradle-release

Also, @brodybits, in the same AndroidManifest.xml I get: <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />

So, considering that at least one of these is affecting others, could we be looking at perhaps a bug with the support libraries as well as a misconfiguration on my part? https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/issues/205#issuecomment-371669478

I am unable to create a test case right now, but I'll try, as time permits, to reproduce the issue in an isolated case in the few coming days.

brodybits commented 5 years ago

I think this is a manifestation of #508 - Inconsistent handling of min/target SDK values

I just added the bug label.

Riyaz0001 commented 5 years ago

simply add this plugin solved this problem: cordova-android-support-gradle-release

newbie78 commented 4 years ago

simply add this plugin solved this problem: cordova-android-support-gradle-release

it's not worked for me

newbie78 commented 4 years ago

how to change AndroidManifest.xml minSdkVersion? i'm add

    <platform name="android">
        <preference name="android-minSdkVersion" value="15" />
        <preference name="android-targetSdkVersion" value="19" />

in config.xml rm & add platform then build an get error in /home/alpine/project/src-cordova/platforms/android/CordovaLib/build/intermediates/library_manifest/debug/AndroidManifest.xml i'm get

<uses-sdk android:minSdkVersion="19" />

then install ordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=15

error when build still here

breautek commented 4 years ago

You really should upgrade to cordova-android@8, which by default targets android 28.

Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 19 declared in library

This is caused something that is using a lower min sdk and it conflicting with another package. You can override it, but it may cause fatal in your app so I wouldn't recommend doing so.

<preference name="android-targetSdkVersion" value="19" />

This is also going to be problematic. This should be at least 28. Which google enforces as of November 1, 2019 for all apps intended to be deployed to the Google Play Store. See https://support.google.com/googleplay/android-developer/answer/113469#targetsdk for more information.

newbie78 commented 4 years ago

i use jeduan/cordova-plugin-facebook4 in the project. in plugin.xml i'm found

<preference name="android-minSdkVersion" value="15" />

how can i'm use the facebook SDK another way?

and i'm use cordova-android@latest in the project

thanx!

newbie78 commented 4 years ago

Hello again. has anyone found a solution to the problem of mismatch of the minimum sdk version? or a workaround?

breautek commented 4 years ago

@newbie78 What you're talking about is unrelated to this issue. Please open a new ticket, or for support, it's better to join the cordova slack community.

breautek commented 4 years ago

Regarding the android-targetSdkVersion, PR https://github.com/apache/cordova-android/pull/849 should address that issue. There is issue already documented for preference tag at https://github.com/apache/cordova-android/issues/846

cordova-android 7.x will always default to android-27. cordova-android 8 will default (and expect) android-28.

For the reasons above, I'm closing this ticket.