Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

If Appium throws Illegal base64 character a while taking an Android screenshot, first inspect the screenshot value returned to your Java test. The reported failure occurs as Selenium converts a screenshot response from Base64 to PNG; it does not, by itself, prove that the Android device or app produced a bad screenshot. Confirm the value is image data, check for line breaks, then investigate web-versus-native context and your installed Appium/Selenium versions.

What the error means—and where to start

The documented incident passed through Selenium’s OutputType.convertFromBase64Png and RemoteWebDriver.getScreenshotAs while retrieving an Appium screenshot. That points first to the screenshot payload or to the client/server conversion path. The exception text alone does not identify the root cause.

The incident was reported with Appium 1.22.3, Java Client 8.2.0, Selenium 4.5.0, Windows 10, Android 12, and Chrome 91. Those are the particulars of one report from October 2022, not a tested reproduction recipe or a statement about current compatibility. The Appium Java Client issue and the related Stack Overflow question and answers document the report and community suggestions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why inspect the returned value first

A Base64 decoder expects encoded image data. If the value is actually an error message, a different response, or otherwise not image data, stripping characters or changing dependencies will not address the underlying problem. Inspect the value at the point your test receives it, before a later decode, file write, HTML embedding, or other conversion can alter it.

#1 Best Overall
Samsung Galaxy A16 4G LTE (128GB + 4GB) International Model SM-A165F/DS Factory Unlocked, 6.7", Dual SIM, 50MP Triple Camera (Case Bundle), Black
  • Please note, this device does not support E-SIM; This 4G model is compatible with all GSM networks worldwide outside of the U.S. In the US, ONLY compatible with T-Mobile and their MVNO's (Metro and Standup). It will NOT work with other CDMA carriers, and it is also not compatible with their MVNO (Visible, Xfinity Mobile, US Mobile, Cricket Wireless, etc).
  • Compatibility with certain third-party devices and accessibility accessories, including some hearing aids, may vary depending on manufacturer support, Bluetooth protocols, software compatibility, and regional firmware limitations. For additional hearing aid compatibility information, please refer to Samsung’s official support documentation.
  • Camera: 50 MP, f/1.8, (wide), 1/2.76", 0.64µm, AF | 50 MP, f/1.8, (wide), 1/2.76", 0.64µm, AF | 2 MP, f/2.4, (macro). Battery: 5000 mAh, non-removable | A power adapter is NOT included.

Inspect the screenshot payload before decoding it

Reduce the test to a screenshot call and inspect the result’s type, length, and a short, safely handled prefix. Avoid logging the entire image: it can be large and may contain sensitive page content. Do not assume that every implementation exposes the same intermediate representation; the following illustrates a diagnostic when your code has the Base64 string itself.

String imageBase64 = /* the Base64 value returned by your screenshot flow */;

System.out.println("screenshot value is null: " + (imageBase64 == null));
if (imageBase64 != null) {
    System.out.println("length: " + imageBase64.length());
    System.out.println("contains LF: " + imageBase64.contains("n"));
    System.out.println("contains CR: " + imageBase64.contains("r"));
    System.out.println("prefix: " + imageBase64.substring(0, Math.min(40, imageBase64.length())));
}

This is an inspection snippet, not a substitute for Appium’s screenshot call. If your code calls getScreenshotAs directly and receives bytes, inspect those bytes or the upstream response in the layer where the encoded text is available. Do not pass a PNG byte array to a Base64 decoder.

  • If the value contains line breaks and is otherwise confirmed to be Base64 image data, remove the line breaks before passing it to a downstream decoder.
  • If the prefix resembles ordinary text, JSON, or an error response rather than image data, investigate the response-producing layer and session/context before attempting a decode.
  • If the value is already image bytes or a saved PNG, follow the relevant file or byte-handling path instead of decoding it again.

Conditional workaround for wrapped Base64

A community answer suggests removing line breaks when they are present. Apply that only after inspection confirms line breaks in the actual string your downstream decoder receives. It is a conditional workaround reported in the discussion, not an established universal cause or fix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
String normalized = imageBase64.replace("r", "").replace("n", "");

Use normalized only for the subsequent Base64 decode in your own processing. Keep the original value while diagnosing so you can compare the response and avoid hiding an unexpected payload. The cited report does not establish that removing other characters, trimming arbitrary text, or changing the image format is appropriate.

Check whether the session is native, hybrid, or web

Screenshot behavior can depend on what Appium is automating. The UiAutomator2 driver supports native, hybrid, and mobile-web apps. Its current documentation says Native mode is applied by default and that providing browserName generally starts Web context mode. For a failure involving Chrome or a web page, establish the active context and review the web screenshot setting; do not apply web-specific advice automatically to a native app.

For Chrome or a web page

  1. Record the active Appium context immediately before the failing screenshot. Confirm whether the test is in a native context or a web context; do not infer it only from the page being visible.
  2. Review how the session is configured, including whether browserName is supplied and whether the session is intended to automate mobile web.
  3. Evaluate the UiAutomator2 nativeWebScreenshot capability/option for a web screenshot scenario. A community answer recommends considering it in that branch. Verify the accepted setting against the documentation for the driver version actually installed.
  4. Repeat the minimal screenshot call without changing unrelated capabilities. If the failure remains, preserve the returned payload and session details for version and response-path investigation.

For a native Android app

Do not treat nativeWebScreenshot as a general native screenshot fix. The community suggestion distinguishes web capture from native apps. Keep the investigation focused on the returned value, screenshot call, and compatible client/server stack unless evidence shows the test is actually running in a web context.

Rank #3
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

See the official UiAutomator2 Driver documentation for the driver’s supported app modes and version compatibility guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify the Appium and Selenium versions as a set

The old discussion includes an individual report that Selenium 4.5.0 worked after Selenium 4.6.0 failed in that person’s setup. That is a historical anecdote, not current official guidance and not proof that downgrading will fix another installation. First identify the versions your build actually resolves, rather than relying only on declared version ranges.

  • Record the Appium server version and installed UiAutomator2 driver version.
  • Record the resolved Appium Java Client and Selenium versions used at runtime.
  • Check the current driver compatibility requirements before changing any dependency. The live UiAutomator2 project documentation says driver major version 5 and later requires Appium 3.
  • Change one relevant variable at a time—such as a client dependency or screenshot mode—and rerun the same minimal test. Keep a record of the before-and-after versions and result.

Do not mix an older thread’s dependency combination with a newer server or driver without checking compatibility. The original incident’s versions describe that incident only; the available reports do not establish a generally recommended Selenium version.

Rank #4
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Build a minimal reproduction and isolate the failing layer

A small test helps distinguish a screenshot retrieval problem from later image processing. Keep the same session setup as the failing test initially, but remove unrelated navigation, assertions, image conversion, and embedding steps. Capture once, then preserve whether the failure occurs during retrieval or only during downstream decoding or writing.

  1. Create the Appium session with the same platform, app/browser mode, and relevant capabilities as the failing test.
  2. Navigate to or open the same target state, then call the screenshot method once.
  3. Record the exception stack, active context, resolved dependency versions, and whether the returned value is text, bytes, or an error response.
  4. Save or decode only after confirming the returned data is image content. If the minimal call succeeds, add the removed processing steps back one at a time.
  5. For a web test, repeat only after evaluating the web-context screenshot branch; for a native test, keep the test in native mode.

This isolates variables; it is not a controlled comparison proving that one context or version is more reliable than another. The cited reports do not provide cross-version or cross-context benchmarks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common symptoms, likely branches, and fixes to try

Symptom What to check Next action
The exception occurs inside Selenium’s Base64-to-PNG conversion path. What value reaches the conversion step, and is it actually Base64 image data? Inspect the payload and the minimal screenshot call before changing device or test-flow settings.
The inspected Base64 string contains line breaks. Whether those breaks are in the exact value supplied to the downstream decoder. Try removing CR/LF from that value; treat this as a conditional community workaround.
The test captures Chrome or a mobile web page. Active Appium context, session configuration, and UiAutomator2 web screenshot behavior. Evaluate nativeWebScreenshot for the web case, using documentation for the installed driver.
The test captures a native app. Whether web-only configuration advice has been applied to a native session. Do not assume the web setting is relevant; inspect the payload and isolate screenshot retrieval.
A version change appears to alter the result. Resolved Selenium and Java Client versions plus server/driver compatibility. Change one version at a time and verify the installed driver’s requirements; do not rely on the 2022 downgrade anecdote as a general fix.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reliability and cost: keep the diagnosis focused

The cited issue and community discussion do not establish a device repair, cable replacement, or physical accessory as a remedy. The evidence points to a screenshot payload/conversion investigation, with context and dependency compatibility as additional branches. Avoid replacing hardware or broadly rewriting the test before confirming where the invalid value first appears.

Best Value
Samsung Galaxy A16 5G 128GB Cell Phone, Unlocked Android Smartphone, Large AMOLED Display, Durable Design, Super Fast Charging, Expandable Storage, US Version, 2025, Blue Black (Renewed)
  • Charger NOT Included, 6.7" Super AMOLED FHD+, 90Hz Refresh Rate, 385 ppi, 800 nits (HBM), 1080x2340px, 5000mAh Battery
  • 128GB, 4GB RAM, microSDXC, Exynos 1330 (5nm), Octa-Core, Mali-G68 MP2 or Mali-G57 MC2 GPU
  • Rear Camera: 50MP, f/1.8 (wide) + 5MP, f/2.2 (ultrawide) + 2MP, f/2.4 (macro), LED flash, panorama, HDR; Front Camera: 13MP, f/2.0, Android 14, up to 6 major Android upgrades, One UI 6.1
  • 3G: HSDPA 850/900/1700(AWS)/1900/2100; 4G LTE: 1/2/3/4/5/7/12/13/14/20/25/26/28/29/30/38/39/40/41/48/66/71, 5G: 2/5/25/41/66/71/77/78 SA/NSA/Sub6/mmWave - Nano-SIM + eSIM
  • US Model – Global Connectivity – Compatible with Most GSM Carriers like T-Mobile, AT&T, MetroPCS, etc. Will Also work with CDMA Carriers Such as Verizon, Straight Talk.

For repeatable diagnosis, retain a compact failure record: Appium server and driver versions, Java Client and Selenium versions, Android version, app or browser mode, active context, exception stack, and a safely limited description of the payload. This makes a dependency or context change comparable without storing or exposing the full screenshot content.

Or skip the browser setup

For screenshots of web pages outside an Appium device session, ScreenshotNeo offers a one-call screenshot API. This does not fix an Appium Base64 conversion error or replace Android device automation; it is an alternative when your requirement is simply to capture a website URL.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for request options. ScreenshotNeo accepts cookie/consent banners and removes known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up free for 1,000 screenshots a month with no card.

FAQ

Does “Illegal base64 character a” prove the Android screenshot is corrupt?

No. The exception identifies a Base64 conversion failure in the reported Java path, but the available incident does not establish whether the device, response payload, or later conversion produced the invalid input.

Should I downgrade Selenium to 4.5.0?

Not on the strength of the old report alone. It records one person’s outcome, not a tested general fix; verify your resolved dependency and Appium/driver compatibility first.

Does ScreenshotNeo take screenshots from my Android app?

No. ScreenshotNeo captures websites from a URL; it is not a replacement for Appium’s native or hybrid Android app automation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.