You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/08/04 14:28:15 UTC

[GitHub] [cordova-android] goffioul opened a new issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

goffioul opened a new issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310


   I used to have the following in my `config.xml`, while using build tools 29.x:
   ```
   <preference name="android-minSdkVersion" value="23" />
   <preference name="android-targetSdkVersion" value="25" />
   ```
   
   This doesn't work anymore with cordova-android 10. The above config leads to the following in `platforms/android/cdv-gradle-config.json`:
   ```
   "SDK_VERSION": 25
   ```
   
   And `platforms/android/app/build.gradle` contains:
   ```
   targetSdkVersion cordovaConfig.SDK_VERSION
   compileSdkVersion cordovaConfig.SDK_VERSION
   ```
   
   So it seems now impossible to have targetSdk != compileSdk. This can be annoying as you may need to use newer compile SDK due to the use of support libraries (e.g. appcompat), but your app may not be ready to target the same newer API level.
   
   On the other hand, using a lower compile SDK (like 25 in the example above) actually leads to compilation error, due to the requirement of the support libraries.
   
   I understand the reason for bumping the target SDK to 30, but Play Store is not the only way to deploy apps on Android, especially on systems that do not use the Google ecosystem. And even then, and unsupported `android-targetSdkVersion` value should probably error earlier in the process, or just be ignored when adding the platform.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] goffioul commented on issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

Posted by GitBox <gi...@apache.org>.
goffioul commented on issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310#issuecomment-892836737


   First, I tried with `android-targetSdkVersion == 23`, which was my original config. This fails to compile with
   ```
   platforms/android/CordovaLib/src/org/apache/cordova/PluginManager.java:336: error: cannot find symbol
               if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                                                               ^
   ```
   
   Then I tried with `android-targetSdkVersion == 25`, which is the lowest API level of the devices targetted by my app (these devices are not Google-enabled). This fails again to compile with
   ```
   > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
      > Android resource linking failed
        ERROR:.../.gradle/caches/transforms-3/88a490903787e53e545ff1ce21c3b715/transformed/appcompat-1.3.0/res/values-v26/values-v26.xml:5:5-8:13: AAPT: error: resource android:attr/colorError not found.
            
        ERROR:.../.gradle/caches/transforms-3/88a490903787e53e545ff1ce21c3b715/transformed/appcompat-1.3.0/res/values-v26/values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
            
        ERROR:.../.gradle/caches/transforms-3/88a490903787e53e545ff1ce21c3b715/transformed/appcompat-1.3.0/res/values-v26/values-v26.xml:13:5-16:13: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
            
        ERROR:.../.gradle/caches/transforms-3/88a490903787e53e545ff1ce21c3b715/transformed/appcompat-1.3.0/res/values-v28/values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
            
        ERROR:.../.gradle/caches/transforms-3/88a490903787e53e545ff1ce21c3b715/transformed/appcompat-1.3.0/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
   ```
   
   AFAIK, the dependency on appcompat is coming from cordova itself. There are other similar errors coming from a dependency on `androidx.core:core:1.3.2` that is injected by one of my custom plugins.
   
   For the record, using `android-targetSdkVersion == 28` works fine (compilation-wise).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310#issuecomment-892802205






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310#issuecomment-892873071


   The `AAPT` errors are likely a result of using an unsupported version of build tools. I don't think this is related to the compile SDK version. For example cordova-android@10 is updated to support API 30, and as such, it also needs build tools version 30. The minimum build tools version required is `30.0.3` as that was what was available at the time of release.
   
   For the `cannot find symbol` error:
   
   ```
   platforms/android/CordovaLib/src/org/apache/cordova/PluginManager.java:336: error: cannot find symbol
               if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
   ```
   
   Cordova itself has supports min SDK 22 (If I recall correctly... whatever API level android 5.1 is), but expects the user to use the default configured compile/target SDK, therefore it may use APIs introduced later than API 22. For instance, `Build.VERSION_CODES.N` was added in API 24, therefore you'll need to use the compile SDK 24 at least for the `PluginManager`. Other parts of the codebase, or other plugins may require a even later compile SDK. Apache-maintaned codebases on any plugins intended to be ran on `cordova-android@10` may use anything up to API 30, assuming there is a compatibility API available, or a defensive check to ensure the device can actually run that code.
   
   I'd try ensuring that you're using build tools version 30 first. Don't forget to check your `PATH` system variable. Note that cordova-android@10.0.1 contains bug fixes regarding build tool settings.
   
   If it doesn't work, then you may have to stick with using an older version of the cordova-android platform and potentially an older version of the CLI, or update the app itself to allow it to support modern versions of the SDK. Alternatively, you can fork cordova-android to make adjustments for your specific use case.
   
   Unfortunately the Apache volunteers don't have the resources to support non-google deployments and the variance that brings. Because majority of Cordova users are using Cordova to deploy to the Google app store, we don't make an active effort to support anything that Google itself doesn't support. In otherwords, if Google cuts off an API level and refuses builds, then we don't bother trying to support that API level.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] goffioul commented on issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

Posted by GitBox <gi...@apache.org>.
goffioul commented on issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310#issuecomment-892889446


   I *am* using build-tools 30.0.3, this is actually the only build-tools version installed in my Android SDK. I am also using cordova-android@10.0.1.
   
   For the rest, my understanding is then that you shouldn't even expose target/compile/min SDK as configurable, as it appears that cordova expects and will only work with the default value.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] goffioul commented on issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

Posted by GitBox <gi...@apache.org>.
goffioul commented on issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310#issuecomment-892836737






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1310: Unable to set targetSdk != compileSdk, fail to compile with targetSdk < 30

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1310:
URL: https://github.com/apache/cordova-android/issues/1310#issuecomment-892802205


   This change introduced in cordova-android@10 was intentional in effort to uniform and simplify the API that Cordova provides.
   
   The rationale behind this change is that we didn't see any **good** reason to keep the two settings as two independent fields and they were often a source of confusion or errors when they are misconfigured.
   
   Having a Target SDK that is > than the Compile SDK is simply invalid. You cannot target something that you're not compiling against.
   
   On the other hand, having a Target SDK that is less than the Compile SDK is valid, but we saw no reason why someone would want to have a mismatch Target/Compile SDK. If they wanted to test against a newer API, then it's best to set the both the target and compile SDK.
   
   Having said that, this decision is by no means final. The stance that we took is "We'll make the change, release it, and if it becomes a problem, then we'll bring back the independent settings". So I'd like to understand your use case better. Perhaps expand on
   
   > ...you may need to use newer compile SDK due to the use of support libraries (e.g. appcompat)...
   
   Isn't these libraries independent of the compile SDK? Looking at the [android docs](https://developer.android.com/jetpack/androidx/versions) at a variety of different androidx packages, I don't ever recall (nor can I find anything that states you need a specific compileSdk) to use them.
   
   Kind regards,
   Norman


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org