Berti Informatica azienda leader nel settore dell'informatica e del Networking, senza tralasciare App, Grafica e WebDesign

Blog

Update your target version and use Android O features

Update your target version and use Android O features

This section explains how to enable full support for Android O by updating your targetSdkVersion to 26 and adding new features available in Android O.

In addition to offering you new APIs, Android O introduces some behavior changes when you update your targetSdkVersion to 26. Because some behavior changes might require code changes to avoid breakage, you should first understand how your app might be affected when you change the targetSdkVersion by reviewing all behavior changes for apps targeting Android O.

Note: The steps described above to ensure platform compatibility are prerequisite to targeting your app to Android O, so be sure you complete those steps first.

Get the Android O SDK
You can get the SDK packages to build your app with Android O using either Android Studio 2.3 or the Android Studio 3.0 preview. However, only Android Studio 3.0 includes tools to help you with Android O features such as adaptive icons and downloadable fonts. If you don’t need those features yet, then you can use the stable version of Android Studio 2.3 to build your app with Android O and use the new APIs.

To get setup with either version of Android Studio, follow these steps:

Launch Android Studio and open the SDK Manager by clicking Tools > Android > SDK Manager.
In the SDK Platforms tab, check Show Package Details. Below Android O Preview check the following:
Android SDK Platform O
Google APIs Intel x86 Atom System Image (only required for the emulator)
Switch to the SDK Tools tab and check all items that have updates available (click each checkbox that shows a dash ). This should include the following that are required:
Android SDK Build-Tools 26.0.0
Android SDK Platform-Tools 26.0.0
Android Emulator 26.0.0
Click OK to install all the selected SDK packages.
Now you’re ready to start building with Android O.

Update your build configuration
Update compileSdkVersion, buildToolsVersion, targetSdkVersion, and the Support Library version with the following versions:

android {
compileSdkVersion 26
buildToolsVersion ’26.0.0′

defaultConfig {
targetSdkVersion 26
}

}

dependencies {
compile ‘com.android.support:appcompat-v7:26.0.0-beta2′
}

// REQUIRED: Google’s new Maven repo is required for the latest
// support library that is compatible with Android O
repositories {
maven {
url ‘https://maven.google.com’
// Alternative URL is ‘https://dl.google.com/dl/android/maven2/’
}
}
Remove broadcast receivers from your manifest file
Because Android O introduces new limitations for broadcast receivers, you should remove any broadcast receivers that are registered for implicit broadcast intents. Leaving them in place does not break your app at build-time or runtime, but they have no effect when your app runs on Android O.

Explicit broadcast intents—those that only your app can respond to—continue to work the same on Android O.

There are exceptions to this new restriction. For a list of implicit broadcasts that still work in apps targeting Android O, see Implicit Broadcast Exceptions.

Test your Android O app
With the above preparations complete, you can build your app and then test it further to make sure it works properly when targeting Android O. This is another good time to review the Core App Quality Guidelines and Best Practices for Testing.

When you build your app with the targetSdkVersion set to 26, there are specific platform changes you should be aware of. Some of these changes can significantly affect your app’s behavior or even break your app altogether, even if you do not implement new features in Android O.

Table 2 provides a list of these changes with links to more information.

Table 2. Key changes that affect apps when targetSdkVersion is set to 26.
Change Summary Further reference
Privacy Android O does not support use of the net.dns1, net.dns2, net.dns3, or net.dns4 system properities. Behavior Changes: Privacy
Writable and Executable Segments Enforced For native libraries, Android O enforces the rule that data shouldn’t be executable, and code shouldn’t be writable. Behavior Changes: Native Libraries
ELF header and section validation The dynamic linker checks more values in the ELF header and section headers, and fails if they are invalid. Behavior Changes: Native Libraries
Notifications Apps targeting Android O version of the SDK must implement one or more notification channels to post notifications to users. API Overview: Notifications
The List.sort() method Implementations of this method may no longer call Collections.sort(), or your app will throw an exception due to stack overflow. Behavior Changes: Collection handling
The Collections.sort() method In List implementations, Collections.sort() now throws a ConcurrentModificationException. Behavior Changes: Collection handling
For a more extensive list of behavior changes in Android O, see Android O Behavior Changes.

To explore the new features and APIs available with Android O, see Android O Features and APIs.

 

Per ulteriori approfondimenti consulta la pagina ufficiale qui.

L’Azienda
BERTI Informatica nasce nel Marzo del 2003 dalla voglia dell’attuale Amministratore Maurizio Berti di creare un’azienda capace di offrire alla propria clientela Serietà, Efficacia,Professionalità ed Innovazione. Ormai pronta a festeggiare il decimo anno di attività, Berti Informatica lavora intensamente alla continua ricerca di migliorarsi per diventare una realtà consolidata nel difficile settore informatico. Una crescita costante che ha visto la nostra piccola attività individuale mettersi a confronto e collaborare con realtà di grandi dimensioni senza difficoltà; una piccola realtà che ad oggi serve oltre 600 clienti molti dei quali di importanti proporzioni.
Login

0571 55440
338 9678541

info@bertiinformatica.com

Via Provinciale Cerretese n° 57, 50050 Cerreto Guidi (Fi)