golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.98k stars 17.67k forks source link

x/mobile: javac encoding error during build #46381

Open Jambo-Git opened 3 years ago

Jambo-Git commented 3 years ago

What version of Go are you using (go version)?

$ go version
1.14

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

PWD=$WORK\java javac -d $WORK\javac-output -source 1.7 -target 1.7 -bootclasspath $ANDROID_HOME\platforms\android-30\android.jar common\Common.java common\Context.java common\DaqContext.java common\User.java go\Seq.java go\Universe.
java go\error.java
警告: [options] 源值7已过时, 将在未来所有发行版中删除
警告: [options] 目标值7已过时, 将在未来所有发行版中删除
警告: [options] 要隐藏有关已过时选项的警告, 请使用 -Xlint:-options。
common\User.java:36: 错误: 编码 GBK 的不可映射字符 (0xB9)
         * 鐢ㄦ埛鍚嶏紝鍙慨鏀?
                     ^
common\User.java:40: 错误: 编码 GBK 的不可映射字符 (0xB9)
         * 鐢ㄦ埛鍚嶏紝鍙慨鏀?
                     ^
Jambo-Git commented 3 years ago

i change: golang.org\x\mobile\cmd\gomobile\bind_androidapp.go; line 308 add "-encoding","utf-8" args := []string{ "-d", dst, "-source", javacTargetVer, "-target", javacTargetVer, "-encoding","utf-8", "-bootclasspath", bClspath, }

mknyszek commented 3 years ago

I see, it looks like javac doesn't like the encoding of the files gomobile generates. Looks like we just put in UTF-8 strings wholesale, but Java strings aren't UTF-8. And it appears OP fixed it by adding -encoding utf-8 to the list of arguments passed to javac.

CC @hyangah via https://dev.golang.org/owners

mknyszek commented 3 years ago

@Jambo-Git would you be willing to send a PR to https://github.com/golang/mobile, since you already figured it out? (See https://golang.org/doc/contribute for how to contribute.)

If you're not interested in sending a patch, I can send a patch for this later this week.