Stringlate cannot "Export to SD card" under AOSP 4.1.2 (Jelly Bean)
Stringlate v0.11 from F-Droid under AOSP 4.1.2 (API level 16) is unable to "Export to SD card": "Could not export strings.xml file".
This was somewhat expected, as the README.md states: "This application has not yet been tested on pre-Lollipop devices and it might fail on some operations, such as exporting a file to the SD card. If this is the case, please let me know, or create a new pull request with a fix."
Although I am unable to write code for a PR, I can provide logs, if that is deemed helpful.
Can you try with adb logcat -s io.github.lonamiwebs.stringlate to get some error logs? Or maybe step into with debugger?
Log taken locally with aLogcat Root: alogcat_stringlate0.11_export-to-sd_filtered-stringlate.txt Pretty terse, IMO.
Tried again with Stringlate 0.12, took a thorough look at the aLogcat settings, still there seems to be nothing meaningful in either main-log or event-log:
How to use a debugger on the device (I fail to run adb from the PC with this device)? Can you provide any web-pointers, please?
Well, with the right settings, logs taken with aLogcat are a bit more comprehensive (but on first sight not sufficiently so):
Tried with Catlog, which is a bit awkward to use and has issues when trying to filter, but the latter actually makes a difference, as the interesting output does not contain the string stringlate!
See for yourself (and supposedly these logs in combination with the last two logs taken with aLogcat are helpful):
P.S. (edit): IMO the following three lines can be ignored (occurring in Catlog's logs), as they seem to be caused by the platform / software stack I am using and occur with many other apps, too:
E/AndroidRuntime(6926): No DOWNLOAD_CACHE is set!
E/AndroidRuntime(6926): '(null)' directory does not exist!
E/AndroidRuntime(6926): loadLocale: can't get locale.
Looks pretty much the same, when filtering for gsantner in aLogcat:
alogcat-mainlog_stringlate0.12_export-to-sd_filtered-gsantner.txt
Hmm. weird, the code should work down to API 14 which is used on Markor too. I will update the utils, tell me then after next uprate if that helped
Well, Markor does not exhibit issues when writing files (tried a regular note and a quick-note), but shows a few similar (but fewer) error messages in the log (I just took a mainlog, filtered for gsantner):
If I can help by investigating this further, please let me know (and how to).
You told Markor doesn't crash right? The said things seem to have todo with java imports, but not calls itself ( which are checked against API version). Both of these image methods are not used in stringlate, so I don't see any problem with it (in meaning of I don't think they are the cause of your problems)

The issue may be somewhere in TranslateActivtiy, but I cannot find any at the fast browsing throguh (doExportToSd,exportToSd). Maybe @Lonami has an idea on that
@gsantner,
You told Markor doesn't crash right?
- Stringlate also does not crash, it just replies "Could not export strings.xml file" in a small, black notification at the middle bottom of the screen (see original description in the first post of this thread / issue), when trying to use its function "Export to SD-card" on my device (AOSP 4.1.2).
- As Markor has no "Export to SD-card" function AFAICS, I did not know (and still don't) how to trigger a similar behaviour, thus I just saved a note and a quick-note in Markor. Looking at the logs the actions carried out are somewhat different. Do you have any specific suggestion, what to test and log with Markor in order to provoke a failure to write as with Stringlate?
If markor does save your notes i see no problem, it always writes to sd/external.
What you can do is to try out all of my apps and can tell if you can find some real crash (where the app quits/exits). For me this all this seems to be not a big error in utils code but maybe some minor thing in stringlate. Still I am happy about fixing any bug in the used utils.
These utils are used in all of my apps, so try maybe Markor, MemeTastic, openlauncher, dandelion*, froody and stringlate.
If markor does save your notes i see no problem, it always writes to sd/external.
Markor successfully does that (I may have missed to state that 100% clearly in my former comment), in contrast to Stringlate.
@Lonami, as I am not (yet) willing "to try out all of (@gsantner's) apps and can tell if you can find some real crash (where the app quits/exits)", which may provide a hint what goes wrong in Stringlate when trying to "export to SD" under Android 4.1.2 (API level 16), I retested with Stringlate 0.13:
- Screenshot to illustrate the issue (e.g. Stringlate is not crashing):

- Mainlog filtered with RegEx "(lonamiwebs|gsantner)": alogcat-mainlog_stringlate-0.13_filtered-lonamiwebs-gsantner.txt
- Eventlog filtered with RegEx "(lonamiwebs|gsantner)": alogcat-eventlog_stringlate-0.13_filtered-lonamiwebs-gsantner.txt
AFAICS the four consecutive "System.err:"-lines at the end of the Mainlog point to io.github.lonamiwebs.stringlate.activities.translate.TranslateActivity.doExportToSd(TranslateActivity.java) as cause, but this is where my Android / Java debugging skills end.
Logcat guide update: Maybe take a look at https://gsantner.net/android-contribution-guide/?packageid=io.github.lonamiwebs.stringlate#logcat (has already filled out the right package id)
Well, what's wrong or missing in the last logs I provided?
Side note: Thanks for your well written, brief guide. But it uses ADB, which I fail to get working. I run an AOSP 4.1.2 based Android runtime environment (AlienDalvik) under (i.e. in a chroot environment) Linux (SailfishOS) on my phone. Using ADB installed on the host Linux (SailfishOS), I see the Android runtime environment (AlienDalvik) as an emulator. Trying to connect via TCP using 127.0.0.1 and the right port (which is not the default one) fails, everything else finds no device. Starting adbd as root on an Android shell (i.e. inside the Android runtime environment) made no difference. Any ideas what else to try?
I just search through projects and pasted the link :smile: , because the existing recommended command seemed not to work.
If you can't start adb wifi (adb tcpip 5555, systemsettings or some wireless app) and cannot get it work over usb, I'm not aware any other way to get some debug logs, at least without having root rights. How did you get the logs above?
The existing logs seem to be fine, and should give us some info to fix this.
Any ideas what else to try?
(Note: Personal recommendation) Yeah, buy a new device. You have a big security hole with such a thing. What's even more bad than android fragmentation and outdated android versions are unmaintained/outdated solutions which do try to integrate an again very old android version. OR at least don't be dependant on Android on that device. (it's great you use this app, but this won't help you if your data gets copied by bad people)
If you can't start adb wifi (
adb tcpip 5555,
adb tcpip 127.0.0.1:5556 on the host Linux finds the "emulator", but fails to connect (as stated).
Or do I have to start adb this way on the Android side as well?
systemsettings
There are no Android system settings, unfortunately.
or some wireless app
Can you please name two or three suitable "wireless apps" you were thinking of, as I have not found anything such for debugging purposes.
and cannot get it work over usb, I'm not aware any other way to get some debug logs, at least without having root rights.
As I am root on the host side anyway, placing a su binary and control app inside the Android container was feasible. When taking logs this way (under Android < 4.3) with "aLogcat root", I cannot see any difference compared to other logs taken with adb (although it took me a while to figure out the proper settings for aLogcat), in contrast to "CatLog".
You have a big security hole with such a thing.
As the Android runtime environment was updated until last year (i.e. as long as Google maintained AOSP 4), I don't think this is worse than most devices running Android 5 and 6 (and receiving no updates from their manufacturers for longer).
Yeah, buy a new device.
I did (but did not migrate to it, yet), but SailfishOS currently provides a AOSP 4 based Android runtime (this is supposed to change), so no fundamental difference besides newer hardware. ;) Note, that I use Android apps only for functionality SailfishOS native apps (or Unix commands) do not provide (e.g. Stringlate).
What's even more bad than android fragmentation and outdated android versions are unmaintained/outdated solutions which do try to integrate an again very old android version.
This was not the case, when designed and implemented in 2013 and was O.K. until 2017 (when Google stopped maintaining AOSP 4). But something has to be (and is promised to be) to be done above this in 2018 , be it Anbox or a license for a newer AlienDalvik.
Well ok, that was my personal recommendation.
"You are a strongly opinionated man!" (this quote was originally directed at me, but fits well here, IMHO).
Or do I have to start adb this way on the Android side as well?
You need to give adb access to your device, which is the counterpart of the PC's adb. But no, this is not the same adb executeable that you run on your desktop. I have to admit if you can't get any help on your devices/OSs forums, I too can't give any advice, as I don't own any. EDIT: Doesn't seem to be a seperate process where adb is running on the device.
Can you please name two or three suitable "wireless apps", you were thinking of, as I have not found anything such for debugging purposes.
I had an app called "adb wireless" from F-Droid installed, which basically did the same like the Adb-Wireless-option in systemsettings.
aLogcat root
Yeah, that was the one last option I can think off.
Other than that, read (update came right after my comment) the more clear comment above :D
OS Monitor (Monitor the Operating System) - https://f-droid.org/app/com.eolwral.osmonitor
seems to give logs too reliable, after enabling root.
@Olf0 thank you so much for providing so much information and sorry for the huge delay. The latest logs point to these lines: https://github.com/LonamiWebs/Stringlate/blob/ef171bb706ca3a4adb6453e5d0e72174760661b8/src/app/src/main/java/io/github/lonamiwebs/stringlate/activities/translate/TranslateActivity.java#L639-L649
642, to be precise. And I think it's because that method is also used even on pre-Lolipop devices (notice inside the else it's called, in the for):
https://github.com/LonamiWebs/Stringlate/blob/ef171bb706ca3a4adb6453e5d0e72174760661b8/src/app/src/main/java/io/github/lonamiwebs/stringlate/activities/translate/TranslateActivity.java#L594-L630
@Lonami, thanks for the analysis and explanation.
@gsantner,
- Thanks for the pointer to adbWireless (seems to be unmaintained, v1.5.4 on F-Droid is from 2013), it helped me finding ADB Manager and Wirebug on F-Droid, which are more recent. But in the end, they all just start adbd, which I already tried manually before. Anyway, they helped me confirm, that I had no fundamental misconception, how this is supposed to work (rsp. still doesn't).
- I use OS Monitor for its detailed network interface monitoring capabilities, but it fails to take logs in my environment, hence I retracted its root access. Anyway as aLogcat root and CatLog work and the former records comprehensive logs with the right settings (I failed to configure CatLog to do that, though), this is a non-issue.
Thanks for your support.
This fails: https://github.com/LonamiWebs/Stringlate/blob/8339decf6ba3b2984e74f4523837281fe445fe05/src/app/src/main/java/io/github/lonamiwebs/stringlate/activities/translate/TranslateActivity.java#L615-L617
But I don't know why. mkdirs returns false for directory on sd card while the parent directory is writable advices to check our permissions but we have them: https://github.com/LonamiWebs/Stringlate/blob/3a827772499e84ed9c2c92741b7ebfb159ebb8e2/src/app/src/main/AndroidManifest.xml#L8-L10
I have checked the root path and it's the same as the one returned by Environment.getExternalStorageDirectory() which in the case of the emulator is /mnt/sdcard. So it's not that the path is being inferred incorrectly.
Oh apparently I don't have a sdcard at all in my emulator (downloads don't work either). Anyway, I created a separate sd card with mksdcard and it's not working either, no matter how I start it. Not even with the -sdcard sd.img switch.