4

当我们尝试使用gomobile bind. 它与 iOS 框架的绑定很好。

这是我们得到的错误:

$ make build_android

cd ./gomobile/logger && gomobile bind -o ../build/logger.aar -target=android . ../levelenum ../remotelogger ../apiclient ../userproperties

gomobile: javac -d /var/folders/p6/vvxrsdbj1bg87kkgk3k77cn40000gp/T/gomobile-work-357624003/javac-output -source 1.7 -target 1.7 -bootclasspath /Users/robin/Library/Android/sdk/platforms/android-29/android.jar apiclient/Apiclient.java apiclient/AuthenticationArgs.java apiclient/PostArgs.java go/Seq.java go/Universe.java go/error.java levelenum/Level.java levelenum/Levelenum.java logger/Logger.java logger/Logger_.java remotelogger/Remotelogger.java userproperties/ApplicationProperties.java userproperties/CarrierProperties.java userproperties/DeviceProperties.java userproperties/NetworkProperties.java userproperties/OSProperties.java userproperties/Userproperties.java failed: exit status 1
apiclient/Apiclient.java:12: error: class APIClient is public, should be declared in a file named APIClient.java
public final class APIClient implements Seq.Proxy {
             ^
remotelogger/Remotelogger.java:12: error: class RemoteLogger is public, should be declared in a file named RemoteLogger.java
public final class RemoteLogger implements Seq.Proxy {
             ^
userproperties/Userproperties.java:12: error: class UserProperties is public, should be declared in a file named UserProperties.java
public final class UserProperties implements Seq.Proxy {
             ^
./apiclient/Apiclient.java:12: error: class APIClient is public, should be declared in a file named APIClient.java
public final class APIClient implements Seq.Proxy {
             ^
apiclient/Apiclient.java:13: error: cannot access Apiclient
        static { Apiclient.touch(); }
                 ^
  bad source file: ./apiclient/Apiclient.java
    file does not contain class apiclient.Apiclient
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.
5 errors

make: *** [build_android] Error 1

例如,我们的 APIClient.go 文件如下所示:

package apiclient

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
    "time"
)

// APIClient : handler of the Network request
type APIClient struct {
    BaseURL string
}

文件夹结构是:

gomobile/
    Makefile
    go.mod
    go.sum
    build/
        logger.framework (iOS)
        logger.aar (Android) <---- Should be here but cannot be built
    apiclient/
        apiclient.go
    logger/
        logger.go
    userproperties/
        userproperties.go
4

0 回答 0