billthefarmer / diary

Android personal diary - forked from http://git.savannah.gnu.org/cgit/diary.git
https://billthefarmer.github.io/diary
GNU General Public License v3.0
276 stars 58 forks source link

Crashes on choosing "Edit style" and "Edit script" #95

Closed uli-on closed 5 years ago

uli-on commented 5 years ago

In v1.48, whenever I choose one of the above menu items, Diary crashes.

Android v6.0.1, Motorola G4 (and in case Android system webview is involved: 74.3729.157)

billthefarmer commented 5 years ago

I have tested this on a device and an emulator and can't reproduce it. On an emulator, with no other editors installed, the built in editor opens the possibly empty script or style file. On the device a dialog pops up showing the editors installed. I need a traceback from the device log to work out what is going on.

uli-on commented 5 years ago

Thanks for testing. My device is not rooted, and I'm having difficulties getting the SDK working for executing an ADB command (I'm all new in these matters). I'll let you know when/if I succeed.

billthefarmer commented 5 years ago

There are various pages on the web about this, this looks the most useful... https://www.xda-developers.com/install-adb-windows-macos-linux

uli-on commented 5 years ago

Thanks, Bill, I appreciate your help! Looks promising. And appropriate in size, compared to the 10 GB SDK. Thanks also for your work on #93 and #94!

uli-on commented 5 years ago

Bill, for security reasons I've deleted the post containing the log. In case you didn't receive a copy via mail please tell me how I can contact you.

billthefarmer commented 5 years ago

Here is what appears to be the part of the log containing a crash. You can use something like adb logcat | grep Diary to filter out the parts you want, or adb logcat | grep AndroidRuntime to get the traceback. The clue is in:

06-14 15:52:20.555 E/AndroidRuntime(2818): java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/3366-3661/Texte/Diary_billthefarmer/js/script.js

I don't understand the path. What I would expect to see is something like this:

06-17 09:09:49.483   503   524 I ActivityManager: Displayed org.billthefarmer.diary/.Diary: +1s453ms
06-17 09:09:52.218 18436 18436 D Diary   : Path /external/Diary/js/script.js
06-17 09:09:52.221   503   515 I ActivityManager: START u0 {act=android.intent.action.EDIT dat=content://org.billthefarmer.diary.fileprovider/external/Diary/js/script.js typ=text/javascript flg=0x3 cmp=android/com.android.internal.app.ResolverActivity} from uid 10422 on display 0
06-17 09:09:54.373   503  6682 I ActivityManager: START u0 {act=android.intent.action.EDIT dat=content://org.billthefarmer.diary.fileprovider/external/Diary/js/script.js typ=text/javascript flg=0x3000003 cmp=org.billthefarmer.diary/.Editor} from uid 10422 on display 0
06-17 09:09:54.503 18436 18436 D FileUtils File: Authority: org.billthefarmer.diary.fileprovider, Fragment: null, Port: -1, Query: null, Scheme: content, Host: org.billthefarmer.diary.fileprovider, Segments: [external, Diary, js, script.js]
06-17 09:09:54.528 18436 18436 D FileUtils: Path /external/Diary/js/script.js
06-17 09:09:54.533 18436 18436 D FileUtils: Path /storage/emulated/0/Diary/js/script.js

Where the 3366-3661/Texte/ part comes from I have no idea. In recent versions of Android apps are not allowed to pass a file:/// URI to another app, but must use a content:// URI obtained from a file provider. The Android file provider I am using in this app didn't understand the file path it was passed. It would be interesting to see what happens if you uninstall and reinstall Diary, or clear it's data using Settings->Apps->Diary->Storage->CLEAR DATA and try editing a script again using the default Diary path.

This is the extract from your log:

06-14 15:52:19.009 D/SFPerfTracer(484): layers: (3:15) (FocusedStackFrame (0xb9085580): 0:19010)* (DimLayer (0xb9087ef8): 0:3575)* (DimLayer (0xb908a960): 0:70)* (StatusBar (0xb908e410): 2:218929) (com.android.systemui.ImageWallpaper (0xb909e398): 0:21353)* (DimLayer (0xb90abed8): 0:23310)* (DimLayer (0xb90ad890): 0:2909)* ( (0xb90c5650): 0:2)* (NavigationBar (0xb9098fe0): 0:145) (org.billthefarmer.diary/org.billthefarmer.diary.Diary (0xb90b1250): 0:171)- (PopupWindow:90988d0 (0xb9068500): 0:67)- (Application Error: org.billthefarmer.diary (0xb90a7108): 0:44)- (com.teslacoilsw.launcher/com.teslacoilsw.launcher.NovaLauncher (0xb90aa6c0): 0:25)- (Starting org.billthefarmer.diary (0xb9068500): 0:35)- (org.billthefarmer.diary/org.billthefarmer.diary.Diary (0xb90d5728): 81:94)
06-14 15:52:19.039 W/NetGuard.Service(6408): No rules for uid=10028 v4 p6 172.217.21.234/443
06-14 15:52:19.213 I/ActivityManager(1840): Process com.motorola.genie (pid 2250) has died
06-14 15:52:19.213 I/am_proc_died(1840): [0,2250,com.motorola.genie]
06-14 15:52:20.125 W/NetGuard.Service(6408): No rules for uid=10149 v4 p6 50.17.241.209/443
06-14 15:52:20.554 I/menu_item_selected(2818): [0,Skript bearbeiten…]
06-14 15:52:20.555 D/AndroidRuntime(2818): Shutting down VM
06-14 15:52:20.556 I/am_crash(1840): [2818,0,org.billthefarmer.diary,952680004,java.lang.IllegalArgumentException,Failed to find configured root that contains /storage/3366-3661/Texte/Diary_billthefarmer/js/script.js,FileProvider.java,679]
06-14 15:52:20.557 I/am_finish_activity(1840): [0,151344852,27931,org.billthefarmer.diary/.Diary,force-crash]
06-14 15:52:20.557 I/am_home_stack_moved(1840): [0,1,0,0,finishActivity adjustFocus setFocusedActivity]
06-14 15:52:20.555 E/AndroidRuntime(2818): FATAL EXCEPTION: main
06-14 15:52:20.558 I/wm_task_moved(1840): [27481,1,1]
06-14 15:52:20.555 E/AndroidRuntime(2818): Process: org.billthefarmer.diary, PID: 2818
06-14 15:52:20.561 I/am_focused_activity(1840): [0,com.teslacoilsw.launcher/.NovaLauncher]
06-14 15:52:20.555 E/AndroidRuntime(2818): java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/3366-3661/Texte/Diary_billthefarmer/js/script.js
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:679)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:378)
06-14 15:52:20.555 E/AndroidRuntime(2818): at org.billthefarmer.diary.Diary.editScript(Diary.java:1493)
06-14 15:52:20.582 I/am_pause_activity(1840): [0,151344852,org.billthefarmer.diary/.Diary]
06-14 15:52:20.555 E/AndroidRuntime(2818): at org.billthefarmer.diary.Diary.onOptionsItemSelected(Diary.java:598)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.app.Activity.onMenuItemSelected(Activity.java:2918)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.policy.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1151)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:761)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:200)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.widget.AdapterView.performItemClick(AdapterView.java:310)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.widget.AbsListView.performItemClick(AbsListView.java:1145)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.widget.AbsListView$PerformClick.run(AbsListView.java:3073)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.widget.AbsListView$3.run(AbsListView.java:3910)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.os.Handler.handleCallback(Handler.java:746)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.os.Handler.dispatchMessage(Handler.java:95)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.os.Looper.loop(Looper.java:148)
06-14 15:52:20.555 E/AndroidRuntime(2818): at android.app.ActivityThread.main(ActivityThread.java:5443)
06-14 15:52:20.555 E/AndroidRuntime(2818): at java.lang.reflect.Method.invoke(Native Method)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
06-14 15:52:20.555 E/AndroidRuntime(2818): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-14 15:52:20.557 W/ActivityManager(1840): Force finishing activity org.billthefarmer.diary/.Diary
uli-on commented 5 years ago

After deleting the prefs, Diary opens an empty file for both, JS and CSS, as you'd expect. Renaming the folder to "Diary" on external storage didn't help. Serving the entire folder from internal storage, though (with its previous name "Diary_billthefarmer"), did change Diary's behaviour back to normal, i.e. no crashes. So the problem, in my case, seems to be the external path.

billthefarmer commented 5 years ago

I hadn't realised you were using the SD card for Diary storage. I added the functionality to use an absolute path for Diary storage by request, but didn't think that anyone would use an SD card. Android says you can use the card for sharing or transferring files, or make it part of the phone's storage, then you can store apps and data on it.

According to the docs, you can't use the file provider to create a content:// URI for files on an SD card. However, looking at the source, it appears that you can use an absolute path. So I will see if that works.

uli-on commented 5 years ago

I've forgotten to mention one thing that might be important: I've always stored my Diary entries on SD card. I've installed the app while it was on v1.43 (according to my backups), and the two menu entries worked back then. I've used them for several weeks while designing some versions. So it might be an update to Diary that broke the functionality while I wasn't using the menu entries. Hope that helps.

billthefarmer commented 5 years ago

Version 1.43 is where I added the file provider, that part hasn't changed since. I have tested using an absolute path for the file provider, which works. I don't have a device with an external SD card and the emulator permissions don't allow the app to write to an SD card, so it is not fully tested. That will be in the next version.

uli-on commented 5 years ago

Thanks, Bill, this issue is solved for me. I leave it open, though, can't speak for others.