সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
আপনি console JavaScript APIs ব্যবহার করে আপনার JavaScript ডিবাগ করতে পারেন এবং Logcat-এ আউটপুট বার্তা দেখতে পারেন। আপনি যদি Firebug বা ওয়েব ইন্সপেক্টর দিয়ে ওয়েব পেজ ডিবাগ করার সাথে পরিচিত হন, তাহলে আপনি সম্ভবত console (যেমন console.log() ) ব্যবহার করার সাথে পরিচিত। অ্যান্ড্রয়েডের ওয়েবকিট ফ্রেমওয়ার্ক বেশিরভাগ একই API গুলিকে সমর্থন করে, যাতে আপনি আপনার WebView ডিবাগ করার সময় আপনার ওয়েব পৃষ্ঠা থেকে লগগুলি পেতে পারেন৷ এই বিভাগে ডিবাগিংয়ের জন্য কনসোল APIগুলি কীভাবে ব্যবহার করবেন তা বর্ণনা করে।
WebView এ কনসোল API ব্যবহার করুন
WebView এ ডিবাগ করার সময় কনসোল APIগুলিও সমর্থিত। আপনাকে অবশ্যই একটি WebChromeClient প্রদান করতে হবে যা Logcat-এ কনসোল বার্তাগুলির জন্য onConsoleMessage() পদ্ধতি প্রয়োগ করে৷ তারপর, setWebChromeClient() দিয়ে আপনার WebView এ WebChromeClient প্রয়োগ করুন। আরও তথ্যের জন্য, WebView ডকুমেন্টেশন দেখুন।
নিম্নলিখিত উদাহরণ দেখায় কিভাবে WebView এ কনসোল API ব্যবহার করতে হয়:
কোটলিন
valmyWebView:WebView=findViewById(R.id.webview)myWebView.webChromeClient=object:WebChromeClient(){overridefunonConsoleMessage(message:ConsoleMessage):Boolean{Log.d("MyApplication","${message.message()} -- From line "+"${message.lineNumber()} of ${message.sourceId()}")returntrue}}
জাভা
WebViewmyWebView=findViewById(R.id.webview);myWebView.setWebChromeClient(newWebChromeClient(){@OverridepublicbooleanonConsoleMessage(ConsoleMessageconsoleMessage){Log.d("MyApplication",consoleMessage.message()+" -- From line "+consoleMessage.lineNumber()+" of "+consoleMessage.sourceId());returntrue;}});
ConsoleMessage একটি MessageLevel অবজেক্টও অন্তর্ভুক্ত থাকে যাতে কনসোল বার্তার ধরণ বিতরণ করা হচ্ছে। আপনি বার্তাটির তীব্রতা নির্ণয় করতে messageLevel() দিয়ে বার্তা স্তরটি জিজ্ঞাসা করতে পারেন, তারপর উপযুক্ত Log পদ্ধতি ব্যবহার করুন বা অন্যান্য উপযুক্ত পদক্ষেপ নিতে পারেন।
আপনি onConsoleMessage(String, int, String) বা onConsoleMessage(ConsoleMessage) ব্যবহার করছেন না কেন, আপনি যখন আপনার ওয়েব পৃষ্ঠায় একটি কনসোল পদ্ধতি চালান, তখন Android উপযুক্ত onConsoleMessage() পদ্ধতিতে কল করে যাতে আপনি ত্রুটিটি রিপোর্ট করতে পারেন৷ উদাহরণস্বরূপ, উদাহরণ কোডের সাথে, একটি Logcat বার্তা মুদ্রিত হয় যা দেখতে এইরকম:
Hello World -- From line 82 of http://www.example.com/hello.html
চিত্র 1. একটি ডিভাইসে ইনস্টল করা অ্যাপের জন্য WebView DevTools আইকন।
DevTools থেকে, ফ্ল্যাগ আইটেমটিতে ক্লিক করুন এবং আপনি সক্ষম বা অক্ষম করতে চান এমন কোনো পরীক্ষামূলক বৈশিষ্ট্য অনুসন্ধান করুন৷ পরিবর্তনটি ডিভাইসের সমস্ত WebView দৃষ্টান্তে প্রযোজ্য।
নতুন বৈশিষ্ট্যগুলির সাথে পরীক্ষা শুরু করতে আপনার অ্যাপটি বন্ধ করুন এবং পুনরায় চালু করুন৷
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-13 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","easyToUnderstand","thumb-up"],["আমার সমস্যার সমাধান হয়েছে","solvedMyProblem","thumb-up"],["অন্যান্য","otherUp","thumb-up"]],[["এতে আমার প্রয়োজনীয় তথ্য নেই","missingTheInformationINeed","thumb-down"],["খুব জটিল / অনেক ধাপ","tooComplicatedTooManySteps","thumb-down"],["পুরনো","outOfDate","thumb-down"],["অনুবাদ সংক্রান্ত সমস্যা","translationIssue","thumb-down"],["নমুনা / কোড সংক্রান্ত সমস্যা","samplesCodeIssue","thumb-down"],["অন্যান্য","otherDown","thumb-down"]],["2025-08-13 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Debug web apps\n\nYou can debug your JavaScript using the `console` JavaScript APIs and view the\noutput messages in Logcat. If you're familiar with debugging web pages with\nFirebug or Web Inspector, then you're probably familiar with using `console`\n(such as `console.log()`). Android's WebKit framework supports most of the same\nAPIs, so you can receive logs from your web page when debugging in your\n[`WebView`](/reference/android/webkit/WebView). This section describes how to use the console APIs for\ndebugging.\n| **Note:** You can also remotely debug your web pages in WebView with the Chrome Developer Tools. For more information, see [Remote debugging\n| WebViews](https://developer.chrome.com/docs/devtools/remote-debugging/webviews/).\n\nUse console APIs in WebView\n---------------------------\n\nThe console APIs are also supported when debugging in `WebView`. You must\nprovide a [`WebChromeClient`](/reference/android/webkit/WebChromeClient) that implements the\n[`onConsoleMessage()`](/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)) method for console messages to appear in Logcat.\nThen, apply the `WebChromeClient` to your `WebView` with\n[`setWebChromeClient()`](/reference/android/webkit/WebView#setWebChromeClient(android.webkit.WebChromeClient)). For more information, see the [`WebView`](/reference/android/webkit/WebView)\ndocumentation.\n\nThe following example shows how to use console APIs in `WebView`: \n\n### Kotlin\n\n val myWebView: WebView = findViewById(R.id.webview)\n myWebView.webChromeClient = object : WebChromeClient() {\n\n override fun onConsoleMessage(message: ConsoleMessage): Boolean {\n Log.d(\"MyApplication\", \"${message.message()} -- From line \" +\n \"${message.lineNumber()} of ${message.sourceId()}\")\n return true\n }\n }\n\n### Java\n\n WebView myWebView = findViewById(R.id.webview);\n myWebView.setWebChromeClient(new WebChromeClient() {\n @Override\n public boolean onConsoleMessage(ConsoleMessage consoleMessage) {\n Log.d(\"MyApplication\", consoleMessage.message() + \" -- From line \" +\n consoleMessage.lineNumber() + \" of \" + consoleMessage.sourceId());\n return true;\n }\n });\n\n| **Warning:** Don't include personally-identifiable information (PII) in console messages.\n\nThe [`ConsoleMessage`](/reference/android/webkit/ConsoleMessage) also includes a [`MessageLevel`](/reference/android/webkit/ConsoleMessage.MessageLevel) object\nto indicate the type of console message being delivered. You can query the\nmessage level with [`messageLevel()`](/reference/android/webkit/ConsoleMessage#messageLevel()) to determine the severity of the\nmessage, then use the appropriate [`Log`](/reference/android/util/Log) method or take other appropriate\nactions.\n\nWhether you're using\n[`onConsoleMessage(String, int, String)`](/reference/android/webkit/WebChromeClient#onConsoleMessage(java.lang.String,%20int,%20java.lang.String)) or\n[`onConsoleMessage(ConsoleMessage)`](/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)), when you execute a console method in\nyour web page, Android calls the appropriate `onConsoleMessage()` method so\nyou can report the error. For example, with the example code, a Logcat message\nis printed that looks like this: \n\n Hello World -- From line 82 of http://www.example.com/hello.html\n\n| **Note:** Logcat is a tool that dumps a log of system messages. The messages include a stack trace when the device throws an error as well as log messages written from your application and those written using the JavaScript `console` APIs. For more information, see [View logs with Logcat](/studio/debug/am-logcat).\n\nThe following are additional resources related to debugging:\n\n- [Remote debug Android devices](https://developer.chrome.com/docs/devtools/remote-debugging/)\n- [Debug your app](/studio/debug)\n\nTest experimental web features\n------------------------------\n\nSimilar to Google Chrome's `chrome://flags` page, you can also test experimental\nweb features in `WebView`.\n\nTo do this, take the following steps:\n\n1. [Install one of the `WebView` pre-release channels](https://chromium.googlesource.com/chromium/src/+/HEAD/android_webview/docs/prerelease.md)\n (beta, dev, or canary){:.external}.\n\n2. [Switch the `WebView` channel](https://chromium.googlesource.com/chromium/src/+/HEAD/android_webview/docs/prerelease.md#trichrome-beta) on your test device to the\n installed pre-release channel.\n\n3. Click the **WebView DevTools** launcher.\n\n **Figure 1.** WebView DevTools icon for app installed on a device.\n4. From DevTools, click the **Flags** item and search for any experimental\n features you'd like to enable or disable. The change applies to all\n `WebView` instances on the device.\n\n5. Stop and restart your app to start testing with the new features.\n\nFor more information about toggling flags, see the\n[`WebView` DevTools documentation](https://chromium.googlesource.com/chromium/src/+/HEAD/android_webview/docs/developer-ui.md#Flag-UI)."]]