- android-targetSdkVersion preference not honoured #846
- Comments
- breautek commented Oct 15, 2019
- Bug Report
- Problem
- What is expected to happen?
- What does actually happen?
- Information
- Command or Code
- Environment, Platform, Device
- Version information
- Checklist
- erisu commented Oct 15, 2019 •
- breautek commented Oct 17, 2019
- almothafar commented Oct 17, 2019 •
- No target available android sdk
- (1) Ensure compileSdkVersion matches targetSdkVersion
- (2) Ensure android/project.properties has the correct target
- (3) Ensure android/CordovaLib/project.properties has the correct target
- Android Studio для NDK под Windows
- Установка и настройка Android Studio
- [feature-request] change the default target sdk to (API Level 30) #1006
- Comments
- mosabab commented Jun 25, 2020
- Feature Request
- Motivation Behind Feature
- Feature Description
- Alternatives or Workarounds
- breautek commented Jun 25, 2020 •
- jcesarmobile commented Jun 27, 2020
- mosabab commented Jun 29, 2020
- mosabab commented Jun 29, 2020 •
- breautek commented Jun 29, 2020
- mosabab commented Jun 29, 2020
- barkermn01 commented Jul 2, 2020 •
- mosabab commented Jul 2, 2020 •
- timbru31 commented Jul 2, 2020
- barkermn01 commented Jul 2, 2020 •
- breautek commented Jul 2, 2020 •
android-targetSdkVersion preference not honoured #846
Comments
breautek commented Oct 15, 2019
Bug Report
Problem
Using the android-targetSdkVersion preference does not work.
What is expected to happen?
The project should use the desired android sdk version as defined in the preference, or fallback to the platform default if not set.
What does actually happen?
The preference is not considered, and the target sdk always gets set to 28 .
Information
The code that appears to gets the desired target can be found here:
Lines 50 to 70 in c35a990
// Get valid target from framework/project.properties if run from this repo |
// Otherwise get target from project.properties file within a generated cordova-android project |
module . exports . get_target = function ( ) < |
function extractFromFile ( filePath ) < |
var target = shelljs . grep ( / \b target= / , filePath ) ; |
if ( ! target ) < |
throw new Error ( ‘Could not find android target within: ‘ + filePath ) ; |
> |
return target . split ( ‘=’ ) [ 1 ] . trim ( ) ; |
> |
var repo_file = path . join ( REPO_ROOT , ‘framework’ , ‘project.properties’ ) ; |
if ( fs . existsSync ( repo_file ) ) < |
return extractFromFile ( repo_file ) ; |
> |
var project_file = path . join ( PROJECT_ROOT , ‘project.properties’ ) ; |
if ( fs . existsSync ( project_file ) ) < |
// if no target found, we’re probably in a project and project.properties is in PROJECT_ROOT. |
return extractFromFile ( project_file ) ; |
> |
throw new Error ( ‘Could not find android target in either ‘ + repo_file + ‘ nor ‘ + project_file ) ; |
> ; |
Originally discovered after I suggested to use the android-targetSdkVersion preference on #830
Command or Code
This is the full config.xml :
Environment, Platform, Device
Version information
Cordova 9.0.0 (cordova-lib@9.0.1)
cordova-android 8.1.0
Ubuntu 18.04
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
The text was updated successfully, but these errors were encountered:
erisu commented Oct 15, 2019 •
@breautek I believe placing
breautek commented Oct 17, 2019
@almothafar if you run cordova requirements android
You should see the following output:
Can you confirm if android-29 is listed? If it’s missing then there might be something wrong with the android sdk installation.
almothafar commented Oct 17, 2019 •
When I do sdkmanager —list I get:
After that I ran ionic cordova requirements android :
First, why it still ask for for API level android-28 not for API level android-29 ?
Second point, actually, as I understand ionic cordova requirements android should be reading from platforms after it is added, in the directory, while I still building it, in ionic project, no platforms and plugins folder generated yet, and I run the command ionic cordova build android —no-interactive —confirm —prod —aot —minifyjs —minifycss —optimizejs —release —buildConfig=build.json — -d immediately.
In your example I see android-28 in the list, could you please remove it, run build again, see if that added again?
because if I add platforms;android-28 I still get the same sdkmanager —list && ionic cordova requirements android result, but the build continues!
Edit: false alarm, I was reading wrong console log, when I add android-28 actually I get target listed:
Источник
No target available android sdk
Adding to the importance of resolving this issue is very soon Google store won’t accept submission of sdk level less than 30.
This is not related to this issue. Targeting API 30 still works via android-targetSdkVersion preference, so that’s not a problem. Additionally we will bump our default target SDKs on our major releases to match the requirement of Google Play store.
The issue described in this ticket is Cordova will still attempt to the default platform SDK (currently API 29) even when targetSdkVersion is set to a different API level. So the current workaround is to simply have both platform 29 & 30 installed.
I’ve had a chance to do some digging on the cause and I’ve found 3 things that Cordova tooling must do:
(1) Ensure compileSdkVersion matches targetSdkVersion
compileSdkVersion is the SDK that the application is compiled against, while the targetSdkVersion is an assertion that you’ve tested your application at the target SDK level for compatibility. If the platform API level is higher of the target, then the platform will enable backwards-compatibility behaviours.
There isn’t any real reason to have a compileSdkVersion set that is different than the targetSdkVersion and doing so can cause an unstable application. Currently, the android-targetSdkVersion overrides but doesn’t modify compileSdkVersion creating this possibility. Cordova should force compileSdkVersion and targetSdkVersion to be equal.
There is currently no config.xml preference to set the compileSdkVersion , and the lack of this feature should remain. There is a cdvCompileSdkVersion cordova gradle flag, which I think should become deprecated and potentially removed in cordova-android@10 and replaced with a cdvTargetSdkVersion flag to match the config.xml ‘s android-targetSdkVersion preference.
(2) Ensure android/project.properties has the correct target
Currently, Cordova does not modify the target attribute inside /platforms/android/project.properties and it remains set to android-29 which will cause the Android Gradle Plugin (AGP) to download Platform 29.
(3) Ensure android/CordovaLib/project.properties has the correct target
Currently, Cordova does not modify the target attribute inside /platforms/android/CordovaLib/project.properties and it remains set to android-29 which will cause AGP to download Platform 29.
Additionally, a warning should be printed for when the SDK is overridden and uses a value other than the Cordova default target SDK, similar to the min sdk override warning. Using an alternate SDK level is not really a supported feature, so this preference is more-or-less «use at your own risk» (and really should be documented as such).
All 3 actions must be done in order for the AGP to not download API 29.
I cannot give any timeline for when I’ll personally be able to do the above, but I’ll support any PR that does what is described above.
ICYMI: You can workaround this issue by installing both Platform 29 & 30. You can still build APKs targeted against API 30.
Источник
Android Studio для NDK под Windows
На днях я обнаружил, что версия Android Studio неуклонно стремится к единице, в связи с чем задумался об изучении этого инструмента. Чтобы не было скучно, я решил поделиться своим опытом и собранными граблями в виде статьи-туториала.
Сразу хочу оговориться, что я не являюсь гуру Android-разработки, поэтому каких-либо откровений в тексте вы не найдете. Зато тут есть пошаговая инструкция по установке и настройке Android Studio под Windows и созданию простейшего проекта с использованием Android NDK.
Также заранее предупреждаю: статья получилась большой и очень подробной (честно, сам не ожидал), даже несмотря на то, что я почти все скриншоты и некоторые листинги кода спрятал под спойлеры.
На момент написания последней версией Android Studio была 0.8.1, для последующих версий необходимые действия могут отличаться от нижеописанных (очень надеюсь, что в лучшую сторону).
Установка и настройка Android Studio
1. Необходимо установить JDK (Java Development Kit) и JRE (Java Runtime Environment).
Раньше Android SDK поддерживал только JDK версии 6, но теперь это в прошлом. Поддерживается 7 и даже 8 (по крайней мере, именно 8-ю версию я указал в качестве JAVA_HOME и в настройках Android Studio, и никаких проблем не испытал).
JRE же нужен для запуска самой студии. У меня она использует версию 7.
Скачать JDK и JRE версий больше 6 можно с сайта Oracle.
Переменную JAVA_HOME теперь, вроде бы, можно не устанавливать, так как в Android Studio мы будем в настройках прописывать путь к JDK. Но я ее установил. Для этого нужно:
- Зайти в Панель управления\Система и безопасность\Система, выбрать слева Дополнительные параметры системы, в открывшемся диалоге найти кнопку Переменные среды.
- Создать системную или пользовательскую переменную JAVA_HOME и указать для нее путь к JDK. У меня указан вот такой путь: C:\Program Files\Java\jdk1.8.0_05.
2. Если у вас установлен Android SDK.
В комплекте с Android Studio идет свой Android SDK. И, если вы хотите использовать именно его, то в некоторых случаях может случиться странное. Например, у меня при обновлении SDK через SDK Manager часть файлов записывалась в старую папку, и возникли проблемы, когда я эту папку удалил. Скорее всего это произошло из-за того, что в реестре хранился ключ с путем к старой папке. Поэтому имеет смысл почистить реестр. Для этого нужно запустить regedit.exe и найти HKEY_LOCAL_MACHINE\Software\Android SDK Tools для 32-битных машин либо HKEY_LOCAL_MACHINE\Software\Wow6432Node\Android SDK Tools для 64-битных машин и удалить Android SDK Tools. Если в реестре вашей системы таких ключей нет, то все в порядке.
Если у вас установлена переменная среды ANDROID_SDK_HOME и вы хотите, чтобы она указывала на старую установку, то, по идее, это не должно стать проблемой, так как при настройке Android Studio мы укажем ей путь к SDK. Проблемы могут возникнуть, если эту переменную использует какое-либо из приложений, входящих в состав Android SDK.
3. Теперь переходим к установке Android Studio.
Нужно скачать Android Studio для вашей системы с официальной страницы и установить ее. По умолчанию, если выбрать «Установить только для меня» ставится в \Users\ \AppData\Local\Android\android-studio\, иначе ставится в \Program FIles (x86)\Android\android-studio\. Можно выбрать и другую папку.
После установки запускаем Android Studio.
Источник
[feature-request] change the default target sdk to (API Level 30) #1006
Comments
mosabab commented Jun 25, 2020
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
The text was updated successfully, but these errors were encountered:
breautek commented Jun 25, 2020 •
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 Jun 27, 2020
SDK 30 is not even released yet, is at beta stage. Won’t be released until some point of Q3
mosabab commented Jun 29, 2020
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 Jun 29, 2020 •
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 ):
breautek commented Jun 29, 2020
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 Jun 29, 2020
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 Jul 2, 2020 •
@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.
mosabab commented Jul 2, 2020 •
@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.
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 Jul 2, 2020
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 Jul 2, 2020 •
@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 Jul 2, 2020 •
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 👍 otherwise, feel free to report bugs, I’ll add them to the cordova-android@10 milestone.
Источник