From 9fb365d92e29684f9009406e9c3dcf51b2bc6568 Mon Sep 17 00:00:00 2001 From: lihongwei Date: Tue, 26 Nov 2024 18:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5firebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 25 ++++++++++++---- app/google-services.json | 29 +++++++++++++++++++ .../com/key/vibekeyboard/AppApplication.java | 14 +++++++++ build.gradle.kts | 3 ++ 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 app/google-services.json diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e534f39..2a879cf 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,6 +3,8 @@ import java.util.Date plugins { alias(libs.plugins.android.application) + id("com.google.gms.google-services") + id("com.google.firebase.crashlytics") } val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date()) android { @@ -13,13 +15,16 @@ android { viewBinding = true } - defaultConfig { + defaultConfig { applicationId = "com.key.vibekeyboard" minSdk = 23 targetSdk = 34 versionCode = 1 versionName = "1.0.0" - setProperty("archivesBaseName", "Mobile Keyboard" + versionName + "(${versionCode})_$timestamp") + setProperty( + "archivesBaseName", + "Mobile Keyboard" + versionName + "(${versionCode})_$timestamp" + ) testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -48,13 +53,23 @@ dependencies { androidTestImplementation(libs.ext.junit) androidTestImplementation(libs.espresso.core) // Room 运行时库 - implementation ("androidx.room:room-runtime:2.6.1") + implementation("androidx.room:room-runtime:2.6.1") // Room 编译器,用于生成代码 - annotationProcessor ("androidx.room:room-compiler:2.6.1") + annotationProcessor("androidx.room:room-compiler:2.6.1") // Glide 依赖 - implementation ("com.github.bumptech.glide:glide:4.16.0") + implementation("com.github.bumptech.glide:glide:4.16.0") //Zip implementation("com.github.omicronapps:7-Zip-JBinding-4Android:Release-16.02-2.02") + // Import the BoM for the Firebase platform + implementation(platform("com.google.firebase:firebase-bom:33.6.0")) + + // Add the dependencies for the Crashlytics and Analytics libraries + // When using the BoM, you don't specify versions in Firebase library dependencies + implementation("com.google.firebase:firebase-crashlytics") + implementation("com.google.firebase:firebase-analytics") + implementation("com.google.firebase:firebase-config") + + } \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..42f68f7 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "480699017036", + "project_id": "mobile-keyboard-e527a", + "storage_bucket": "mobile-keyboard-e527a.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:480699017036:android:bb1e5d95fac488d87a51e9", + "android_client_info": { + "package_name": "com.key.vibekeyboard" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyCfnLHjdKzPePbdUvB-VzlV3s750tPLf2E" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/app/src/main/java/com/key/vibekeyboard/AppApplication.java b/app/src/main/java/com/key/vibekeyboard/AppApplication.java index 99ffe82..4ae47e5 100644 --- a/app/src/main/java/com/key/vibekeyboard/AppApplication.java +++ b/app/src/main/java/com/key/vibekeyboard/AppApplication.java @@ -2,7 +2,9 @@ package com.key.vibekeyboard; import android.app.Application; import android.content.Context; +import android.util.Log; +import com.google.firebase.FirebaseApp; import com.key.vibekeyboard.Room.Category; import com.key.vibekeyboard.Room.MyDatabase; import com.key.vibekeyboard.Room.WallpaperInfo; @@ -20,12 +22,24 @@ public class AppApplication extends Application { public static final int DB_Version = 1; public static final String DB_Name = "image_database"; + + public static final String TAG = "--------------"; @Override public void onCreate() { super.onCreate(); instance = this; categories = Mytool.parseJsonToList("keyboard.json"); + // 确保Firebase初始化 +// FirebaseApp.initializeApp(this); +// +// // 输出日志以确认Firebase初始化 +// if (!FirebaseApp.getApps(this).isEmpty()) { +// Log.d(TAG, "Firebase 初始化成功"); +// } else { +// Log.e(TAG, "Firebase 初始化失败"); +// } + Mytool.runIO(new Runnable() { @Override public void run() { diff --git a/build.gradle.kts b/build.gradle.kts index d21a48a..d573bc1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,7 @@ // 顶级构建文件,用于添加所有子项目/模块的公共配置选项 plugins { alias(libs.plugins.android.application) apply false + + id("com.google.gms.google-services") version "4.4.2" apply false + id ("com.google.firebase.crashlytics") version "3.0.2" apply false }