如何使用gomobile build sdk-arr-libs来访问web?

huangapple go评论86阅读模式
英文:

How to use gomobile build sdk-arr-libs to access to web?

问题

我使用gomobile bind生成了一个.arr文件。

gomobile version
gomobile version +e154aff Wed Dec 2 14:48:43 2015 +0000 (android); androidSDK=D:\android\sdk\platforms\android-23

go version
go version go1.5.2 windows/amd64

Go代码包含一个访问网络的func

client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
	log.Fatal(err.Error())
}
resp, err := client.Do(req)

我将这个.arr文件添加到我的Android项目中,在Android Studio中构建并安装了一个apk到虚拟设备。

但是应用程序无法访问网络。

运行应用程序后出现以下错误:

 GoLog: Get www.google.com: unsupported protocol scheme ""

我一定漏掉了什么,请帮助我。

英文:

I use gomobile bind generated an .arr file.

gomobile version
gomobile version +e154aff Wed Dec 2 14:48:43 2015 +0000 (android); androidSDK=D:\android\sdk\platforms\android-23

go version
go version go1.5.2 windows/amd64

Go code include a func which access to web.

client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
	log.Fatal(err.Error())
}
resp, err := client.Do(req)

I add this .arr to my Android project in Android Studio, build and install a apk to Virtual Devices.

But the app can't access to web.

After running app it comes out:

 GoLog: Get www.google.com: unsupported protocol scheme ""

I must missed something, please help me.

答案1

得分: 2

这与gomobile无关。网址www.google.com应该以http://开头。

英文:

It's nothing to do with gomobile. The url www.google.com should started with http://.

huangapple
  • 本文由 发表于 2015年12月8日 01:16:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/34139371.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定