How to use Android 12, Migration of our Android Apps to Android12 (API 31)

Android 12 update
Spread the love

A few months back in 2022 Google Playstore announce to Android DeveloperS that all of apps that service on Google Play Store must update the Android app’s Target API Level 30 to 31

If you don’t update Target API app may refuse to update. 

New Apps on Google Play: Starting from August 2022. 

App Update: Starting from November 2022. 

For security and safety purposes, Google recommends updating Target API Level every year. Please follow the instruction for these updates. 

By now you might have started getting this message on the google play store console: 

Image source: Google Console

Google Play and Android recently announced several new policy updates and technical changes. Review the following recommendations to ensure your app stays up to date and in compliance. 

Here I’ll walk you through what all you need to do to stay updated. 

What is Android 12(API 31) 

Android 12 introduces great new features and APIs for developers. Briefly, Android 12 is more customizable and personalized for you, and has a heavier focus on performance and privacy than Android 11. If you’re familiar with Apple’s personalization tools in its latest iOS versions, that seems to be what Google is trying to emulate in its latest Android version. To clarify Android 12 and API 31 are same. 

 Although the redesigned user interface, which Google is calling Material You, is one of the most easily recognizable changes, there’s a lot going on beneath the surface. Improvements were made to battery life, privacy and security, and other performance features. Now, let’s get into the specifics! 

1. User experience 

Image source: Google

Android 12 introduces a brand-new design language called Material You, helping you to build more personalized, beautiful apps. With this much-awaited user interface refresh, you can customize widgets and change select app icons to look the way you want, so you can make your phone feel more like you. Then, you can set a unique colour palette for your phone that you’ll see everywhere. 

The new unified API lets your app receive rich content from any source: clipboard, keyboard, or drag & drop. 

Android 12 introduces a new app launch animation for all apps that includes a splash screen showing the app icon, and transition to the app itself as well as introduces Rounded Corner. 

API 31 / Android 12 has more tools for creating informative haptic feedback for UI events, delightful gaming effects, and attentional haptics for productivity. 

AppSearch introduced by Android 12 allows applications to index data and search over it with built-in full-text search capabilities. It also allows native search features, retrieval, multi-language support, and relevancy ranking. 

The Game Mode API and interventions allow you to optimize gameplay by prioritizing performance or battery life based on user or game-specific configurations. 

Because calls (both outgoing and incoming) are the most critical to users, hence such notifications are given top ranking in Android 12.  

Moreover, via Android 12, the Pixel device users can now share links to recently viewed web content directly from the Recents screen. 

2. Security and privacy 

Image source: Google

Privacy Dashboard is enabled on supported devices that run Android 12 or higher, in system settings. On this screen, users would be displayed an indicator when apps access location, camera, and microphone information. 

Bluetooth permissions provided by Android 12 make it easier for apps interact with Bluetooth devices, especially for apps that do not need device location access. 

Android 12 also introduces a secure mobile environment named Private Compute Core. It requires explicit permission from the user before it can be shared with Google or any other app or any third party. 

Phishing detection in messaging apps is available for Pixel only. For example, phishing detection can warn users of the following potential risks: Suspicious requests, Untrusted URLs, Malicious attachments, and Links to malicious apps 

3. Media 

Starting in Android 12 (API level 31), the system is compatible for media transcoding & can automatically transcode HEVC (H.265) and HDR (HDR10 and HDR10+) videos recorded on the device to AVC (H.264), a format which is widely compatible with standard players. 

In Android 12 (API level 31), when an app requests audio focus while another app is playing, the system automatically fades out the playing app. 

4. Camera 

In many cases, our device manufacturers have created custom camera effects, like bokeh, HDR, night mode, etc., so that apps can create differentiated experiences. Through a set of vendor extensions, CameraX already supports these custom effects. These same vendor extensions are now exposed directly in Android 12. 

Today, many Android devices come with ultra-high-resolution cameras, typically with Quad or Nona Bayer patterns, which offer excellent low-light performance and image quality. Third-party apps can now take full advantage of these versatile sensors using Android 12’s new platform APIs. 

5. Graphics and images 

With Android 12, RenderEffects can be applied to Views and rendering hierarchies to apply common graphics effects like blurs, colour filters, and shaders

Native animated image decoding in Android 12 / API 31 has been expanded to decode all frames and timing data from images that use the animated GIF and animated WebP file formats. 

6. Performance 

Android 12 feels much more user-friendly than Android 11. Android 12’s updated user interface makes it even more enjoyable to use and switching from an alternate OS has never been easier. Using a cable or a shared Wi-Fi connection, you can transfer your essential data from any phone (even an iPhone). 

After upgrading to Android 12, you’ll also notice that your motions and gestures feel more fluid. Additionally, in addition to the Material You change, you’ll see a notification bar that’s easier to read with a quick glance, so you can see what’s open in the background as well. 

One of the coolest features of Android 12 is the ability to capture a scrolling screenshot. This is exactly what it sounds like. If you’ve ever needed to take multiple screenshots of a long article or a text chain, you can now do so with a single image. When you start taking the screenshot, you’ll have the ability to scroll to capture as much as you need to. 

7. Core functionality 

API 31/ Android 12 allows installer apps to perform automatic app updates without requiring the user to confirm the action. 

Updates to core Java APIs in Android 12 include several new classes of Java being added to the core libraries. 

Play store Policy about API Level 

Every new version of the Android platform improves its user experience, security, and performance. A targetSdkVersion (also known as the target API level) is specified in the manifest file of each app. In the target API level, you indicate how your app will work on different Android versions.   

In addition to providing security, privacy, and performance improvements to users, targeting a recent API level keeps an app compatible with older versions of Android (down to the specified minSdkVersion). 

To provide Android and Google Playstore users with a safe experience, all apps need to meet target API level requirements as mentioned below. 

Android OS version When are apps required to target this API level? 
New app Updated app Existing app 
Android 13 (API level 32) August 1, 2023 November 1, 2023 November 1, 2024 
Android 12 (API level 31) August 1, 2022 November 1, 2022 November 1, 2023 

If your app doesn’t meet the required target API level mentioned by Google Playstore, your apps are impacted in the following ways:   

New app: You will not be able to upload app bundles in Google Play store Console. 

Updated app: You will not be able to upload app bundles or APKs that do not meet the target API level in Google Play store Console. 

Existing app: Your app will not be available on Google Play store to new users with devices running newer Android OS versions than your app’s target API level. New users will not be able to search or install your app from Google Play store. 

However, users who have already installed your app from Google Play store will continue to be able to search, re-install, and use your app.  

How to Migrate from Android 11 (API level 30) to Android 12 (API level 31) 

Step1) Update SDK APIs 

In this step, we need to open our app-level build.gradle file and update the compileSdkVersion and targetSdkVersion to 31 on your Google Play store console. 

Follow the below mentioned steps to update Android 12 SDK: 

  • Go to the menu on Tools > SDK Manager on Android Studio. 
  • On SDK Platforms select Android 12. 
  • On SDK Tools tap select Android SDK Build-Tools 31. 
  • Click the OK button to install the SDK. 
  • Go to the build.gradle on Apps folder and update following script. 
android { 

    compileSdkVersion 31 

  

    defaultConfig { 

        minSdkVersion 23 

        targetSdkVersion 31 

        applicationId "com.example.applicationname" 

        versionCode 1 

        versionName "1.0" 

        resConfigs "en" 

        multiDexEnabled true 

    } 

What is issue for updating API 31? 

You may receive a message like this: 

Manifest merger failed: android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined.  

See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. 

You mut set exported as true if any components need to be accessible from outside of our app (either by OS or other apps). i.e. Our App’s Launcher Activity. 

<activity 

android:name="com.example.sampleapp.views.activities.SplashScreenActivity" 

    android:theme="@style/Theme.Design.Light.NoActionBar" 

    android:exported="true"> 

    <intent-filter> 

        <action android:name="android.intent.action.MAIN" /> 

        <category android:name="android.intent.category.LAUNCHER" /> 

    </intent-filter> 

</activity> 

Still unable to run your app with Android 12 (API 31)? 

If you are working on a production App (creating a new app that was still under processes) and your App codebase has used some third-party libraries, then you will get this error until you individually find what components are not exported properly and export them to Android 12/ API 31. 

After doing this you are all set to use the latest features of API 31/ Android 12 for your app, which are explained below. 

Step2) Sync your app and run it. 

You simply need to disable offline mode in gradle and sync the project & then try to run app on any device. 

Now All Android12 features, and latest updates are in action. 

From Android12 onwards, you can use the new features in all Android components, i.e., Activities, Services, and Broadcast Receivers. 

The next step includes adopting Android 12 features, which are categorised into 3 main heads as follows: 

Step3) Adopt Android 12 features 

Security and Permissions 

  • Bluetooth: If you want to use Bluetooth, you must replace BLUETOOTH & BLUETOOTH_ADMIN permission declarations with BLUETOOTH_SCAN, BLUETOOTH_ADVERTISEMENT, or BLUETOOTH_CONNECT permission declarations. Bluetooth operations no longer require LOCATION runtime permissions. 
  • Location: It is possible for users to request that apps retrieve only approximate location data. The ACCESS_FINE_LOCATION permission must always be requested accompanied by the ACCESS_COARSE_LOCATION permission. 
  • Intent filters: Android:exported must be explicitly declared for activities, services, and broadcast receivers that use intent filters. 
  • Hibernation: In the event that an app has not been used for a long period of time, it may be put into hibernation mode. Hibernation resets your app’s runtime permissions and cache, and you cannot run jobs or alerts. 
  • Pending intent mutability: Your app must specify the mutability of each object in your app. 

User Experience 

  • Custom notifications: The system no longer uses the full notification area for notifications with custom content views, but instead uses a standard template. The template ensures that custom notifications look the same in all states. 
  • Android App Links verification changes: You should ensure that your intent filters include the BROWSABLE category and support HTTPS when using Android App Link verification. 

Performance 

  • Foreground service launch restrictions: In most cases, you won’t be able to start foreground services in the background while your app runs on Android 12 or higher.(except for a few special cases). 
  • Notification trampoline restrictions: In some apps, when users tap notifications, an app component launches that starts the activity the user sees and interacts with. This is known as a notification trampoline.   

Apps must not launch activities from notification trampolines or services. In a service or broadcast receiver, your app cannot call startActivity() after a user taps a notification or action button. 

Step4) Test 

You can run tests on your device or emulator by installing your app. Work through all app flows and focus on system behavior changes. 

Step5) Update 

Adapt code only when needed to resolve issues or adapt behavior. Simply recompile with the same API level as your app originally targeted.  

Update your targetSdkVersion and other build configurations again once Android 12 APIs are final, make any added updates, and test your app. 

Step6) Publish 

 You can now sign, upload, and publish your updated Android App Bundle or APK. 

Click here if you want to upgrade to Android 12 from lower than Android 11 (API level 30) 

App developers have reason to be concerned 

The entire process of migrating from Android 11 to 12 is now clear to you. Nonetheless, this can still be a challenge for new app developers, especially if they are not familiar with app development or even coding!

It is recommended by Google that Target API Level be updated every year for security and safety reasons. Since Android 12 / API 31 is the latest target level API, the guidelines have also been updated. For your app to be approved by Appstore, you need to reread the entire Android App Developer policies documentation. 

There will be more updates in the future. As soon as a new update is launched, Google will roll out new guidelines, so it is a never-ending process. App developers are responsible for checking every detail of the guidelines and ensuring that their apps comply with them. 

This is not a problem, however. Here comes Swing2App the no code app builder to your rescue.  

You can easily create no-code apps that are compatible with every device using Swing2app. This way, you don’t need to worry about the latest Android updates or policy changes. 

With Android 12, you will need to update your app’s design in accordance with the latest policy guidelines (which are constantly updated by Google Play Store). 

With Swing2App, you can create a no-code app effortlessly without the risk of rejection and extra work to upgrade. 

For just $10, Swing2App handles the entire app upload process over the Play store! 

The only thing you need is a brilliant app idea, and Swing2App’s codeless platform to create it. We can then handle the difficult task of publishing and approving the app. 

Conclusion 

Hope we were able to share some valuable information about the Android 12 update!  

If you follow the above-mentioned steps properly you will be able to update to API 31/ Android 12 without any issues. 

Leave a Reply