Migrating Apps to Android P

Posted on

Migrating Apps to Android P

Android P (API degree 28) introduces new options and APIs that you would be able to reap the benefits of in your apps, in addition to new conduct modifications. This doc provides you an outline of the steps emigrate your apps to Android P throughout two key phases:

  1. Guarantee fundamental compatibility with Android confirm that your present app is absolutely purposeful on the brand new model of the platform. At this stage, you don’t use new APIs or change your app’s,targetSdkVersion however minor modifications is likely to be needed.
  2. Goal the brand new platform, compile with the Android P SDK, and construct with Android P options if you find yourself able to reap the benefits of the brand new options of the platform, replace your targetSdkVersionto,28 confirm the app continues to operate as anticipated, after which start utilizing new APIs.

Put together a tool working Android P

When you’ve got a suitable system, get hold of the Android P system picture on your system from the producer. Learn Get Android P for data. Basic directions for flashing a system picture are right here.

You can even obtain the Android P system picture for the Android Emulator. It’s listed within the SDK Supervisor beneath Android P Preview as Google APIs Intel x86 Atom System Picture.

Be aware: The Android P emulator system picture is offered for obtain in Android Studio 3.1 and better; Android Studio 3.2 offers most compatibility. For extra data, see Get the Android P SDK.

Guarantee compatibility with Android P

The target right here is to guarantee that your present app works as-is on Android P (API degree 28). As a result of some platform modifications would possibly have an effect on the best way your app behaves, some changes is likely to be needed, however you don’t want to make use of new APIs or change yourstargetSdkVersion.

Carry out compatibility testing

For essentially the most half, testing compatibility with Android P (API degree 28) entails the identical kind of testing you carry out when getting ready to launch your app. This can be a good time to assessment the Core App High quality Tips and Finest Practices for Testing.

Nonetheless, there’s one other side to testing: Android P introduces modifications to the Android platform that may have an effect on your app’s conduct or break the app altogether, even when you don’t change yourstargetSdkVersion. For that reason, it will be important that you just assessment the important thing modifications in desk 1, and check any fixes that you just implement to accommodate the modifications.

Desk 1. Key modifications that have an effect on all apps working on Android P units.

Change Abstract
Restrictions on non-SDK interfaces Entry to particular non-SDK interfaces is now blocked, whether or not the entry is direct, by way of JNI, or by way of reflection. Makes an attempt to entry restricted interfaces generate errors resemblingNoSuchFieldException and.NoSuchMethodException See Restrictions on Non-SDK Interfaces for particulars.
Removing of Crypto supplier Beginning in Android P, Crypto JCA supplier has been eliminated. Calls to willSecureRandom.getInstance("SHA1PRNG", "Crypto") throw.NoSuchProviderException
Stricter UTF-Eight decoder In Android P, the UTF-Eight decoder for Java language is stricter and follows the Unicode commonplace.
Entry to digital camera, microphone, and sensors blocked for idle apps Whereas apps are idle, they will now not entry digital camera, microphone, or SensorManager sensors.

For a extra intensive checklist of conduct modifications for all apps working on Android P, see the Conduct Modifications doc.

Replace your goal model and use Android P options

This part explains easy methods to allow full help for Android P (API degree 28) by updating your totargetSdkVersion 28 and including new options accessible in Android P.

Along with providing you new APIs, Android P introduces some conduct modifications whenever you replace yours totargetSdkVersion 28. As a result of some conduct modifications would possibly require code modifications to keep away from breakage, you must first perceive how your app is likely to be affected whenever you change the bytargetSdkVersion reviewing all conduct modifications for apps focusing on Android P.

Be aware: The steps described above to guarantee platform compatibility are prerequisite to focusing on your app to Android P, so be sure you full these steps first.

Get the Android P SDK

You may get the SDK packages to construct your app with Android P (API degree 28) utilizing Android Studio 3.1 or increased. For those who don’t want the brand new options in Android P but, and solely need to compile in opposition to that model of the platform, you should use Android Studio 3.1. Android Studio 3.2 offers full help for Android P options.

To get arrange with both model of Android Studio, comply with the steps documented in Arrange the Preview SDK.

Take a look at your Android P app

With the above preparations full, you possibly can construct your app after which check it additional to ensure it really works correctly when focusing on Android P (API degree 28). That is one other good time to assessment the Core App High quality Tips and Finest Practices for Testing.

If you construct your app with the settargetSdkVersion to P, there are particular platform modifications you have to be conscious of. A few of these modifications can considerably have an effect on your app’s conduct and even break your app altogether, even when you don’t implement new options in Android P.

Desk 2 offers an inventory of those modifications with hyperlinks to extra data.

Desk 2. Key modifications that have an effect on apps when istargetSdkVersion set to 28.

Change Abstract
Foreground service permission Apps wanting to make use of foreground companies should now request the FOREGROUND_SERVICE permission first. This can be a regular permission, so the system routinely grants it to the requesting app. Beginning a foreground service with out the permission throws a SecurityException.
Deprecation of Bouncy Fort ciphers Android P deprecates a number of ciphers from the Bouncy Fort supplier in favor of these supplied by the Conscript supplier. Calls to thatgetInstance() request the Bouncy Fort supplier generate errorsNoSuchAlgorithmException. To resolve the errors, don’t specify a supplier in getInstance() (that’s, request the default implementation).
Removing of direct entry to Construct.serial Apps needing the Construct.serial identifier should now request the permissionREAD_PHONE_STATE after which use the brand new techniqueConstruct.getSerial() added in Android P.
Disallowed sharing of WebView knowledge listing Apps can now not share a single WebView knowledge listing throughout processes. In case your app has multiple course of utilizing WebView, CookieManager, or every other API within the android.WebKit bundle, your app will crash when the second course of calls a WebView technique.
Entry to app’s knowledge listing blocked by SELinux The system enforces per-app SELinux sandboxes with per-app SELinux restrictions on every app’s personal knowledge listing. Instantly accessing one other app’s knowledge listing by path is now disallowed. Apps might proceed to share knowledge utilizing IPC mechanisms, together with bypassing FDs.

For a extra intensive checklist of conduct modifications for apps focusing on Android P, see Conduct Modifications doc.

To discover the brand new options and APIs accessible Android P (API degree 28), see Android P Options and APIs.