gomobile

runwu2204 Lv6

安装好gomobile后

如果使用go mod模式就直接在.go文件处go mod init xxx即可

gomobile bind -target android (init出来的包名)

注意golang的外部可调用方法得开头大写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
plugins {
id 'com.android.application'
}

android {
namespace 'com.example.mobilego'
compileSdk 33

defaultConfig {
applicationId "com.example.mobilego"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ''
}
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version '3.22.1'
}
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation(fileTree("libs"))//導入
}
  • 标题: gomobile
  • 作者: runwu2204
  • 创建于 : 2023-11-02 17:51:27
  • 更新于 : 2024-06-11 00:56:06
  • 链接: https://runwu2204.github.io/2023/11/02/开发/安卓开发/gomobile/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
gomobile