You may have received a notification from Google requesting you to upgrade your app to target API Level 35 before end of August. This is expected, as Android 15 is scheduled to launch by the end of this year.
- Official reference: Android 15 developer preview: https://developer.android.com/about/versions/15
- Google’s Play Store API policy target dates: https://support.google.com/googleplay/android-developer/answer/11926878
Upgrading your NativeScript project to target Android API Level 35 (Android 15) is crucial to maintain compatibility with the latest Android devices and comply with Google Play Store requirements. This guide will provide you with step-by-step instructions to ensure a smooth upgrade process.
Prerequisites
Before starting, ensure you have:
- A working NativeScript project
- Node.js installed on your system
- Android development environment set up
- Access to your project’s command line
Step 1: Update NativeScript Dependencies
The foundation of your Android 15 upgrade starts with updating your core NativeScript packages. These packages contain the essential bridge between your JavaScript code and the Android platform.
Open your terminal in your project’s root directory and run:
npm update @nativescript/android @nativescript/core
However, for Android 15 compatibility, you’ll want to ensure you’re using version 8.9 or higher. Check your current versions:
npm list @nativescript/android @nativescript/core
If you’re below version 8.9, explicitly install the latest versions:
npm install @nativescript/android@latest @nativescript/core@latest
Why this matters: These packages contain the Android-specific runtime and APIs that your app uses. Version 8.9+ includes support for Android 15’s new features and security requirements.
Step 2: Upgrade the NativeScript CLI
The NativeScript CLI is your command-line toolkit for building, running, and managing your projects. An outdated CLI can cause compatibility issues with newer Android versions.
Update your global NativeScript CLI:
npm install -g @nativescript/cli@latest
Verify the update:
ns --version
You should see version 8.9 or higher for optimal Android 15 support.
Step 3: Configure Android SDK Versions
Now comes the crucial part – telling your project to target Android 15. This happens in your app’s Gradle configuration file, which is like the blueprint that tells the Android build system how to compile your app.
Navigate to your project’s app/App_Resources/Android/app.gradle
file and locate the android
section. Update the compileSdkVersion
and targetSdkVersion
:
android {
compileSdkVersion 35
buildToolsVersion "35.0.0"
defaultConfig {
minSdkVersion 21
targetSdkVersion 35
// ... other configurations
}
}
Understanding the difference:
compileSdkVersion
: The Android API level your app is compiled against (like the “language version” your app speaks)targetSdkVersion
: The Android version your app is designed and tested for (tells Android how to treat your app)
Step 4: Clean Your Project
Before rebuilding, you need to clean out old build artifacts that might conflict with the new Android 15 configuration. This is like clearing your workspace before starting a new project.
Run the NativeScript clean command:
ns clean
This command removes:
- The
platforms
folder (contains platform-specific generated code) - Build cache files
- Temporary compilation artifacts
You might also want to clean your npm cache for good measure:
npm cache clean --force
Step 5: Rebuild Your Project
Now it’s time to rebuild your project with the new Android 15 configuration. You have two options depending on your workflow:
For a simple build:
ns build android
For building and running on a connected device or emulator:
ns run android
What’s happening behind the scenes: NativeScript is now regenerating the Android platform with your new SDK version 35 settings, downloading necessary Android libraries, and compiling your JavaScript code with the updated Android runtime.
Step 6: Test on Real Device
This is the most important step – testing your app on an actual Android device. Emulators are helpful, but real devices reveal issues that might not appear in simulated environments.
Testing Checklist:
- Basic functionality: Navigate through your app’s main features
- Permissions: Ensure camera, location, and storage permissions work correctly
- Performance: Check for any new lag or memory issues
- UI elements: Verify buttons, forms, and layouts display correctly
- Device-specific features: Test features like biometric authentication, if applicable
Troubleshooting Tips
If Your Build Fails:
- Check your Android SDK: Ensure you have Android SDK 35 installed through Android Studio
- Verify Java version: Android 15 requires Java 11 or higher
- Review plugin compatibility: Some third-party plugins might not be compatible with Android 15 yet
If Your App Behaves Differently:
- Check the changelog: Review NativeScript 8.9+ release notes for breaking changes
- Update plugins: Ensure all your NativeScript plugins are compatible with version 8.9+
- Review Android 15 behavior changes: Some Android APIs might behave differently in Android 15
Best Practices for Future Upgrades
- Regular updates: Don’t wait too long between Android version upgrades
- Test incrementally: Upgrade in a separate branch and test thoroughly before merging
- Documentation: Keep notes of any custom configurations that need updating
- Plugin maintenance: Regularly update your NativeScript plugins
Conclusion
Upgrading to Android 15 ensures your NativeScript app stays current with the latest Android features and security requirements. While the process involves several steps, following this guide systematically will help you navigate the upgrade smoothly.
Remember, this upgrade is not just about compliance – it’s about providing your users with the best possible experience on their Android devices. The improved security, performance, and feature set of Android 15 will benefit both you as a developer and your app’s users.