Reputation: 2910
I am creating an app using nativescript. I have add the android platform as follows
tns platform add android --sdk 22
as I want to build for API level 22.
And when I build the app I get the following error.
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
"Install Android SDK Platform 25" failed.
Where is it getting SDK platform 25 from? How can I overcome this?
Also, do mention how can I build for a specific API level.
Thanks.
Upvotes: 0
Views: 404
Reputation: 1486
Short version:
Add a platform - tns platform add android
State desired compileSdk during build - tns run android --compileSdk 22
or tns build android --compileSdk 22
Longer version:
Adding the android platform to a {N} project only creates the android-studio-project structure. When the gradle script is invoked, the {N} CLI will pass along compileSdk, targetSdk, support libraries version flags to the build.
So doing tns platform add
android is enough to bootstrap the project structure.
When building/running your project: By default, the CLI reads the $ANDROID_HOME/platforms directory to see what Android API level sdks are installed, and will work with the latest supported version. Say if I had android-22, android-23, android-25, android-26, the project will be built against compileSdk 26. If, your latest installed is android-22, then that will be the version your android project will be built against.
But what if you have other platform levels installed? Well, when building/running an android project, you can supply the --compileSdk flag followed by your desired version, and the gradle build will pick that up.
tns run android --compileSdk
22 is what you should run to get the desired results in your case, I assume.
Alternatively, you could override any, or at least most of the Android settings by writing gradle configuration inside the app/App_Resources/Android/app.gradle script, where changes are persistent.
Copied response from https://discourse.nativescript.org/t/nativescript-building-for-a-specific-api-level-android/2140/2?u=pete.k
Upvotes: 1