Skip to content

Commit f985988

Browse files
authored
fix(core): compatibility check for Android SDK < 24 (#12870)
1 parent 060de5b commit f985988

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changes/fix-android-min-sdk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch:bug
3+
---
4+
5+
Update path plugin to use older dataDir API on SDK < 24.

crates/tauri/mobile/android/src/main/java/app/tauri/PathPlugin.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package app.tauri
66

77
import android.app.Activity
8+
import android.os.Build
89
import android.os.Environment
910
import app.tauri.annotation.Command
1011
import app.tauri.annotation.TauriPlugin
@@ -34,12 +35,20 @@ class PathPlugin(private val activity: Activity): Plugin(activity) {
3435

3536
@Command
3637
fun getConfigDir(invoke: Invoke) {
38+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
3739
resolvePath(invoke, activity.dataDir.absolutePath)
40+
} else {
41+
resolvePath(invoke, activity.applicationInfo.dataDir)
42+
}
3843
}
3944

4045
@Command
4146
fun getDataDir(invoke: Invoke) {
47+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
4248
resolvePath(invoke, activity.dataDir.absolutePath)
49+
} else {
50+
resolvePath(invoke, activity.applicationInfo.dataDir)
51+
}
4352
}
4453

4554
@Command

0 commit comments

Comments
 (0)