পূর্ববর্তী রিলিজগুলোর মতোই, অ্যান্ড্রয়েড ১৪-এ এমন কিছু আচরণগত পরিবর্তন রয়েছে যা আপনার অ্যাপকে প্রভাবিত করতে পারে। নিম্নলিখিত আচরণগত পরিবর্তনগুলো শুধুমাত্র সেইসব অ্যাপের জন্য প্রযোজ্য যেগুলো অ্যান্ড্রয়েড ১৪ (এপিআই লেভেল ৩৪) বা তার উচ্চতর সংস্করণকে টার্গেট করছে। যদি আপনার অ্যাপটি অ্যান্ড্রয়েড ১৪ বা তার উচ্চতর সংস্করণকে টার্গেট করে থাকে, তবে প্রযোজ্য ক্ষেত্রে এই আচরণগুলোকে সঠিকভাবে সমর্থন করার জন্য আপনার অ্যাপটি পরিবর্তন করা উচিত।
অ্যাপটির targetSdkVersion নির্বিশেষে Android 14-এ চলমান সমস্ত অ্যাপকে প্রভাবিত করে এমন আচরণগত পরিবর্তনের তালিকাটিও পর্যালোচনা করতে ভুলবেন না।
মূল কার্যকারিতা
ফোরগ্রাউন্ড পরিষেবা প্রকারের প্রয়োজন
If your app targets Android 14 (API level 34) or higher, it must specify at least one foreground service type for each foreground service within your app. You should choose a foreground service type that represents your app's use case. The system expects foreground services that have a particular type to satisfy a particular use case.
If a use case in your app isn't associated with any of these types, it's strongly recommended that you migrate your logic to use WorkManager or user-initiated data transfer jobs.
BluetoothAdapter-এ BLUETOOTH_CONNECT অনুমতির প্রয়োগ
Android 14 (API লেভেল 34) বা উচ্চতরকে লক্ষ্য করে এমন অ্যাপগুলির জন্য BluetoothAdapter getProfileConnectionState() পদ্ধতিতে কল করার সময় Android 14 BLUETOOTH_CONNECT অনুমতি প্রয়োগ করে৷
এই পদ্ধতিটি ইতিমধ্যেই BLUETOOTH_CONNECT অনুমতির প্রয়োজন ছিল, কিন্তু এটি প্রয়োগ করা হয়নি৷ নিম্নলিখিত স্নিপেটে দেখানো হিসাবে আপনার অ্যাপটি আপনার অ্যাপের AndroidManifest.xml ফাইলে BLUETOOTH_CONNECT ঘোষণা করেছে এবং getProfileConnectionState এ কল করার আগে একজন ব্যবহারকারী অনুমতি দিয়েছেন কিনা তা পরীক্ষা করুন ।
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
OpenJDK 17 আপডেট
অ্যান্ড্রয়েড 14 অ্যাপ এবং প্ল্যাটফর্ম ডেভেলপারদের জন্য লাইব্রেরি আপডেট এবং জাভা 17 ভাষা সমর্থন উভয় সহ সর্বশেষ OpenJDK LTS রিলিজের বৈশিষ্ট্যগুলির সাথে সারিবদ্ধ করার জন্য Android এর মূল লাইব্রেরিগুলিকে রিফ্রেশ করার কাজ চালিয়ে যাচ্ছে।
এই পরিবর্তনগুলির মধ্যে কয়েকটি অ্যাপের সামঞ্জস্যকে প্রভাবিত করতে পারে:
- রেগুলার এক্সপ্রেশনে পরিবর্তন : অবৈধ গ্রুপ রেফারেন্স এখন ওপেনজেডিকে-এর শব্দার্থবিদ্যাকে আরও ঘনিষ্ঠভাবে অনুসরণ করার জন্য অননুমোদিত। আপনি নতুন ক্ষেত্রে দেখতে পারেন যেখানে
java.util.regex.Matcherক্লাস দ্বারা একটিIllegalArgumentExceptionনিক্ষেপ করা হয়েছে, তাই রেগুলার এক্সপ্রেশন ব্যবহার করে এমন এলাকাগুলির জন্য আপনার অ্যাপটি পরীক্ষা করা নিশ্চিত করুন। পরীক্ষা করার সময় এই পরিবর্তনটি সক্ষম বা অক্ষম করতে, সামঞ্জস্যপূর্ণ ফ্রেমওয়ার্ক সরঞ্জামগুলি ব্যবহার করেDISALLOW_INVALID_GROUP_REFERENCEপতাকা টগল করুন৷ - UUID হ্যান্ডলিং :
java.util.UUID.fromString()পদ্ধতিটি এখন ইনপুট আর্গুমেন্ট যাচাই করার সময় আরও কঠোর পরীক্ষা করে, তাই আপনি ডিসিরিয়ালাইজেশনের সময় একটিIllegalArgumentExceptionদেখতে পারেন। পরীক্ষা করার সময় এই পরিবর্তনটি সক্ষম বা অক্ষম করতে, সামঞ্জস্যপূর্ণ ফ্রেমওয়ার্ক সরঞ্জামগুলি ব্যবহার করেENABLE_STRICT_VALIDATIONপতাকা টগল করুন৷ - ProGuard সমস্যা : কিছু ক্ষেত্রে,
java.lang.ClassValueক্লাস যোগ করলে সমস্যা দেখা দেয় যদি আপনি ProGuard ব্যবহার করে আপনার অ্যাপকে সঙ্কুচিত, অস্পষ্ট এবং অপ্টিমাইজ করার চেষ্টা করেন। সমস্যাটি একটি Kotlin লাইব্রেরি থেকে উদ্ভূত হয় যাClass.forName("java.lang.ClassValue")ক্লাস ফেরত দেয় কি না তার উপর ভিত্তি করে রানটাইম আচরণ পরিবর্তন করে। যদি আপনার অ্যাপটিjava.lang.ClassValueক্লাস উপলব্ধ না থাকলে রানটাইমের একটি পুরানো সংস্করণের বিপরীতে তৈরি করা হয়, তাহলে এই অপ্টিমাইজেশনগুলিjava.lang.ClassValueথেকে প্রাপ্ত ক্লাসগুলি থেকেcomputeValueপদ্ধতিটি সরিয়ে দিতে পারে।
JobScheduler কলব্যাক এবং নেটওয়ার্ক আচরণকে শক্তিশালী করে।
Since its introduction, JobScheduler expects your app to return from
onStartJob or onStopJob within a few seconds. Prior to Android 14,
if a job runs too long, the job is stopped and fails silently.
If your app targets Android 14 (API level 34) or higher and
exceeds the granted time on the main thread, the app triggers an ANR
with the error message "No response to onStartJob" or
"No response to onStopJob".
This ANR may be a result of 2 scenarios:
1. There is work blocking the main thread, preventing the callbacks onStartJob
or onStopJob from executing and completing within the expected time limit.
2. The developer is running blocking work within the JobScheduler
callback onStartJob or onStopJob, preventing the callback from
completing within the expected time limit.
To address #1, you will need to further debug what is blocking the main thread
when the ANR occurs, you can do this using
ApplicationExitInfo#getTraceInputStream() to get the tombstone
trace when the ANR occurs. If you're able to manually reproduce the ANR,
you can record a system trace and inspect the trace using either
Android Studio or Perfetto to better understand what is running on
the main thread when the ANR occurs.
Note that this can happen when using JobScheduler API directly
or using the androidx library WorkManager.
To address #2, consider migrating to WorkManager, which provides
support for wrapping any processing in onStartJob or onStopJob
in an asynchronous thread.
JobScheduler also introduces a requirement to declare the
ACCESS_NETWORK_STATE permission if using setRequiredNetworkType or
setRequiredNetwork constraint. If your app does not declare the
ACCESS_NETWORK_STATE permission when scheduling the job and is targeting
Android 14 or higher, it will result in a SecurityException.
টাইলস লঞ্চ এপিআই
For apps targeting 14 and higher,
TileService#startActivityAndCollapse(Intent) is deprecated and now throws
an exception when called. If your app launches activities from tiles, use
TileService#startActivityAndCollapse(PendingIntent) instead.
গোপনীয়তা
ছবি এবং ভিডিওতে আংশিক প্রবেশাধিকার
Android 14 introduces Selected Photos Access, which allows users to grant apps access to specific images and videos in their library, rather than granting access to all media of a given type.
This change is only enabled if your app targets Android 14 (API level 34) or higher. If you don't use the photo picker yet, we recommend implementing it in your app to provide a consistent experience for selecting images and videos that also enhances user privacy without having to request any storage permissions.
If you maintain your own gallery picker using storage permissions and need to
maintain full control over your implementation, adapt your implementation
to use the new READ_MEDIA_VISUAL_USER_SELECTED permission. If your app
doesn't use the new permission, the system runs your app in a compatibility
mode.
ব্যবহারকারীর অভিজ্ঞতা
সুরক্ষিত পূর্ণ-স্ক্রিন ইন্টেন্ট বিজ্ঞপ্তি
With Android 11 (API level 30), it was possible for any app to use
Notification.Builder.setFullScreenIntent to send full-screen
intents while the phone is locked. You could auto-grant this on app install by
declaring USE_FULL_SCREEN_INTENT permission in the
AndroidManifest.
Full-screen intent notifications are designed for extremely high-priority
notifications demanding the user's immediate attention, such as an incoming
phone call or alarm clock settings configured by the user. For apps targeting
Android 14 (API level 34) or higher, apps that are allowed to use this
permission are limited to those that provide calling and alarms only. The Google
Play Store revokes default USE_FULL_SCREEN_INTENT permissions for any apps
that don't fit this profile. The deadline for these policy changes is May 31,
2024.
This permission remains enabled for apps installed on the phone before the user updates to Android 14. Users can turn this permission on and off.
You can use the new API
NotificationManager.canUseFullScreenIntent to check if your app
has the permission; if not, your app can use the new intent
ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT to launch the settings
page where users can grant the permission.
নিরাপত্তা
অন্তর্নিহিত এবং বিচারাধীন অভিপ্রায়ের উপর বিধিনিষেধ
অ্যান্ড্রয়েড 14 (এপিআই লেভেল 34) বা উচ্চতরকে টার্গেট করা অ্যাপগুলির জন্য, অ্যান্ড্রয়েড নিম্নলিখিত উপায়ে অভ্যন্তরীণ অ্যাপ উপাদানগুলিতে অন্তর্নিহিত উদ্দেশ্য পাঠানো থেকে অ্যাপগুলিকে সীমাবদ্ধ করে:
- অন্তর্নিহিত উদ্দেশ্যগুলি শুধুমাত্র রপ্তানি করা উপাদানগুলিতে বিতরণ করা হয়। অ্যাপ্লিকেশানগুলিকে হয় অরপ্তানি না হওয়া উপাদানগুলিতে সরবরাহ করার জন্য একটি সুস্পষ্ট অভিপ্রায় ব্যবহার করতে হবে, অথবা উপাদানটিকে রপ্তানি করা হিসাবে চিহ্নিত করতে হবে৷
- যদি একটি অ্যাপ এমন একটি অভিপ্রায়ের সাথে একটি পরিবর্তনযোগ্য মুলতুবি অভিপ্রায় তৈরি করে যা একটি উপাদান বা প্যাকেজ নির্দিষ্ট করে না, তবে সিস্টেমটি একটি ব্যতিক্রম নিক্ষেপ করে৷
এই পরিবর্তনগুলি দূষিত অ্যাপগুলিকে একটি অ্যাপের অভ্যন্তরীণ উপাদানগুলির দ্বারা ব্যবহারের উদ্দেশ্যে করা অন্তর্নিহিত উদ্দেশ্যগুলিকে বাধা দিতে বাধা দেয়৷
উদাহরণস্বরূপ, এখানে একটি অভিপ্রায় ফিল্টার রয়েছে যা আপনার অ্যাপের ম্যানিফেস্ট ফাইলে ঘোষণা করা যেতে পারে:
<activity
android:name=".AppActivity"
android:exported="false">
<intent-filter>
<action android:name="com.example.action.APP_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
যদি আপনার অ্যাপ একটি অন্তর্নিহিত উদ্দেশ্য ব্যবহার করে এই কার্যকলাপটি চালু করার চেষ্টা করে, তাহলে একটি ActivityNotFoundException ব্যতিক্রম নিক্ষেপ করা হবে:
কোটলিন
// Throws an ActivityNotFoundException exception when targeting Android 14. context.startActivity(Intent("com.example.action.APP_ACTION"))
জাভা
// Throws an ActivityNotFoundException exception when targeting Android 14. context.startActivity(new Intent("com.example.action.APP_ACTION"));
অ-রপ্তানি ক্রিয়াকলাপ চালু করতে, আপনার অ্যাপের পরিবর্তে একটি স্পষ্ট অভিপ্রায় ব্যবহার করা উচিত:
কোটলিন
// This makes the intent explicit. val explicitIntent = Intent("com.example.action.APP_ACTION") explicitIntent.apply { package = context.packageName } context.startActivity(explicitIntent)
জাভা
// This makes the intent explicit. Intent explicitIntent = new Intent("com.example.action.APP_ACTION") explicitIntent.setPackage(context.getPackageName()); context.startActivity(explicitIntent);
রানটাইমে নিবন্ধিত ব্রডকাস্ট রিসিভারদের অবশ্যই এক্সপোর্ট আচরণ নির্দিষ্ট করতে হবে।
Apps and services that target Android 14 (API level 34) or higher and use
context-registered receivers are required to specify a flag
to indicate whether or not the receiver should be exported to all other apps on
the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED, respectively.
This requirement helps protect apps from security vulnerabilities by leveraging
the features for these receivers introduced in Android 13.
Exception for receivers that receive only system broadcasts
If your app is registering a receiver only for
system broadcasts through Context#registerReceiver
methods, such as Context#registerReceiver(), then it
shouldn't specify a flag when registering the receiver.
নিরাপদ ডাইনামিক কোড লোডিং
If your app targets Android 14 (API level 34) or higher and uses Dynamic Code Loading (DCL), all dynamically-loaded files must be marked as read-only. Otherwise, the system throws an exception. We recommend that apps avoid dynamically loading code whenever possible, as doing so greatly increases the risk that an app can be compromised by code injection or code tampering.
If you must dynamically load code, use the following approach to set the dynamically-loaded file (such as a DEX, JAR, or APK file) as read-only as soon as the file is opened and before any content is written:
Kotlin
val jar = File("DYNAMICALLY_LOADED_FILE.jar") val os = FileOutputStream(jar) os.use { // Set the file to read-only first to prevent race conditions jar.setReadOnly() // Then write the actual file content } val cl = PathClassLoader(jar, parentClassLoader)
Java
File jar = new File("DYNAMICALLY_LOADED_FILE.jar"); try (FileOutputStream os = new FileOutputStream(jar)) { // Set the file to read-only first to prevent race conditions jar.setReadOnly(); // Then write the actual file content } catch (IOException e) { ... } PathClassLoader cl = new PathClassLoader(jar, parentClassLoader);
Handle dynamically-loaded files that already exist
To prevent exceptions from being thrown for existing dynamically-loaded files, we recommend deleting and recreating the files before you try to dynamically load them again in your app. As you recreate the files, follow the preceding guidance for marking the files read-only at write time. Alternatively, you can re-label the existing files as read-only, but in this case, we strongly recommend that you verify the integrity of the files first (for example, by checking the file's signature against a trusted value), to help protect your app from malicious actions.
ব্যাকগ্রাউন্ড থেকে কার্যক্রম শুরু করার ক্ষেত্রে অতিরিক্ত বিধিনিষেধ
অ্যান্ড্রয়েড 14 (এপিআই লেভেল 34) বা উচ্চতর টার্গেট করা অ্যাপগুলির জন্য, যখন অ্যাপগুলিকে ব্যাকগ্রাউন্ড থেকে ক্রিয়াকলাপ শুরু করার অনুমতি দেওয়া হয় তখন সিস্টেমটি আরও সীমাবদ্ধ করে:
- যখন একটি অ্যাপ
PendingIntent#send()বা অনুরূপ পদ্ধতি ব্যবহার করে একটিPendingIntentপাঠায়, অ্যাপটিকে অবশ্যই বেছে নিতে হবে যদি এটি মুলতুবি থাকা অভিপ্রায় শুরু করার জন্য নিজস্ব ব্যাকগ্রাউন্ড অ্যাক্টিভিটি লঞ্চের সুবিধা দিতে চায়। নির্বাচন করতে, অ্যাপটিকেsetPendingIntentBackgroundActivityStartMode(MODE_BACKGROUND_ACTIVITY_START_ALLOWED)সহ একটিActivityOptionsবান্ডেল পাস করতে হবে। - যখন একটি দৃশ্যমান অ্যাপ
bindService()পদ্ধতি ব্যবহার করে ব্যাকগ্রাউন্ডে থাকা অন্য অ্যাপের একটি পরিষেবাকে আবদ্ধ করে, তখন দৃশ্যমান অ্যাপটিকে অবশ্যই বেছে নিতে হবে যদি এটি আবদ্ধ পরিষেবাতে তার নিজস্ব ব্যাকগ্রাউন্ড কার্যকলাপ লঞ্চের সুবিধা দিতে চায়। নির্বাচন করার জন্য,bindService()পদ্ধতিতে কল করার সময় অ্যাপটিতেBIND_ALLOW_ACTIVITY_STARTSপতাকা অন্তর্ভুক্ত করা উচিত।
এই পরিবর্তনগুলি ব্যাকগ্রাউন্ড থেকে ব্যাঘাতমূলক ক্রিয়াকলাপ শুরু করার জন্য API-এর অপব্যবহার থেকে ক্ষতিকারক অ্যাপগুলিকে প্রতিরোধ করে ব্যবহারকারীদের সুরক্ষার জন্য বিদ্যমান বিধিনিষেধের সেটকে প্রসারিত করে৷
জিপ পাথ ট্র্যাভার্সাল
For apps targeting Android 14 (API level 34) or higher, Android prevents the Zip
Path Traversal Vulnerability in the following way:
ZipFile(String) and
ZipInputStream.getNextEntry() throws a
ZipException if zip file entry names contain ".." or start
with "/".
Apps can opt-out from this validation by calling
dalvik.system.ZipPathValidator.clearCallback().
প্রতিটি মিডিয়াপ্রজেকশন ক্যাপচার সেশনের জন্য ব্যবহারকারীর সম্মতি প্রয়োজন।
Android 14 (API লেভেল 34) বা উচ্চতর টার্গেট করা অ্যাপগুলির জন্য, MediaProjection#createVirtualDisplay দ্বারা নিম্নলিখিত পরিস্থিতিতে যেকোন একটিতে একটি SecurityException নিক্ষেপ করা হয়:
- আপনার অ্যাপটি
MediaProjectionManager#createScreenCaptureIntentথেকে ফেরত আসাIntentক্যাশ করে এবং এটি একাধিকবারMediaProjectionManager#getMediaProjectionএ পাস করে। - আপনার অ্যাপ একই
MediaProjectionদৃষ্টান্তে একাধিকবারMediaProjection#createVirtualDisplayআহ্বান করে।
প্রতিটি ক্যাপচার সেশনের আগে আপনার অ্যাপ ব্যবহারকারীকে সম্মতি দিতে বলতে হবে। একটি একক ক্যাপচার সেশন হল MediaProjection#createVirtualDisplay এ একটি একক আহ্বান, এবং প্রতিটি MediaProjection দৃষ্টান্ত শুধুমাত্র একবার ব্যবহার করতে হবে।
কনফিগারেশন পরিবর্তন হ্যান্ডেল
কনফিগারেশন পরিবর্তনগুলি (যেমন স্ক্রিন ওরিয়েন্টেশন বা স্ক্রীনের আকার পরিবর্তন) পরিচালনা করার জন্য যদি আপনার অ্যাপটিকে MediaProjection#createVirtualDisplay চালু করতে হয়, তাহলে আপনি বিদ্যমান MediaProjection উদাহরণের জন্য VirtualDisplay আপডেট করতে এই পদক্ষেপগুলি অনুসরণ করতে পারেন:
- নতুন প্রস্থ এবং উচ্চতার সাথে
VirtualDisplay#resizeকরুন। -
VirtualDisplay#setSurfaceএ নতুন প্রস্থ এবং উচ্চতা সহ একটি নতুনSurfaceপ্রদান করুন।
একটি কলব্যাক নিবন্ধন করুন
যে ক্ষেত্রে ব্যবহারকারী ক্যাপচার সেশন চালিয়ে যাওয়ার জন্য সম্মতি দেন না সেগুলি পরিচালনা করতে আপনার অ্যাপের একটি কলব্যাক নিবন্ধন করা উচিত। এটি করার জন্য, Callback#onStop প্রয়োগ করুন এবং আপনার অ্যাপকে যেকোনো সম্পর্কিত সংস্থান (যেমন VirtualDisplay এবং Surface ) প্রকাশ করতে দিন।
যদি আপনার অ্যাপ এই কলব্যাকটি নিবন্ধন না করে, MediaProjection#createVirtualDisplay একটি IllegalStateException নিক্ষেপ করে যখন আপনার অ্যাপ এটিকে আহ্বান করে।
আপডেট করা নন-এসডিকে বিধিনিষেধ
Android 14 includes updated lists of restricted non-SDK interfaces based on collaboration with Android developers and the latest internal testing. Whenever possible, we make sure that public alternatives are available before we restrict non-SDK interfaces.
If your app does not target Android 14, some of these changes might not immediately affect you. However, while you can currently use some non-SDK interfaces (depending on your app's target API level), using any non-SDK method or field always carries a high risk of breaking your app.
If you are unsure if your app uses non-SDK interfaces, you can test your app to find out. If your app relies on non-SDK interfaces, you should begin planning a migration to SDK alternatives. Nevertheless, we understand that some apps have valid use cases for using non-SDK interfaces. If you cannot find an alternative to using a non-SDK interface for a feature in your app, you should request a new public API.
To learn more about the changes in this release of Android, see Updates to non-SDK interface restrictions in Android 14. To learn more about non-SDK interfaces generally, see Restrictions on non-SDK interfaces.