update example app deps
Seto committed
Nov 28, 2025 at 16:37 UTC
be802a580b5e62fa576b8e25b5e375a81ede8a6c
6 files changed
+66
-20
examples/tauri-app/README.md
+4
-5
@@ -1,8 +1,7 @@
1
-# Svelte + Vite
1
+# Tauri Plugin AdMod Example
2
3
-This template should help get you started developing with Tauri and Svelte in Vite.
3
+This is an example app of Tauri plugin AdMob.
4
5
-## Recommended IDE Setup
6
-
7
-[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
5
+## Android XML
6
7
+Replace the `gen/android/app/src/main/AndroidManifest.xml` manifest with the one in the `gen-override`.
examples/tauri-app/src-tauri/Cargo.toml
+5
-3
@@ -15,9 +15,11 @@ crate-type = ["staticlib", "cdylib", "lib"]
15
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
16
17
[build-dependencies]
18
-tauri-build = { version = "2.0.0-beta.19", default-features = false , features = [] }
18
+tauri-build = { version = "2", default-features = false , features = [] }
19
20
[dependencies]
21
-tauri = { version = "2.0.0-beta.24", features = [] }
21
+tauri = { version = "2", features = [] }
22
+tauri-plugin-devtools = "2"
23
+
24
+[target.'cfg(target_os = "android")'.dependencies]
25
tauri-plugin-admob = { path = "../../../" }
23
-tauri-plugin-devtools = "2.0.0-beta"
examples/tauri-app/src-tauri/gen-override/android/app/src/main/AndroidManifest.xml
new
+45
@@ -0,0 +1,45 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+ <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
5
+
6
+ <!-- AndroidTV support -->
7
+ <uses-feature android:name="android.software.leanback" android:required="false" />
8
+
9
+ <application
10
+ android:icon="@mipmap/ic_launcher"
11
+ android:label="@string/app_name"
12
+ android:theme="@style/Theme.tauri_app"
13
+ android:usesCleartextTraffic="${usesCleartextTraffic}">
14
+ <activity
15
+ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
16
+ android:launchMode="singleTask"
17
+ android:label="@string/main_activity_title"
18
+ android:name=".MainActivity"
19
+ android:exported="true">
20
+ <intent-filter>
21
+ <action android:name="android.intent.action.MAIN" />
22
+ <category android:name="android.intent.category.LAUNCHER" />
23
+ <!-- AndroidTV support -->
24
+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
25
+ </intent-filter>
26
+ </activity>
27
+
28
+ <provider
29
+ android:name="androidx.core.content.FileProvider"
30
+ android:authorities="${applicationId}.fileprovider"
31
+ android:exported="false"
32
+ android:grantUriPermissions="true">
33
+ <meta-data
34
+ android:name="android.support.FILE_PROVIDER_PATHS"
35
+ android:resource="@xml/file_paths" />
36
+ </provider>
37
+
38
+ <meta-data
39
+ android:name="com.google.android.gms.ads.APPLICATION_ID"
40
+ android:value="ca-app-pub-3940256099942544~3347511713"/>
41
+ <meta-data
42
+ android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
43
+ android:value="true"/>
44
+ </application>
45
+</manifest>
examples/tauri-app/src-tauri/src/lib.rs
+8
-1
@@ -13,7 +13,14 @@ pub fn run() {
13
14
builder
15
.invoke_handler(tauri::generate_handler![greet])
16
- .plugin(tauri_plugin_admob::init())
16
+ .setup(|#[allow(unused)] app| {
17
+ // Android-only plugin.
18
+ #[cfg(target_os = "android")]
19
+ {
20
+ app.handle().plugin(tauri_plugin_admob::init())?;
21
+ }
22
+ Ok(())
23
+ })
24
.run(tauri::generate_context!())
25
.expect("error while running tauri application");
26
}
examples/tauri-app/src/App.svelte
+3
-9
@@ -1,16 +1,10 @@
1
<script lang="ts">
2
-import { BannerAd, InterstitialAd } from "tauri-plugin-admob-api";
2
+import { BannerAd } from "tauri-plugin-admob-api";
3
import Greet from "./lib/Greet.svelte";
4
5
let response = "";
6
7
-function updateResponse(returnValue) {
8
- response += `[${new Date().toLocaleTimeString()}] ${
9
- typeof returnValue === "string" ? returnValue : JSON.stringify(returnValue)
10
- }<br>`;
11
-}
12
-
13
-async function _ping() {
7
+async function showBannerAd() {
8
const banner = new BannerAd({
9
adUnitId: "ca-app-pub-3940256099942544/9214589741",
10
position: "top",
@@ -46,7 +40,7 @@ async function _ping() {
40
</div>
41
42
<div>
49
- <button on:click="{_ping}">Ping</button>
43
+ <button on:click="{showBannerAd}">Show Banner Ad</button>
44
<div>{@html response}</div>
45
</div>
46
examples/tauri-app/src/lib/Greet.svelte
+1
-2
@@ -1,7 +1,7 @@
1
<script>
2
import { invoke } from "@tauri-apps/api/core";
3
4
-const name = "";
4
+let name = "";
5
let greetMsg = "";
6
7
async function greet() {
@@ -19,4 +19,3 @@ async function greet() {
19
</div>
20
<p>{greetMsg}</p>
21
</div>
22
-