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

java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml (No such file or directory) #1116

Closed
d3dbit opened this issue Jan 28, 2020 · 2 comments

Comments

@d3dbit
Copy link

d3dbit commented Jan 28, 2020

Hi,
I am getting the next error when I run scrcpy.exe (on Windows 10).
How can I resolve this issue?
Thanks & Regards.

>{...}\scrcpy-win64-v1.12.1\scrcpy.exe
INFO: scrcpy 1.12.1 <https://github.com/Genymobile/scrcpy>
* daemon not running; starting now at tcp:5037
* daemon started successfully
{...}\scrcpy-win64-v1....py-server: 1 file pushed. 1.3 MB/s (26202 bytes in 0.019s)
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:2168)
        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: 1080x2160
@rom1v
Copy link
Collaborator

rom1v commented Jan 28, 2020

This error is harmless, see #994. It is not printed anymore (on the development branch).

Besides this, does scrcpy work normally? (If not, it is probably unrelated.)

@rom1v rom1v closed this as completed Jan 28, 2020
@d3dbit
Copy link
Author

d3dbit commented Jan 29, 2020

This error is harmless, see #994. It is not printed anymore (on the development branch).

@rom1v OK. Thanks for your support.

Besides this, does scrcpy work normally? (If not, it is probably unrelated.)

Yes. I confirm that scrcpy works normally.

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).
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

2 participants