Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiaomi MiUI: java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml #994

Closed
siddharths2710 opened this issue Dec 10, 2019 · 24 comments

Comments

@siddharths2710
Copy link

OS: Ubuntu 16.04
Android: Version 5.0.2
Mode of running: Run scrcpy without installation

On running the program without installation, the bottom keys are missing from the display (Please zoom in the image):

scrcpy_issue1-min

Please check the log that appears after executing ./run x

INFO: scrcpy 1.12 <https://github.com/Genymobile/scrcpy>
551 KB/s (26234 bytes in 0.046s)
java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml: open failed: ENOENT (No such file or directory)
	at libcore.io.IoBridge.open(IoBridge.java:456)
	at java.io.FileInputStream.<init>(FileInputStream.java:76)
	at java.io.FileInputStream.<init>(FileInputStream.java:103)
	at java.io.FileReader.<init>(FileReader.java:66)
	at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108)
	at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126)
	at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59)
	at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31)
	at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111)
	at android.content.res.MiuiResources.<clinit>(MiuiResources.java:29)
	at android.content.res.Resources.getSystem(Resources.java:259)
	at android.app.LoadedApk.<init>(LoadedApk.java:197)
	at android.app.ContextImpl.createSystemContext(ContextImpl.java:2214)
	at android.app.ActivityThread.getSystemContext(ActivityThread.java:1812)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.genymobile.scrcpy.Workarounds.fillAppInfo(Workarounds.java:66)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:56)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:34)
	at com.genymobile.scrcpy.Server.main(Server.java:163)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:329)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
	at libcore.io.Posix.open(Native Method)
	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
	at libcore.io.IoBridge.open(IoBridge.java:442)
	... 21 more
INFO: Initial texture: 1080x1920
@siddharths2710
Copy link
Author

Upon trying adb shell ls /data/, it says opendir failed, Permission denied. Could this be the issue?
Unfortunately I'm not able to execute adb root for the device :(

@siddharths2710 siddharths2710 changed the title Bottom Input Keys are missing Missing input keys Dec 10, 2019
@hafizidev
Copy link

I ran into same error message. But mine use full screen gesture, so mine never shows bottom navigation bar. Seems like Xiaomi's MiUI related issue?

OS: Windows 10
Android: Version 10.0
Android Device: Xiaomi Mi 9T

INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
C:\Users\User\scrcpy\scrcpy-server: 1 file pushed. 4.3 MB/s (26202 bytes in 0.006s)
java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml: open failed: ENOENT (No such file or directory)
        at libcore.io.IoBridge.open(IoBridge.java:496)
        at java.io.FileInputStream.<init>(FileInputStream.java:159)
        at java.io.FileInputStream.<init>(FileInputStream.java:115)
        at java.io.FileReader.<init>(FileReader.java:58)
        at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108)
        at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126)
        at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59)
        at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31)
        at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111)
        at android.content.res.MiuiResourcesImpl.<clinit>(MiuiResourcesImpl.java:40)
        at android.content.res.Resources.<init>(Resources.java:283)
        at android.content.res.MiuiResources.<init>(MiuiResources.java:49)
        at android.content.res.Resources.getSystem(Resources.java:204)
        at android.app.LoadedApk.<init>(LoadedApk.java:235)
        at android.app.ContextImpl.createSystemContext(ContextImpl.java:2430)
        at android.app.ActivityThread.getSystemContext(ActivityThread.java:2427)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.Workarounds.fillAppInfo(Workarounds.java:66)
        at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:56)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:34)
        at com.genymobile.scrcpy.Server.main(Server.java:163)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
        at libcore.io.Linux.open(Native Method)
        at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
        at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
        at libcore.io.IoBridge.open(IoBridge.java:482)
        ... 22 more
INFO: Initial texture: 1080x2336

@siddharths2710
Copy link
Author

@hafizidev Yeah should be. In any case, we can depend on the shortcuts as an alternative.

@rom1v
Copy link
Collaborator

rom1v commented Dec 11, 2019

On running the program without installation, the bottom keys are missing from the display (Please zoom in the image):

That's expected. If they don't appear on the device, they won't be mirrored. See #7.

IIUC, there is an exception, but mirroring still works?

To investigate the issue, could you test with 1.11 and 1.10, please (which changed things where the exception occurs)?

@rom1v rom1v changed the title Missing input keys Xiaomi MiUI: java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml Dec 11, 2019
@hafizidev
Copy link

hafizidev commented Dec 11, 2019

On running the program without installation, the bottom keys are missing from the display (Please zoom in the image):

That's expected. If they don't appear on the device, they won't be mirrored. See #7.

IIUC, there is an exception, but mirroring still works?

To investigate the issue, could you test with 1.11 and 1.10, please (which changed things where the exception occurs)?

Yes mirroring still works, just there is this exception in the console while starting the app.

I ran both version 1.10 and 1.11 and this exception doesn't occur in both versions.

@rom1v
Copy link
Collaborator

rom1v commented Dec 11, 2019

OK, so this is harmless. It's just a workaround which is applied to make some devices work.

When the workaround fails for some reason it just log the stacktrace in the console.

@Xplouder
Copy link

Looks like I have the same/similar error. However the cast works but i can not control de device.

INFO: scrcpy 1.12 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 3.0 MB/s (26196 bytes in 0.008s)
java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml (No such file or directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:231)
	at java.io.FileInputStream.<init>(FileInputStream.java:165)
	at java.io.FileInputStream.<init>(FileInputStream.java:112)
	at java.io.FileReader.<init>(FileReader.java:58)
	at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108)
	at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126)
	at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59)
	at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31)
	at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111)
	at android.content.res.MiuiResourcesImpl.<clinit>(MiuiResourcesImpl.java:40)
	at android.content.res.Resources.<init>(Resources.java:267)
	at android.content.res.MiuiResources.<init>(MiuiResources.java:49)
	at android.content.res.Resources.getSystem(Resources.java:190)
	at android.app.LoadedApk.<init>(LoadedApk.java:211)
	at android.app.ContextImpl.createSystemContext(ContextImpl.java:2331)
	at android.app.ActivityThread.getSystemContext(ActivityThread.java:2190)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.genymobile.scrcpy.Workarounds.fillAppInfo(Workarounds.java:66)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:56)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:34)
	at com.genymobile.scrcpy.Server.main(Server.java:163)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:388)
INFO: Initial texture: 1080x2336

@vncastanheira
Copy link

This happens with my Xiaomi phone as well and I'm also using fullscreen gestures.
At least it doesn't crash the application.

Btw, awesome app.

@acai2046
Copy link

acai2046 commented Jan 10, 2020

C:\Users\Administrator>adb shell
chiron:/ $ ls /data/
ls: /data/: Permission denied
1|chiron:/ $ ls /
ls: //vndservice_contexts: Permission denied
ls: //verity_key: Permission denied
ls: //vendor_service_contexts: Permission denied
ls: //vendor_hwservice_contexts: Permission denied
ls: //ueventd.rc: Permission denied
ls: //plat_hwservice_contexts: Permission denied
ls: //init.zygote64_32.rc: Permission denied
ls: //init.zygote32.rc: Permission denied
ls: //init.usb.rc: Permission denied
ls: //init.usb.configfs.rc: Permission denied
ls: //init.recovery.qcom.rc: Permission denied
ls: //init.recovery.hardware.rc: Permission denied
ls: //init.rc: Permission denied
ls: //init.miui.rc: Permission denied
ls: //init.miui.post_boot.sh: Permission denied
ls: //init.miui.nativedebug.rc: Permission denied
ls: //init.miui.google_revenue_share_v2.rc: Permission denied
ls: //init.miui.google_revenue_share.rc: Permission denied
ls: //init.miui.early_boot.sh: Permission denied
ls: //init.miui.cust.rc: Permission denied
ls: //init.environ.rc: Permission denied
ls: //init.batteryd.rc: Permission denied
ls: //init: Permission denied
ls: //default.prop: Permission denied
ls: //cn.prop: Permission denied
acct data plat_file_contexts sdcard
bin dev plat_property_contexts sepolicy
bt_firmware dsp plat_seapp_contexts storage
bugreports etc plat_service_contexts sys
cache firmware proc system
charger mnt product vendor
config odm res vendor_file_contexts
cust oem root vendor_property_contexts
d persist sbin vendor_seapp_contexts

@acai2046
Copy link

acai2046 commented Jan 13, 2020

/storage/emulated/0/data/目录,和/data/目录不是同一个目录吧?

/storage/emulated/0/下的目录是可以读写找到的。

adb 不可读写 /data/
手机根目录下没有找到/data/只有storage文件



小米应用市场里有句话:
Root手机后会照成系统的不稳定,并且可能会给您带来不可挽回的硬件损伤,如果您需要root权限请刷开发版MIUI.
http://www.miui.com/download.html

@rom1v rom1v closed this as completed Jan 19, 2020
rom1v added a commit that referenced this issue Jan 19, 2020
Some workarounds are needed on some devices. But applying them may cause
exceptions on other devices, where they are not necessary anyway.

Do not report these errors in release builds.

Closes #994 <#994>
@rom1v
Copy link
Collaborator

rom1v commented Jan 19, 2020

Since this is harmless (#994 (comment)), I disabled the error report: 96bd2c9

@rom1v
Copy link
Collaborator

rom1v commented Apr 30, 2020

In fact, the error is still printed: #1336 😕

@rom1v rom1v reopened this Apr 30, 2020
@rom1v
Copy link
Collaborator

rom1v commented Apr 30, 2020

The failing statement is here:

Context ctx = (Context) getSystemContextMethod.invoke(activityThread);

The whole thing is in a try-catch-Throwable block, which logs only in debug mode. (and the message Could not fill app info: does not appear, so in fact this specific log is not printed).

So I guess some method in the callstack catches the exception and just calls printStackTrace()… 😞

@rom1v
Copy link
Collaborator

rom1v commented Apr 30, 2020

Could you please take scrcpy v1.13 and replace this file:

scrcpy-server
SHA256: b64e6672eeb2b7c00c6f83673783bd8839ba65ea2ac7edcdeeca44676047328b

and confirm that it works without the error message.

Thank you.

@flynncowell
Copy link

flynncowell commented May 1, 2020

This issue isn't allowing me to do anything, apart from seeing my interactions with the phone itself.

Love this tool though. Also, I installed through choco.

@hafizidev
Copy link

Could you please take scrcpy v1.13 and replace this file:

scrcpy-server
SHA256: b64e6672eeb2b7c00c6f83673783bd8839ba65ea2ac7edcdeeca44676047328b

and confirm that it works without the error message.

Thank you.

Yeah, no more error displays after I replaced with yours

@rom1v
Copy link
Collaborator

rom1v commented May 1, 2020

@hafizidev Thank you for your feedback 👍

@hafizidev
Copy link

@hafizidev Thank you for your feedback 👍

My pleasure. But I just noticed, I got a warning

[server] INFO: Device: Xiaomi MI 9T (Android 10.0)
INFO: Renderer: direct3d
WARN: Trilinear filtering disabled (not an OpenGL renderer)
INFO: Initial texture: 1080x2336

@rom1v
Copy link
Collaborator

rom1v commented May 1, 2020

Yes, that's expected. Check §"Downscaling quality" here: https://github.com/Genymobile/scrcpy/releases/tag/v1.13

(scrcpy --render-driver=opengl should remove the warning, and you'll get trilinear filtering)

@rom1v rom1v closed this as completed May 2, 2020
rom1v added a commit that referenced this issue May 2, 2020
To avoid NullPointerException on some devices, workarounds have been
implemented. But these workaround produce (harmless) internal errors
causing exceptions to be printed in the console.

To avoid this problem, apply the workarounds only if it fails without
them.

Fixes #994 <#994>
Refs #365 <#365>
Refs #940 <#940>
@azhenglianxi
Copy link

棒棒哒~ 我想问这是什么语音开发的 小白 看着啥都想 但是感觉啥都不是 混合语言吗

Marc--Olivier added a commit to Marc--Olivier/AndroidViewClient that referenced this issue Oct 6, 2020
My script uses `AndroidViewClient` but cannot create a `ViewClient`

```python3
from com.dtmilano.android.viewclient import ViewClient

def createViewClient():
    return ViewClient(*ViewClient.connectToDeviceOrExit(serialno='.*'))

vc = createViewClient()
```

The script returns the following stack trace:

```sh
  File "/home/bob/workspace/script.py", line 4, in createViewClient
    return ViewClient(*ViewClient.connectToDeviceOrExit(serialno='.*'))
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 2690, in __init__
    self.dump()
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 3522, in dump
    self.setViewsFromUiAutomatorDump(received)
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 3105, in setViewsFromUiAutomatorDump
    self.__parseTreeFromUiAutomatorDump(received)
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 3323, in __parseTreeFromUiAutomatorDump
    self.root = parser.Parse(receivedXml[start_xml_index:end_xml_index + 1])
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 2394, in Parse
    _ = parser.Parse(encoded, True)
  File "../Modules/pyexpat.c", line 284, in CharacterData
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 2381, in CharacterData
    element = self.nodeStack[-1]
IndexError: list index out of range
```

When I execute the command `adb shell uiautomator dump` on my device a Pocophone X3 with MIUI 12 installed, I get the following result:

```sh
adb shell uiautomator dump
java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml: open failed: ENOENT (No such file or directory)
	at libcore.io.IoBridge.open(IoBridge.java:496)
	at java.io.FileInputStream.<init>(FileInputStream.java:159)
	at java.io.FileInputStream.<init>(FileInputStream.java:115)
	at java.io.FileReader.<init>(FileReader.java:58)
	at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108)
	at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126)
	at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59)
	at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31)
	at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111)
	at android.content.res.MiuiResourcesImpl.<clinit>(MiuiResourcesImpl.java:41)
	at android.content.res.Resources.<init>(Resources.java:285)
	at android.content.res.MiuiResources.<init>(MiuiResources.java:49)
	at android.content.res.Resources.getSystem(Resources.java:206)
	at android.util.MiuiMultiWindowAdapter.<clinit>(MiuiMultiWindowAdapter.java:79)
	at android.view.Display.getSize(Display.java:665)
	at com.android.commands.uiautomator.DumpCommand.run(DumpCommand.java:98)
	at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
	at libcore.io.Linux.open(Native Method)
	at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
	at libcore.io.IoBridge.open(IoBridge.java:482)
	... 18 more
UI hierchary dumped to: /sdcard/window_dump.xml
```

So `uiautomator` throws an error, but still succeeds to dump the XML. The constructor of `ViewClient` calls `parser.Parse(receivedXml[start_xml_index:end_xml_index + 1])` [Ln 3323](https://github.com/dtmilano/AndroidViewClient/blob/master/src/com/dtmilano/android/viewclient.py#L3323), but the XML contained in `received` cannot be parsed because it still contains parts of the exceptions: `start_xml_index = receivedXml.index("<")` will return the first index of '<', which is in the exception (`java.io.FileInputStream.<init>`).

We fixed the issue by filtering out the exception from the `received` variable [Ln 3461](https://github.com/dtmilano/AndroidViewClient/blob/master/src/com/dtmilano/android/viewclient.py#L3460):

```python3
received = re.sub(re.compile('java.io.FileNotFoundException.*<\?xml', re.DOTALL),'<?xml', received)
```

But it would probably be cleaner to replace the value of `start_xml_index = receivedXml.index("<")` with `start_xml_index = receivedXml.index("<?xml")`.

@dtmilano What do you think? Would you be interested by a pull request?

Note that this error is similar to two issues in the `scrcpy` project:
- Genymobile/scrcpy#1116
- Genymobile/scrcpy#994

These issues were fixed by just ignoring the exceptions (see Genymobile/scrcpy@96bd2c9).
Marc--Olivier added a commit to Marc--Olivier/AndroidViewClient that referenced this issue Oct 6, 2020
My script uses `AndroidViewClient` but cannot create a `ViewClient`

```python3
from com.dtmilano.android.viewclient import ViewClient

def createViewClient():
    return ViewClient(*ViewClient.connectToDeviceOrExit(serialno='.*'))

vc = createViewClient()
```

The script returns the following stack trace:

```sh
  File "/home/bob/workspace/script.py", line 4, in createViewClient
    return ViewClient(*ViewClient.connectToDeviceOrExit(serialno='.*'))
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 2690, in __init__
    self.dump()
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 3522, in dump
    self.setViewsFromUiAutomatorDump(received)
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 3105, in setViewsFromUiAutomatorDump
    self.__parseTreeFromUiAutomatorDump(received)
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 3323, in __parseTreeFromUiAutomatorDump
    self.root = parser.Parse(receivedXml[start_xml_index:end_xml_index + 1])
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 2394, in Parse
    _ = parser.Parse(encoded, True)
  File "../Modules/pyexpat.c", line 284, in CharacterData
  File "/home/bob/.local/lib/python3.6/site-packages/com/dtmilano/android/viewclient.py", line 2381, in CharacterData
    element = self.nodeStack[-1]
IndexError: list index out of range
```

When I execute the command `adb shell uiautomator dump` on my device a Pocophone X3 with MIUI 12 installed, I get the following result:

```sh
adb shell uiautomator dump
java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml: open failed: ENOENT (No such file or directory)
	at libcore.io.IoBridge.open(IoBridge.java:496)
	at java.io.FileInputStream.<init>(FileInputStream.java:159)
	at java.io.FileInputStream.<init>(FileInputStream.java:115)
	at java.io.FileReader.<init>(FileReader.java:58)
	at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108)
	at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126)
	at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59)
	at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31)
	at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111)
	at android.content.res.MiuiResourcesImpl.<clinit>(MiuiResourcesImpl.java:41)
	at android.content.res.Resources.<init>(Resources.java:285)
	at android.content.res.MiuiResources.<init>(MiuiResources.java:49)
	at android.content.res.Resources.getSystem(Resources.java:206)
	at android.util.MiuiMultiWindowAdapter.<clinit>(MiuiMultiWindowAdapter.java:79)
	at android.view.Display.getSize(Display.java:665)
	at com.android.commands.uiautomator.DumpCommand.run(DumpCommand.java:98)
	at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
	at libcore.io.Linux.open(Native Method)
	at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
	at libcore.io.IoBridge.open(IoBridge.java:482)
	... 18 more
UI hierchary dumped to: /sdcard/window_dump.xml
```

So `uiautomator` throws an error, but still succeeds to dump the XML. The constructor of `ViewClient` calls `parser.Parse(receivedXml[start_xml_index:end_xml_index + 1])` [Ln 3323](https://github.com/dtmilano/AndroidViewClient/blob/master/src/com/dtmilano/android/viewclient.py#L3323), but the XML contained in `received` cannot be parsed because it still contains parts of the exceptions: `start_xml_index = receivedXml.index("<")` will return the first index of '<', which is in the exception (`java.io.FileInputStream.<init>`).

We fixed the issue by filtering out the exception from the `received` variable [Ln 3461](https://github.com/dtmilano/AndroidViewClient/blob/master/src/com/dtmilano/android/viewclient.py#L3460):

```python3
received = re.sub(re.compile('java.io.FileNotFoundException.*<\?xml', re.DOTALL),'<?xml', received)
```

But it would probably be cleaner to replace the value of `start_xml_index = receivedXml.index("<")` with `start_xml_index = receivedXml.index("<?xml")`.

@dtmilano What do you think? Would you be interested by a pull request?

Note that this error is similar to two issues in the `scrcpy` project:
- Genymobile/scrcpy#1116
- Genymobile/scrcpy#994

These issues were fixed by just ignoring the exceptions (see Genymobile/scrcpy@96bd2c9).
@rom1v rom1v mentioned this issue Apr 11, 2022
2 tasks
@lydacious
Copy link

lydacious commented Feb 22, 2023

Hello, I am having this issue.

INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
/usr/share/scrcpy/scrcpy-server: 1 file pushed. 9.5 MB/s (24773 bytes in 0.002s)
java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml: open failed: ENOENT (No such file or directory)INFO: Initial texture: 1080x2400

	at libcore.io.IoBridge.open(IoBridge.java:574)
	at java.io.FileInputStream.<init>(FileInputStream.java:160)
	at java.io.FileInputStream.<init>(FileInputStream.java:115)
	at java.io.FileReader.<init>(FileReader.java:60)
	at miui.content.res.ThemeCompatibilityLoader.getVersion(ThemeCompatibilityLoader.java:108)
	at miui.content.res.ThemeCompatibilityLoader.getConfigDocumentTree(ThemeCompatibilityLoader.java:126)
	at miui.content.res.ThemeCompatibilityLoader.loadConfig(ThemeCompatibilityLoader.java:59)
	at miui.content.res.ThemeCompatibility.<clinit>(ThemeCompatibility.java:31)
	at miui.content.res.ThemeCompatibility.isThemeEnabled(ThemeCompatibility.java:111)
	at android.content.res.MiuiResourcesImpl.<clinit>(MiuiResourcesImpl.java:41)
	at android.content.res.MiuiResources.<init>(MiuiResources.java:58)
	at android.content.res.IMiuiResourceImpl.createResources(IMiuiResourceImpl.java:13)
	at android.content.res.ThemeManagerStub.createMiuiResources(ThemeManagerStub.java:56)
	at android.content.res.Resources.getSystem(Resources.java:235)
	at android.app.LoadedApk.<init>(LoadedApk.java:243)
	at android.app.ContextImpl.createSystemContext(ContextImpl.java:2980)
	at android.app.ActivityThread.getSystemContext(ActivityThread.java:2722)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.genymobile.scrcpy.Workarounds.fillAppInfo(Workarounds.java:66)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:56)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:34)
	at com.genymobile.scrcpy.Server.main(Server.java:163)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:383)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
	at libcore.io.Linux.open(Native Method)
	at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
	at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
	at libcore.io.IoBridge.open(IoBridge.java:560)
	... 23 more
[server] ERROR: Exception on thread Thread[main,5,main]
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
	at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:75)
	at com.genymobile.scrcpy.ScreenEncoder.setDisplaySurface(ScreenEncoder.java:178)
	at com.genymobile.scrcpy.ScreenEncoder.streamScreen(ScreenEncoder.java:70)
	at com.genymobile.scrcpy.Server.scrcpy(Server.java:34)
	at com.genymobile.scrcpy.Server.main(Server.java:163)
	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:383)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Method.invoke(Native Method)
WARN: Device disconnected
	at com.genymobile.scrcpy.wrappers.SurfaceControl.setDisplaySurface(SurfaceControl.java:73)
	... 6 more
Caused by: java.lang.IllegalArgumentException: displayToken must not be null
	at android.view.SurfaceControl$Transaction.setDisplaySurface(SurfaceControl.java:3215)
	at android.view.SurfaceControl.setDisplaySurface(SurfaceControl.java:2254)
	... 8 more

@rom1v
Copy link
Collaborator

rom1v commented Feb 22, 2023

Use a newer version.

Caused by: java.lang.IllegalArgumentException: displayToken must not be null

Android 12 requires at least scrcpy v1.18. Just use the latest (1.25 currently).

@lydacious
Copy link

Use a newer version.

Caused by: java.lang.IllegalArgumentException: displayToken must not be null

Android 12 requires at least scrcpy v1.18. Just use the latest (1.25 currently).

yup, it worked. thanks

rom1v added a commit that referenced this issue Jun 16, 2023
DONOTMERGE: it causes #994 on Xiaomi devices

This allows to make Context.getPackageManager() work.

Fixes #4015 <#4015>
Refs <#4015 (comment)>

Co-authored-by: Simon Chan <[email protected]>
rom1v added a commit that referenced this issue Oct 31, 2023
Xiaomi device ROMs print internal errors using e.printStackTRace(),
flooding the console with irrelevant errors.

To get rid of them, on Xiaomi devices, trash the messages printed to the
console by direct calls to System.out and System.err.

Refs #994 <#994>
Refs #4213 <#4213>
rom1v added a commit that referenced this issue Nov 1, 2023
Some devices (mostly Xiaomi) print internal errors using
e.printStackTrace(), flooding the console with irrelevant errors.

Disable system streams used via System.out and System.err streams, to
print only the logs from scrcpy.

Refs #994 <#994>
Refs #4213 <#4213>
rom1v added a commit that referenced this issue Nov 1, 2023
Some devices (mostly Xiaomi) print internal errors using
e.printStackTrace(), flooding the console with irrelevant errors.

Disable system streams used via System.out and System.err streams, to
print only the logs from scrcpy.

Refs #994 <#994>
Refs #4213 <#4213>
XayahSuSuSu added a commit to XayahSuSuSu/Android-DataBackup that referenced this issue Feb 21, 2024
* Ref: Genymobile/scrcpy#994

Change-Id: I700cee9418881880941fcf75fd813a1e2037173e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants