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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: Unable to create application org.electroncash.electroncash3.App: java.lang.RuntimeException: java.io.FileNotFoundException: chaquopy/bootstrap-native/x86/java/__init__.py #2136

Closed
ProfessorVenkman opened this issue Jan 24, 2021 · 3 comments
Labels

Comments

@ProfessorVenkman
Copy link

ProfessorVenkman commented Jan 24, 2021

Crash Report

This crash report was reported through the automatic crash reporting system 馃

Traceback

	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5408)
	at android.app.ActivityThread.-wrap2(ActivityThread.java)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6121)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: chaquopy/bootstrap-native/x86/java/__init__.py
	at com.chaquo.python.android.AndroidPlatform.getPath(AndroidPlatform.java:111)
	at com.chaquo.python.Python.start(Python.java:53)
	at org.electroncash.electroncash3.AppKt$py$2.invoke(App.kt:18)
	at org.electroncash.electroncash3.AppKt$py$2.invoke(App.kt)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at org.electroncash.electroncash3.AppKt.getPy(App.kt)
	at org.electroncash.electroncash3.AppKt.libMod(App.kt:21)
	at org.electroncash.electroncash3.NetworkKt$libNetwork$2.invoke(Network.kt:27)
	at org.electroncash.electroncash3.NetworkKt$libNetwork$2.invoke(Network.kt)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at org.electroncash.electroncash3.NetworkKt.getLibNetwork(Network.kt)
	at org.electroncash.electroncash3.SettingsKt.setDefaultValues(Settings.kt:63)
	at org.electroncash.electroncash3.SettingsKt.initSettings(Settings.kt:28)
	at org.electroncash.electroncash3.App.onCreate(App.kt:53)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5405)
	... 8 more
Caused by: java.io.FileNotFoundException: chaquopy/bootstrap-native/x86/java/__init__.py
	at android.content.res.AssetManager.openAsset(Native Method)
	at android.content.res.AssetManager.open(AssetManager.java:347)
	at android.content.res.AssetManager.open(AssetManager.java:321)
	at com.chaquo.python.android.AndroidPlatform.extractAsset(AndroidPlatform.java:194)
	at com.chaquo.python.android.AndroidPlatform.extractAssets(AndroidPlatform.java:149)
	at com.chaquo.python.android.AndroidPlatform.getPath(AndroidPlatform.java:108)
	... 23 more
java.lang.RuntimeException: Unable to create application org.electroncash.electroncash3.App: java.lang.RuntimeException: java.io.FileNotFoundException: chaquopy/bootstrap-native/x86/java/__init__.py

Reporter

This issue was reported by 9 user(s):

Electron Cash Version Python Version Operating System Wallet Type Locale
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on samsung SM-N975F (SM-N975F) unknown ar_EG
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on samsung SM-N975F (SM-N975F) unknown ar_EG
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on OPPO PCRT00 (PCRT00) unknown zh_CN
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on OPPO PCRT00 (PCRT00) unknown zh_CN
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on OPPO PCRT00 (PCRT00) unknown zh_CN
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on OPPO PCRT00 (PCRT00) unknown zh_CN
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on OPPO PCRT00 (PCRT00) unknown zh_CN
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on Asus ASUS_Z01QD (ASUS_Z01QD) unknown en_US
4.2.3-2 java.lang.IllegalStateException: Python startup previously failed, and cannot be retried Android 7.1.2 on google G011A (G011A) unknown en_US

Additional Information

The reporting user(s) did not provide additional information.

@mhsmith
Copy link
Collaborator

mhsmith commented Jan 28, 2021

This is weird:

  • Why is it attempting to read an x86 file on an ARM device?
  • Why isn't it finding the file anyway, since the APK should contain all ABIs?

And now it's been reported by two different people.

@mhsmith
Copy link
Collaborator

mhsmith commented Feb 11, 2021

Some of the devices in the duplicates actually have x86 processors (setzer_cheets, celes_cheets and Z00A). According to the Google Play device catalog, SM-N975F has x86 support as well, though Wikipedia says it's an ARM device, so perhaps it has x86-on-ARM emulation.

dream2lteks, OnePlus3T and OnePlus5 are listed as ARM-only in the device catalog, and PCRT00 is not in the catalog at all. But the catalog isn't always perfect, so my guess is that they have x86-on-ARM emulation as well.

I can reproduce this with the released APK on an x86 emulator on API levels 23 to 28 inclusive, but not newer or older versions, and not with an APK I built myself.

Looking at the released APK, there is something special about the file chaquopy/bootstrap-native/x86/java/__init__.py: it's the only file which ends on a 4 KB boundary (0x001c5000), and it's one of only 5 empty files. So it looks like there's a bug in some versions of the AssetManager when one or both of these conditions happen.

Since this issue is so sensitive to the APK file layout, It'll almost certainly disappear in the next release, but I'll try to find a workaround to make sure it never comes back.

@mhsmith
Copy link
Collaborator

mhsmith commented Feb 13, 2021

This is awkward to reproduce, but I eventually managed it:

  • Delete APK before each build, otherwise the build may modify it incrementally and cause confusion.
  • Use Android Gradle plugin 3.5.0 with release build: other versions or build types may not store files in alphabetical order. Note that index order isn't always the same as file order.
  • Changing the name or content of any file will change MANIFEST.MF, which is compressed, so its size changes unpredictably. Since MANIFEST.MF appears near the start of the APK, this makes it difficult to get any other file perfectly on a 4K boundary. However, zipalign -p will 4K-align the content of any uncompressed file whose name ends with .so, regardless of path, and small files (0-1 bytes) should always be stored uncompressed, so that can be used as an anchor for both the .so file and any file which follows it in alphabetical order. Normal builds apparently don't use zipalign, so run it manually. This removes the v2 signature, so test on API level 23 which doesn't know about that.

Using these methods I was able to reproduce the AssetManager.open failure with an empty asset on a 4K boundary. A non-empty file doesn't have the issue, whether it starts or ends on a 4K boundary.

So as long as we don't generate any empty files in the APK, we should be fine. I'll fix Chaquopy to do that.

EchterAgo pushed a commit to EchterAgo/Electron-Cash that referenced this issue Mar 11, 2021
EchterAgo pushed a commit to EchterAgo/Electron-Cash that referenced this issue Mar 11, 2021
EchterAgo pushed a commit to EchterAgo/Electron-Cash that referenced this issue Mar 11, 2021
EchterAgo pushed a commit to EchterAgo/Electron-Cash that referenced this issue Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants