How to migrate apps to Android P version

Source: Internet
Author: User
Tags deprecated

Android p (API level p) introduces behavioral changes and new features and APIs that can be leveraged in your app. This article outlines the steps for migrating your app to the two key phases of Android P:

1. Ensure compatibility with Android P

Verify that your app is running fully functional on the new version of the platform. At this stage, you do not need to use the new API, and you do not need to change the targetsdkversion of your app, but you may need to make some minor changes.

2. Update your target version and use the Android P feature

When you're ready to take advantage of the new features of the platform, update targetsdkversion to "P", verify that the app still works as expected, and start using the new API.

Android P Upgrade Program

Ensure compatibility with Android P

The goal here is to ensure that your existing apps run as normal on Android p (API level P). Because some platform changes may affect how your app behaves, you may need to make some adjustments, but you don't need to use the new API or change targetsdkversion.

Prepare a device to run Android P

If you have a compatible device (Pixel, Pixel XL, Pixel 2, Pixel 2XL), obtain an Android p system image for your device from the official website, and then follow the instructions to swipe the image into the device.

Perform a compatibility test

Compatibility testing with Android p (API level P) is mostly the same type of test that you perform when you are ready to publish your app.

However, the test has another dimension: Android P introduces some changes to the Android platform, which can affect the behavior of the app or make it impossible to run even if no changes are made to targetsdkversion. Therefore, you must review the key changes in the following table and test any fixes that are implemented to accommodate these changes.

    • Limitations on non-SDK interfaces

Access to specific non-SDK interfaces is now prohibited, whether direct access or indirect access via JNI or reflection. Attempting to access a restricted interface will generate errors such as nosuchfieldexception and nosuchmethodexception. For more information, see Limitations on non-SDK interfaces.

    • Remove the cryptographic Provider

Starting with Android P, the Crypto JCA provider is now removed. Calling Securerandom.getinstance ("Sha1prng", "Crypto") will cause the nosuchproviderexception to be raised.

    • More stringent UTF-8 decoder

In Android P, the UTF-8 decoder for the Java language is stricter than ever and follows the Unicode standard.

    • Prevent idle apps from accessing cameras, microphones, and sensors

The camera, microphone, or sensormanager sensor can no longer be accessed when the app is in an idle state.

Test Android P App

Once you have completed the above preparation, you can build your app and then test it further to ensure that Android p (API level P) is working correctly when it is the target platform. It is then necessary to revisit the core application quality guidelines and test best practices.

If you set Targetsdkversion to p when you build your app, you should be aware of specific platform changes. Even if you don't implement the new features in Android P, some of these changes can still seriously affect the behavior of your app or make it impossible to run at all.

    • Front Desk Service Permissions

Apps that want to use the foreground service now must first request Foreground_service permissions. This is a normal permission, so the system automatically grants this permission to the app that requested the permission. Starting the foreground service without this permission will cause SecurityException.

    • Deprecated Bouncy Castle encryption

Android P deprecated several cryptographic techniques from the bouncy Castle provider and replaced it with the encryption technology provided by the Conscrypt provider. Invoking the getinstance () of the request bouncy Castle provider will generate a nosuchalgorithmexception error. To resolve these errors, do not specify the provider in getinstance () (that is, request the default implementation).

    • Remove direct access to the Build.serial

Now the app that needs the build.serial identifier must request Read_phone_state permissions and then use the new Build.getserial () function in Android P.

    • Sharing WebView Data directory is not allowed

Apps are now not allowed to share a WebView data directory between different processes. If your app has more than one process using any of the other APIs in the WebView, Cookiemanager, or Android.webkit packages, your app will crash when the second process calls the WebView function.

    • SELinux prohibits access to the app's data directory

The system enforces the SELinux sandbox for each app to enforce a per-app SELinux limit for each app's private data catalog. Access to other apps ' data directories is now not allowed directly through the path. Apps can continue to share data using interprocess communication (IPC) mechanisms, including by passing FD.

Compatibility Solutions

If you do not have a compatible device that supports the Android P version, you can access the Huawei Terminal Open Lab cloud test platform for free pixel.

Platform has a complete set of mobile application DevOps solutions, after the Google IO Conference, the first to go online Android P DP2 version of the pixel model, free of charge for Android Green Alliance members use.

Test and resolve Android P version compatibility from 11 items based on Google's official solution.

How to migrate apps to Android P version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.