Hi,
I need to pass a build tag `-tags sqlite` to the build so I can build sqlite access into my app. It doesn't seem gogio take that info and therefore I can't access my DB from my mobile.
I guess there must be more stuff to it (like CGO) but I don't know about that.
Tanguy ⧓
On Wed Dec 4, 2019 at 6:09 AM wrote:
> > I need to pass a build tag `-tags sqlite` to the build so I can build sqlite access into my app. It doesn't seem gogio take that info and therefore I can't access my DB from my mobile.> I guess there must be more stuff to it (like CGO) but I don't know about that.>
That's just an oversight, and -tags should be easy to add to the `gogio`
command. Would you be interested in submitting a patch? I'm just about
the send out the December newsletter with instructions on cloning and
sending patches with a web-based workflow.
-- elias
>> I need to pass a build tag `-tags sqlite` to the build so I can build sqlite access into my app. It>> doesn't seem gogio take that info and therefore I can't access my DB from my mobile.>> I guess there must be more stuff to it (like CGO) but I don't know about that.
It seems I did something wrong passing my GOFLAGS.
Checking the source code, I saw that you pass `os.Environ()` to the cmd.Env ( https://git.sr.ht/~eliasnaur/gio/tree/master/cmd/gogio/androidbuild.go#L192 )
So I tried again with `GOFLAGS="-tags=sqlite" gogio -target android .` and it worked.
Now I'm facing another issue as I can't write on the fs of android by creating a sqlite database.
Do I need to ask Android permissions for that?
```
12-04 17:43:12.288 23150 23182 I gio : sqlite:///data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite
12-04 17:43:12.288 23150 23182 I gio : [POP] 2019/12/04 16:43:12 info - create /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite (/data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite?_busy_timeout=5000)
12-04 17:43:12.292 23150 0 E Go : panic: mempack: couldn't create database /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite: could not create SQLite database /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite: open /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite: permission denied
```
(do I need to create another thread?)
Tanguy ⧓
On Wed Dec 4, 2019 at 6:42 PM wrote:
> >> I need to pass a build tag `-tags sqlite` to the build so I can build sqlite access into my app. It> >> doesn't seem gogio take that info and therefore I can't access my DB from my mobile.> >> I guess there must be more stuff to it (like CGO) but I don't know about that.> > It seems I did something wrong passing my GOFLAGS.> Checking the source code, I saw that you pass `os.Environ()` to the cmd.Env ( https://git.sr.ht/~eliasnaur/gio/tree/master/cmd/gogio/androidbuild.go#L192 )> So I tried again with `GOFLAGS="-tags=sqlite" gogio -target android .` and it worked.> > Now I'm facing another issue as I can't write on the fs of android by creating a sqlite database.> Do I need to ask Android permissions for that?> > ```> 12-04 17:43:12.288 23150 23182 I gio : sqlite:///data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite> 12-04 17:43:12.288 23150 23182 I gio : [POP] 2019/12/04 16:43:12 info - create /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite (/data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite?_busy_timeout=5000)> 12-04 17:43:12.292 23150 0 E Go : panic: mempack: couldn't create database /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite: could not create SQLite database /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite: open /data/user/0/com.tuxago.mempack/files/mempack/mempack.sqlite: permission denied> ```> > (do I need to create another thread?)
If you're using app.DataDir, you should need to ask for permission. According
to
https://developer.android.com/reference/android/content/Context.html#getFilesDir()
"No additional permissions are required for the calling app to read or write
files under the returned path."
-- elias
> If you're using app.DataDir, you should need to ask for permission. According> to> > https://developer.android.com/reference/android/content/Context.html#getFilesDir()> > "No additional permissions are required for the calling app to read or write> files under the returned path."
You're right.
My mistake is that I created a subdirectory (to be able to write to `~/.config/mempack/` on an UNIX OS for example). And I used the wrong perms (I used os.ModeDir and should have used os.ModePerm on the os.MkdirAll call). So the dir wasn't writeable I guess.
On Android, it makes less sense to create an app subdirectory from the DataDir since the DataDir is already scoped for your app.
Thank you again!