পূর্ববর্তী রিলিজের মতো, Android 14-এ এমন আচরণের পরিবর্তন অন্তর্ভুক্ত রয়েছে যা আপনার অ্যাপকে প্রভাবিত করতে পারে। নিম্নলিখিত আচরণ পরিবর্তনগুলি শুধুমাত্র Android 14 (API স্তর 34) বা উচ্চতরকে লক্ষ্য করে এমন অ্যাপগুলিতে প্রযোজ্য। যদি আপনার অ্যাপটি Android 14 বা তার বেশির দিকে লক্ষ্য করে থাকে, তাহলে প্রযোজ্য ক্ষেত্রে এই আচরণগুলিকে সঠিকভাবে সমর্থন করার জন্য আপনার অ্যাপটি সংশোধন করা উচিত।
অ্যাপ্লিকেশানের 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
.
টাইলস লঞ্চ API
14 এবং উচ্চতর টার্গেট করা অ্যাপ্লিকেশানগুলির জন্য, TileService#startActivityAndCollapse(Intent)
বাতিল করা হয়েছে এবং এখন কল করার সময় একটি ব্যতিক্রম থ্রো করে৷ যদি আপনার অ্যাপটি টাইলস থেকে ক্রিয়াকলাপ চালু করে, তাহলে পরিবর্তে TileService#startActivityAndCollapse(PendingIntent)
ব্যবহার করুন।
গোপনীয়তা
ফটো এবং ভিডিও আংশিক অ্যাক্সেস
অ্যান্ড্রয়েড 14 নির্বাচিত ফটো অ্যাক্সেস প্রবর্তন করে, যা ব্যবহারকারীদের একটি প্রদত্ত ধরণের সমস্ত মিডিয়াতে অ্যাক্সেস দেওয়ার পরিবর্তে তাদের লাইব্রেরিতে নির্দিষ্ট চিত্র এবং ভিডিওগুলিতে অ্যাপ্লিকেশনগুলিকে অ্যাক্সেস দেওয়ার অনুমতি দেয়।
আপনার অ্যাপটি Android 14 (API লেভেল 34) বা উচ্চতরকে লক্ষ্য করলেই এই পরিবর্তনটি সক্ষম হবে। আপনি যদি এখনও ফটো পিকার ব্যবহার না করেন, তাহলে আমরা কোনও স্টোরেজ অনুমতির অনুরোধ না করেই ব্যবহারকারীর গোপনীয়তা বাড়ায় এমন ছবি এবং ভিডিও নির্বাচন করার জন্য একটি সামঞ্জস্যপূর্ণ অভিজ্ঞতা প্রদানের জন্য এটিকে আপনার অ্যাপে প্রয়োগ করার পরামর্শ দিই।
আপনি যদি স্টোরেজ অনুমতিগুলি ব্যবহার করে আপনার নিজস্ব গ্যালারি পিকার বজায় রাখেন এবং আপনার বাস্তবায়নের উপর সম্পূর্ণ নিয়ন্ত্রণ বজায় রাখতে চান, তাহলে নতুন READ_MEDIA_VISUAL_USER_SELECTED
অনুমতি ব্যবহার করতে আপনার বাস্তবায়ন মানিয়ে নিন । যদি আপনার অ্যাপটি নতুন অনুমতি ব্যবহার না করে, তাহলে সিস্টেমটি আপনার অ্যাপটিকে একটি সামঞ্জস্যপূর্ণ মোডে চালায়।
ব্যবহারকারীর অভিজ্ঞতা
পূর্ণ-স্ক্রীন ইন্টেন্ট বিজ্ঞপ্তিগুলি সুরক্ষিত করুন
Android 11 (API লেভেল 30) এর সাথে, ফোন লক থাকা অবস্থায় যেকোন অ্যাপের জন্য Notification.Builder.setFullScreenIntent
ব্যবহার করে ফুল-স্ক্রিন ইন্টেন্ট পাঠানো সম্ভব ছিল। আপনি AndroidManifest-এ USE_FULL_SCREEN_INTENT
অনুমতি ঘোষণা করে অ্যাপ ইনস্টলে এটি স্বয়ংক্রিয়ভাবে মঞ্জুর করতে পারেন।
পূর্ণ-স্ক্রীন অভিপ্রায় বিজ্ঞপ্তিগুলি ব্যবহারকারীর অবিলম্বে মনোযোগ দাবি করে অত্যন্ত উচ্চ-প্রধান বিজ্ঞপ্তিগুলির জন্য ডিজাইন করা হয়েছে, যেমন একটি ইনকামিং ফোন কল বা ব্যবহারকারীর দ্বারা কনফিগার করা অ্যালার্ম ঘড়ি সেটিংস। Android 14 (API লেভেল 34) বা উচ্চতর টার্গেট করা অ্যাপ্লিকেশানগুলির জন্য, যে অ্যাপগুলিকে এই অনুমতি ব্যবহার করার অনুমতি দেওয়া হয়েছে শুধুমাত্র সেইগুলির মধ্যেই সীমাবদ্ধ যেগুলি কলিং এবং অ্যালার্ম প্রদান করে৷ Google Play স্টোর ডিফল্ট USE_FULL_SCREEN_INTENT
অনুমতি প্রত্যাহার করে যে কোনও অ্যাপ এই প্রোফাইলের সাথে খাপ খায় না৷ এই নীতি পরিবর্তনের সময়সীমা মে 31, 2024 ।
ব্যবহারকারী Android 14-এ আপডেট করার আগে ফোনে ইনস্টল করা অ্যাপগুলির জন্য এই অনুমতিটি সক্রিয় থাকে৷ ব্যবহারকারীরা এই অনুমতিটি চালু এবং বন্ধ করতে পারেন৷
আপনার অ্যাপটির অনুমতি আছে কিনা তা পরীক্ষা করতে আপনি নতুন API NotificationManager.canUseFullScreenIntent
ব্যবহার করতে পারেন; যদি তা না হয়, আপনার অ্যাপটি সেটিংস পৃষ্ঠা চালু করতে নতুন অভিপ্রায় ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT
ব্যবহার করতে পারে যেখানে ব্যবহারকারীরা অনুমতি দিতে পারেন।
নিরাপত্তা
অন্তর্নিহিত এবং মুলতুবি অভিপ্রায়ে সীমাবদ্ধতা
For apps targeting Android 14 (API level 34) or higher, Android restricts apps from sending implicit intents to internal app components in the following ways:
- Implicit intents are only delivered to exported components. Apps must either use an explicit intent to deliver to unexported components, or mark the component as exported.
- If an app creates a mutable pending intent with an intent that doesn't specify a component or package, the system throws an exception.
These changes prevent malicious apps from intercepting implicit intents that are intended for use by an app's internal components.
For example, here is an intent filter that could be declared in your app's manifest file:
<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>
If your app tried to launch this activity using an implicit intent, an
ActivityNotFoundException
exception would be thrown:
Kotlin
// Throws an ActivityNotFoundException exception when targeting Android 14. context.startActivity(Intent("com.example.action.APP_ACTION"))
Java
// Throws an ActivityNotFoundException exception when targeting Android 14. context.startActivity(new Intent("com.example.action.APP_ACTION"));
To launch the non-exported activity, your app should use an explicit intent instead:
Kotlin
// This makes the intent explicit. val explicitIntent = Intent("com.example.action.APP_ACTION") explicitIntent.apply { package = context.packageName } context.startActivity(explicitIntent)
Java
// 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-এর অপব্যবহার থেকে ক্ষতিকারক অ্যাপগুলিকে প্রতিরোধ করে ব্যবহারকারীদের সুরক্ষার জন্য বিদ্যমান বিধিনিষেধের সেটকে প্রসারিত করে৷
জিপ পাথ ট্রাভার্সাল
Android 14 (API লেভেল 34) বা উচ্চতর টার্গেট করা অ্যাপগুলির জন্য, Android নিম্নলিখিত উপায়ে Zip Path Traversal Vulnerability রোধ করে: ZipFile(String)
এবং ZipInputStream.getNextEntry()
একটি ZipException
থ্রো করে যদি জিপ ফাইলের এন্ট্রি নামগুলিতে ".." থাকে বা শুরু হয় "/" দিয়ে।
অ্যাপগুলি dalvik.system.ZipPathValidator.clearCallback()
কল করে এই বৈধতা থেকে অপ্ট-আউট করতে পারে৷
প্রতিটি MediaProjection ক্যাপচার সেশনের জন্য ব্যবহারকারীর সম্মতি প্রয়োজন
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
নিক্ষেপ করে যখন আপনার অ্যাপ এটিকে আহ্বান করে।
নন-SDK সীমাবদ্ধতা আপডেট করা হয়েছে
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.
অ্যান্ড্রয়েডের এই প্রকাশের পরিবর্তনগুলি সম্পর্কে আরও জানতে, Android 14-এ নন-SDK ইন্টারফেস সীমাবদ্ধতার আপডেটগুলি দেখুন। সাধারণত নন-SDK ইন্টারফেস সম্পর্কে আরও জানতে, নন-SDK ইন্টারফেসের উপর সীমাবদ্ধতা দেখুন।