Skip to content

Support switch workspace on the Pad #8948

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

Closed
Vanessa219 opened this issue Aug 10, 2023 · 19 comments
Closed

Support switch workspace on the Pad #8948

Vanessa219 opened this issue Aug 10, 2023 · 19 comments
Assignees
Milestone

Comments

@Vanessa219
Copy link
Member

https://ld246.com/article/1691668626632

@Vanessa219 Vanessa219 self-assigned this Aug 10, 2023
@Vanessa219 Vanessa219 added this to the 2.10.0 milestone Aug 10, 2023
@88250 88250 changed the title Support switch workspace in the Pad Support switch workspace on the Pad Aug 10, 2023
Vanessa219 added a commit that referenced this issue Aug 11, 2023

Verified

This commit was signed with the committer’s verified signature.
@88250 88250 changed the title Support switch workspace on the Pad Support switch workspace on the Pad Aug 15, 2023
@HowcanoeWang
Copy link

插个楼问一下,能不能支持安卓端开启开发者终端?插件在安卓端使用报错但是伺服后在PC浏览器上正常,需要开启终端debug确认一下报错信息

@88250
Copy link
Member

88250 commented Aug 15, 2023

@HowcanoeWang 你那里方便编译 Android 端吗?方便的话就比较好弄,不方便的话估计我们得想想其他配置方案。

@HowcanoeWang
Copy link

@HowcanoeWang 你那里方便编译 Android 端吗?方便的话就比较好弄,不方便的话估计我们得想想其他配置方案。

编译有教程吗,我手头是有PC的应该可以编译,但是没有编译基础知识。

最好能跟桌面端一样,有个开发者工具(仅限Mobile-desktop? 手机端可以不考虑有这个选项)

image

@88250
Copy link
Member

88250 commented Aug 15, 2023

Android 得改一行代码,开启 webview debug 才行,如果能试试的话你先搭建个 Android 环境,然后按照 siyuan-android 项目的步骤试试编译。

@HowcanoeWang
Copy link

HowcanoeWang commented Aug 20, 2023

Android

  • gomobile bind --tags fts5 -ldflags '-s -w' -v -o kernel.aar -target='android/arm64' ./kernel/mobile/

按照指引,卡在这一步:

> gomobile bind --tags fts5 -ldflags '-s -w' -v -o kernel.aar -target='android/arm64' ./mobile/
flag provided but not defined: -w'
usage: gomobile bind [-target android|ios|iossimulator|macos|maccatalyst] [-bootclasspath <path>] [-classpath <path>] [-o output] [build flags] [package]

看了一下 -ldflags的帮助,也没找到具体的参数说明

        -ldflags '[pattern=]arg list'
                arguments to pass on each go tool link invocation.

以及我发现中英文的说明,移动端编码部分说明不一致:

@88250
Copy link
Member

88250 commented Aug 20, 2023

感谢反馈,文档已经在 dev 上更新。

我这里编译 Android 内核正常(Windows),你试下把 -w 去掉或者升级最新 gomobile。

@HowcanoeWang
Copy link

去掉了-w,然后也在studio里面装了下面的3个版本的NDK,但是命令行里还是报错说找不到对应版本的ndk?

image

> D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 24 ./mobile/
gomobile: no usable NDK in C:\Users\hwang\AppData\Local\Android\sdk: unsupported API version 16 (not in 19..33), open C:\Users\hwang\AppData\Local\Android\sdk\ndk-bundle\meta\platforms.json: The system cannot find the path specified.

@88250
Copy link
Member

88250 commented Aug 20, 2023

把 16 那个卸载了。

image

环境变量

image

@HowcanoeWang
Copy link

按照上面的方法,只保留25.2的设置并修改环境变量

image

不管是指定androidapi还是不指定,一直都在找16的,这也是为啥我上面装了3个版本的NDK

D:\AppData\siyuan\kernel>echo %ANDROID_HOME%
D:\AppData\android-sdk

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 24 ./mobile/
gomobile: no usable NDK in D:\AppData\android-sdk: unsupported API version 16 (not in 19..33), open D:\AppData\android-sdk\ndk-bundle\meta\platforms.json: The system cannot find the path specified.

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 25 ./mobile/
gomobile: no usable NDK in D:\AppData\android-sdk: unsupported API version 16 (not in 19..33), open D:\AppData\android-sdk\ndk-bundle\meta\platforms.json: The system cannot find the path specified.

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' ./mobile/
gomobile: no usable NDK in D:\AppData\android-sdk: unsupported API version 16 (not in 19..33), open D:\AppData\android-sdk\ndk-bundle\meta\platforms.json: The system cannot find the path specified.

@88250
Copy link
Member

88250 commented Aug 20, 2023

gomobile 是最新版不?

@88250
Copy link
Member

88250 commented Aug 20, 2023

@HowcanoeWang
Copy link

感觉是gomobile的问题,我按照官网的安装:

$ go install golang.org/x/mobile/cmd/gomobile@latest
$ gomobile init
https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile

然后发现检查gomobile版本一直报错

D:\AppData\siyuan\kernel>go install golang.org/x/mobile/cmd/gomobile@latest

D:\AppData\siyuan\kernel>gomobile init

D:\AppData\siyuan\kernel>gomobile version
gomobile version unknown: binary is out of date, re-install it

查了一下,需要在go路径下去查看版本

D:\AppData\siyuan\kernel>echo %GOPATH%
C:\Users\hwang\go

C:\Users\hwang\go>gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package golang.org/x/mobile/cmd/gomobile: go.mod file not found in current directory or any parent directory; see 'go help modules'

看了一下go/pkg/gomobile文件夹,里面是空的。估计是安装出了问题。


然后找了中文教程,从github下源码编译,好像也运行不起来

https://www.bilibili.com/read/cv13171586/

C:\Users\hwang\go\src\golang.org\x>git clone https://github.com/golang/mobile/
Cloning into 'mobile'...
remote: Enumerating objects: 10131, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 10131 (delta 3), reused 7 (delta 2), pack-reused 10114
Receiving objects: 100% (10131/10131), 6.44 MiB | 7.40 MiB/s, done.
Resolving deltas: 100% (6331/6331), done.

C:\Users\hwang\go\src\golang.org\x>cd ../../..

C:\Users\hwang\go>go build golang.org/x/mobile/cmd/gomobile/
no required module provides package golang.org/x/mobile/cmd/gomobile: go.mod file not found in current directory or any parent directory; see 'go help modules'

https://codeantenna.com/a/gVt9mMZUzO
会自动下载到 $GOPATH/src/github.com 路径下

下载的位置也不对,然后编译也跑不起来,但是最终的效果是bin文件夹下面有gomobile.exe,我发现一直都是有的

image

但是即使在这个文件夹下,还是没法检查gomobile版本

C:\Users\hwang\go\bin>gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package golang.org/x/mobile/cmd/gomobile: go.mod file not found in current directory or any parent directory; see 'go help modules'

要不还是在移动端支持一下开发者工具吧,完全没有go和andriod开发基础,搭个环境很心累(o_ _)ノ

@88250
Copy link
Member

88250 commented Aug 20, 2023

gomobile version 那个不用管,我这也是坏的。

开 debug 主要是不清楚对性能和安全性的影响,担心开了会有问题。

@HowcanoeWang
Copy link

HowcanoeWang commented Aug 20, 2023

看看这个有帮助不 https://www.cnblogs.com/ghj1976/p/gomobile-pei-zhi-peng-dao-de-wen-ti-ji-lu.html

按照这个装了之后(那个download已经点不了了)

image

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 24 ./mobile/
gomobile: no usable NDK in D:\AppData\android-sdk: unsupported API version 16 (not in 19..33), open D:\AppData\android-sdk\ndk-bundle\meta\platforms.json: The system cannot find the path specified.

然后我去把ANDROID_HOME环境变量删了,用回默认的PATH,换了个报错:

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 24 ./mobile/
gomobile: C:\Users\hwang\go\bin\gobind.exe -lang=go,java -outdir=C:\Users\hwang\AppData\Local\Temp\gomobile-work-2740611927 -tags=fts5 ' -v -o kernel.aar -target='android/arm64' -androidapi 24 github.com/siyuan-note/siyuan/kernel/mobile failed: exit status 1
no exported names in the package "'"
no exported names in the package "-v"
no exported names in the package "-o"
no exported names in the package "kernel.aar"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-androidapi"
no exported names in the package "24"
no exported names in the package "'"
no exported names in the package "'"
no exported names in the package "'"
no exported names in the package "-v"
no exported names in the package "-v"
no exported names in the package "-v"
no exported names in the package "-o"
no exported names in the package "-o"
no exported names in the package "-o"
no exported names in the package "kernel.aar"
no exported names in the package "kernel.aar"
no exported names in the package "kernel.aar"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-androidapi"
no exported names in the package "-androidapi"
no exported names in the package "-androidapi"
no exported names in the package "24"
no exported names in the package "24"
no exported names in the package "24"

把androidapi 24去掉,倒是跑起来了,有一堆输出,但是没找到产生的文件在哪?./mobile/里面只有一个kernel.go:


D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' ./mobile/

        C:/Program Files/Go/src/sync/mutex.go:171 +0x15d fp=0xc036f9ff08 sp=0xc036f9feb8 pc=0xbae07d
sync.(*Mutex).Lock(...)
        C:/Program Files/Go/src/sync/mutex.go:90
sync.(*Once).doSlow(0x0?, 0xc036f9ff78)
        C:/Program Files/Go/src/sync/once.go:70 +0x50 fp=0xc036f9ff68 sp=0xc036f9ff08 pc=0xbae370
sync.(*Once).Do(...)
        C:/Program Files/Go/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:844 +0x4a fp=0xc036f9ffa0 sp=0xc036f9ff68 pc=0xd650aa
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:851 +0x26 fp=0xc036f9ffc8 sp=0xc036f9ffa0 pc=0xd65326
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.2()
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:853 +0x27 fp=0xc036f9ffe0 sp=0xc036f9ffc8 pc=0xd652c7
runtime.goexit()
...
        C:/Program Files/Go/src/os/file.go:314
os.ReadFile({0xc0340832c0?, 0xc023680c90?})
        C:/Program Files/Go/src/os/file.go:715 +0x59 fp=0xc038987e78 sp=0xc038987da0 pc=0xbf9d39
io/ioutil.ReadFile(...)
        C:/Program Files/Go/src/io/ioutil/ioutil.go:37
golang.org/x/tools/go/packages.(*loader).parseFile(0xc0334d2000, {0xc0340832c0, 0x54})
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1130 +0x308 fp=0xc038987f78 sp=0xc038987e78 pc=0xd67328
golang.org/x/tools/go/packages.(*loader).parseFiles.func1(0x14, {0xc0340832c0?, 0x0?})
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1163 +0x45 fp=0xc038987fb8 sp=0xc038987f78 pc=0xd67945
golang.org/x/tools/go/packages.(*loader).parseFiles.func2()
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1165 +0x2f fp=0xc038987fe0 sp=0xc038987fb8 pc=0xd678cf
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc038987fe8 sp=0xc038987fe0 pc=0xba57c1
created by golang.org/x/tools/go/packages.(*loader).parseFiles in goroutine 12629
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1162 +0x2bf

用everything也搜不到kernel.aar文件

@HowcanoeWang
Copy link

开 debug 主要是不清楚对性能和安全性的影响,担心开了会有问题。

只编译一个开发版放github release里?不上架应用商店,只是用来开发测试用?

@88250
Copy link
Member

88250 commented Aug 20, 2023

你加了开发者 QQ 群吗?我放群里好了。

@HowcanoeWang
Copy link

HowcanoeWang commented Aug 20, 2023

你加了开发者 QQ 群吗?我放群里好了。

在群里了,然后我刚刚发现不用debug了,不是我插件的问题,思源app本身就没法上传一些目录里面的图片。。。

比如内部存储里面的download, pictures这些文件夹,插入图片就没反应

@HowcanoeWang
Copy link

发现开了伺服,用安卓的浏览器访问,可以成功上传那些思源app里面不能上传的图片。。。

HowcanoeWang/siyuan-plugin-background-cover#6

准备给插件增加个提示,如果是安卓app,则提示用伺服上传图片

感谢D大的耐心指导!

@zwting
Copy link

zwting commented Mar 19, 2024

看看这个有帮助不 https://www.cnblogs.com/ghj1976/p/gomobile-pei-zhi-peng-dao-de-wen-ti-ji-lu.html

按照这个装了之后(那个download已经点不了了)

image

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 24 ./mobile/
gomobile: no usable NDK in D:\AppData\android-sdk: unsupported API version 16 (not in 19..33), open D:\AppData\android-sdk\ndk-bundle\meta\platforms.json: The system cannot find the path specified.

然后我去把ANDROID_HOME环境变量删了,用回默认的PATH,换了个报错:

D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' -androidapi 24 ./mobile/
gomobile: C:\Users\hwang\go\bin\gobind.exe -lang=go,java -outdir=C:\Users\hwang\AppData\Local\Temp\gomobile-work-2740611927 -tags=fts5 ' -v -o kernel.aar -target='android/arm64' -androidapi 24 github.com/siyuan-note/siyuan/kernel/mobile failed: exit status 1
no exported names in the package "'"
no exported names in the package "-v"
no exported names in the package "-o"
no exported names in the package "kernel.aar"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-androidapi"
no exported names in the package "24"
no exported names in the package "'"
no exported names in the package "'"
no exported names in the package "'"
no exported names in the package "-v"
no exported names in the package "-v"
no exported names in the package "-v"
no exported names in the package "-o"
no exported names in the package "-o"
no exported names in the package "-o"
no exported names in the package "kernel.aar"
no exported names in the package "kernel.aar"
no exported names in the package "kernel.aar"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-target='android/arm64'"
no exported names in the package "-androidapi"
no exported names in the package "-androidapi"
no exported names in the package "-androidapi"
no exported names in the package "24"
no exported names in the package "24"
no exported names in the package "24"

把androidapi 24去掉,倒是跑起来了,有一堆输出,但是没找到产生的文件在哪?./mobile/里面只有一个kernel.go:


D:\AppData\siyuan\kernel>gomobile bind --tags fts5 -ldflags '-s ' -v -o kernel.aar -target='android/arm64' ./mobile/

        C:/Program Files/Go/src/sync/mutex.go:171 +0x15d fp=0xc036f9ff08 sp=0xc036f9feb8 pc=0xbae07d
sync.(*Mutex).Lock(...)
        C:/Program Files/Go/src/sync/mutex.go:90
sync.(*Once).doSlow(0x0?, 0xc036f9ff78)
        C:/Program Files/Go/src/sync/once.go:70 +0x50 fp=0xc036f9ff68 sp=0xc036f9ff08 pc=0xbae370
sync.(*Once).Do(...)
        C:/Program Files/Go/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:844 +0x4a fp=0xc036f9ffa0 sp=0xc036f9ff68 pc=0xd650aa
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0x0?)
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:851 +0x26 fp=0xc036f9ffc8 sp=0xc036f9ffa0 pc=0xd65326
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.2()
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:853 +0x27 fp=0xc036f9ffe0 sp=0xc036f9ffc8 pc=0xd652c7
runtime.goexit()
...
        C:/Program Files/Go/src/os/file.go:314
os.ReadFile({0xc0340832c0?, 0xc023680c90?})
        C:/Program Files/Go/src/os/file.go:715 +0x59 fp=0xc038987e78 sp=0xc038987da0 pc=0xbf9d39
io/ioutil.ReadFile(...)
        C:/Program Files/Go/src/io/ioutil/ioutil.go:37
golang.org/x/tools/go/packages.(*loader).parseFile(0xc0334d2000, {0xc0340832c0, 0x54})
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1130 +0x308 fp=0xc038987f78 sp=0xc038987e78 pc=0xd67328
golang.org/x/tools/go/packages.(*loader).parseFiles.func1(0x14, {0xc0340832c0?, 0x0?})
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1163 +0x45 fp=0xc038987fb8 sp=0xc038987f78 pc=0xd67945
golang.org/x/tools/go/packages.(*loader).parseFiles.func2()
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1165 +0x2f fp=0xc038987fe0 sp=0xc038987fb8 pc=0xd678cf
runtime.goexit()
        C:/Program Files/Go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc038987fe8 sp=0xc038987fe0 pc=0xba57c1
created by golang.org/x/tools/go/packages.(*loader).parseFiles in goroutine 12629
        C:/Users/hwang/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230818130535-1517d1a3ba60/go/packages/packages.go:1162 +0x2bf

用everything也搜不到kernel.aar文件

我在编译android包的时候也遇到了和你一样的问题,经过研究和尝试之后找到了解决办法

  • 首先是编译内核命令报错说-w参数未定义的问题。在window的默认命令行中,应该把命令中所有的单引号替换成双引号即可解决
  • 其次是ndk的问题,我尝试了直接用Android Studio安装Android SDK在默认位置 C:\Users\[用户名]\AppData\Local\Android\Sdk,这里需要注意:使用Android Studio安装的NDK默认是最新版本的,我这里是v26,这个版本会报错;然后我尝试手动去官网下载21版本,解压到C:\Users\[用户名]\AppData\Local\Android\Sdk\ndk\21.4.7075529中,此时再执行上面的命令来编译内核就可以成功
  • 我把windows命令行环境的编译命令替换引号后的命令贴到这里
gomobile bind --tags fts5 -ldflags "-s -w" -v -o kernel.aar -target="android/arm64" -androidapi 24 ./mobile/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants