Skip to content

x/mobile/bind/java: fatal error: jni.h: No such file or directory #58426

@dpanic

Description

@dpanic

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

$ go version
go version go1.20 linux/amd64

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

GOHOSTARCH="amd64"
GOHOSTOS="linux"

ANDROID_NDK_HOME=/home/dpanic/development/Android/Sdk/ndk/25.2.9519653
ANDROID_HOME=/home/dpanic/development/Android/Sdk

What did you do?

Binding Go Mobile project with following command:

CGO_ENABLED=1 \
        gomobile bind \
        -androidapi 23 \
        -target=android/$TARGET \
        -ldflags="-w -s" \
        -o export_$TARGET.aar \
        -v

What did you expect to see?

On Go version 1.19.5 and lower this works.

What did you see instead?

unable to import bind/java: [-: # golang.org/x/mobile/bind/java                         
/home/dpanic/go/pkg/mod/golang.org/x/mobile@v0.0.0-20221110043201-43a038452099/bind/java
/context_android.go:9:10: fatal error: jni.h: No such file or directory                 
    9 | //#include <jni.h>                                                              
      |          ^~~~~~~                                                                
compilation terminated.]                                                                
gomobile: /home/dpanic/go/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-1953076754
 example.com/export failed: exit status 1                                            

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.mobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions