@@ -19,6 +19,14 @@ android {
1919 vectorDrawables {
2020 useSupportLibrary = true
2121 }
22+
23+ // Configure native build ABIs
24+ ndk {
25+ abiFilters.add(" armeabi-v7a" )
26+ abiFilters.add(" arm64-v8a" )
27+ abiFilters.add(" x86" )
28+ abiFilters.add(" x86_64" )
29+ }
2230 }
2331
2432 buildTypes {
@@ -31,23 +39,27 @@ android {
3139 }
3240 }
3341 compileOptions {
34- sourceCompatibility = JavaVersion .VERSION_1_8
35- targetCompatibility = JavaVersion .VERSION_1_8
42+ sourceCompatibility = JavaVersion .VERSION_17
43+ targetCompatibility = JavaVersion .VERSION_17
3644 }
3745 kotlinOptions {
38- jvmTarget = " 1.8 "
46+ jvmTarget = " 17 "
3947 }
4048 buildFeatures {
4149 compose = true
4250 aidl = true
4351 }
4452 composeOptions {
45- kotlinCompilerExtensionVersion = " 1.4.3 "
53+ kotlinCompilerExtensionVersion = " 1.5.11 "
4654 }
4755 packaging {
4856 resources {
4957 excludes + = " /META-INF/{AL2.0,LGPL2.1}"
5058 }
59+ // Don't strip native libraries during APK build
60+ jniLibs {
61+ keepDebugSymbols + = " **/*.so"
62+ }
5163 }
5264 externalNativeBuild {
5365 cmake {
@@ -57,6 +69,42 @@ android {
5769 }
5870}
5971
72+ // Create a custom task to build the Go library
73+ tasks.register<Exec >(" buildGoLibrary" ) {
74+ // Use a task output directory for the Go AAR
75+ val libDir = layout.buildDirectory.dir(" go-lib" ).get().asFile
76+ mkdir(libDir)
77+
78+ workingDir = file(" src/main/go" )
79+ commandLine(" ./build.sh" , libDir.absolutePath)
80+
81+ doLast {
82+ // Create the libs directory if it doesn't exist
83+ mkdir(" src/main/libs" )
84+
85+ // Copy the AAR to the libs directory
86+ copy {
87+ from(libDir)
88+ include(" *.aar" )
89+ into(" src/main/libs" )
90+ }
91+ println (" Built and copied Go AAR to src/main/libs" )
92+ }
93+ }
94+
95+ // Run buildGoLibrary after the native libraries are built
96+ // Make the mergeDebugJniLibFolders task depend on buildGoLibrary
97+ afterEvaluate {
98+ tasks.named(" mergeDebugJniLibFolders" ).configure {
99+ dependsOn(" buildGoLibrary" )
100+ }
101+
102+ // Make buildGoLibrary depend on the C++ build
103+ tasks.named(" buildGoLibrary" ).configure {
104+ dependsOn(" externalNativeBuildDebug" )
105+ }
106+ }
107+
60108dependencies {
61109 implementation(" androidx.core:core-ktx:1.12.0" )
62110 implementation(" androidx.lifecycle:lifecycle-runtime-ktx:2.7.0" )
@@ -75,22 +123,25 @@ dependencies {
75123
76124 implementation(" androidx.navigation:navigation-compose:2.7.7" )
77125
78- implementation(platform(" androidx.compose:compose-bom:2023.03 .00" ))
126+ implementation(platform(" androidx.compose:compose-bom:2024.04 .00" ))
79127 implementation(" androidx.compose.ui:ui" )
80128 implementation(" androidx.compose.ui:ui-graphics" )
81129 implementation(" androidx.compose.ui:ui-tooling-preview" )
82130 implementation(" androidx.compose.material3:material3" )
83131 implementation(" androidx.compose.material:material-icons-core" )
84132 implementation(" androidx.compose.material:material-icons-extended" )
85133 implementation(" com.google.accompanist:accompanist-permissions:0.32.0" )
134+
135+ // Include AAR files from src/main/libs directory
86136 implementation(fileTree(mapOf (
87- " dir" to " src/main/go " ,
137+ " dir" to " src/main/libs " ,
88138 " include" to listOf (" *.aar" , " *.jar" ),
89139 )))
140+
90141 testImplementation(" junit:junit:4.13.2" )
91142 androidTestImplementation(" androidx.test.ext:junit:1.1.5" )
92143 androidTestImplementation(" androidx.test.espresso:espresso-core:3.5.1" )
93- androidTestImplementation(platform(" androidx.compose:compose-bom:2023.03 .00" ))
144+ androidTestImplementation(platform(" androidx.compose:compose-bom:2024.04 .00" ))
94145 androidTestImplementation(" androidx.compose.ui:ui-test-junit4" )
95146 debugImplementation(" androidx.compose.ui:ui-tooling" )
96147 debugImplementation(" androidx.compose.ui:ui-test-manifest" )
0 commit comments