我正在處理一個項目,在這個項目中,我需要使用gomobile工具從Golang代碼庫生成一個APK文件。計劃是能夠在Android平板電腦上運行它。當我在平板電腦上安裝apk文件時,通過安卓工作室,我收到以下錯誤。 E/Go: panic: open C:/Users/ash/OneDrive/Desktop/go-workSpace/src/Myproject/config.json: no such file or directory但是,在單擊錯誤消息中的給定路徑后,Android 工作室會打開它要查找的文件(配置.json)這是我在Go中的源代碼exDir := "C:/Users/ash/OneDrive/Desktop/go-workSpace/src/Myproject/" configFile, err := ioutil.ReadFile(filepath.Join(filepath.Dir(exDir), "config.json")) // Look for the config file in the same directory as the executable Check(err)func Check(err error) { if err != nil { fmt.Println("Received generic error, panicking") fmt.Println(err) panic(err) }}任何建議如何修復文件路徑?
添加回答
舉報
0/150
提交
取消