简体   繁体   English

如何将firebase sdk添加到最新的android studio version 2022?

[英]How to add firebase sdk to latest android studio version 2022?

I wanted to add firebase sdk to my android studio project written in kotlin我想将 firebase sdk 添加到我用 kotlin 编写的 android 工作室项目中

as per firebase website it asks to add根据 firebase 网站要求添加

buildscript {
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
  dependencies {
    ...
    // Add the dependency for the Google services Gradle plugin
    classpath 'com.google.gms:google-services:4.3.13'

  }
}

allprojects {
  ...
  repositories {
    // Make sure that you have the following two repositories
    google()  // Google's Maven repository

    mavenCentral()  // Maven Central repository

  }
}

but what i see in my android in build.gradle但我在 build.gradle 中看到的 android

plugins {
    id 'com.android.application' version '7.4.0' apply false
    id 'com.android.library' version '7.4.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}

Documentation are not upto date what to do?文档不是最新的怎么办?

I Tried to add it in setting.gradle with entire buildscript block as well I did the same thing with buil.gradle我试图将它添加到 setting.gradle 中以及整个 buildscript 块我对 buil.gradle 做了同样的事情

This is quite a long process.这是一个相当漫长的过程。 Start by going over the required processes like:首先检查所需的流程,例如:

  • registering with firebase; firebase注册;
  • setting up the android environment (where you are)设置 android 环境(你在哪里)
  • setting up the server environment (most likely your will need this)设置服务器环境(很可能你会需要这个)

For android implementations, you can follow this:https://firebase.google.com/docs/cloud-messaging/android/client对于 android 的实现,你可以按照这个:https://firebase.google.com/docs/cloud-messaging/android/client

For server-side, you can follow this if on PHP: https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html对于服务器端,如果在 PHP 上,您可以按照此操作: https://firebase-php.readthedocs.io/en/stable/cloud-messaging.html

But, specifically to your question:但是,具体针对您的问题:

There are two gradles;有两个等级; Build.gradle( project ) and Build.gradle( Module --app-name) At the module one, where your min-sdk and target-sdk settings are, at the very top and not inside any of the current settings, add these: Build.gradle( project ) 和 Build.gradle( Module --app-name) 在第一个模块中,您的 min-sdk 和 target-sdk 设置位于最顶部,不在任何当前设置中,添加这些:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
}
apply plugin: 'com.android.application'

The one you are seeing is in the project-gradle.您看到的是在项目 gradle 中。 In it some re-ordering may also be required.其中可能还需要一些重新排序。 Just be sure to use the exact one instructed: project or app (module).请务必使用所指示的确切内容:项目或应用程序(模块)。 It took me a while to find out this - especially the placement of the plugins entry .我花了一段时间才弄清楚这一点——尤其是插件条目的位置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在最新的 ZC31B32364CE19CA8FCD150A417ECCE5 中将 firebase json 文件添加到 gradle 项目级别面临困难 - facing difficulty to add firebase json file to gradle project level in latest android version 如何将 Firebase SDK 版本 9 添加到 Service Worker Chrome 扩展清单版本 MV3? - How to add Firebase SDK version 9 to a Service Worker Chrome Extension Manifest Version MV3? 如何在 Flutter 中使用最新版本配置 Firebase Messaging? - How to configure Firebase Messaging with latest version in Flutter? 将 Firebase 应用到 Android Studio 项目版本 Bumblebee - Apply Firebase to Android Studio Project version Bumblebee 如何将值 + 1 添加到 integer? / android 工作室 / firebase / java - how to add the value + 1 to an integer ? / android studio / firebase / java 插件firebase_database需要更高的版本 Android SDK - The plugin firebase_database requires a higher Android SDK version 警告:插件 firebase_storage 需要 Android SDK 版本 31。一个或多个插件需要更高版本 Android SDK - Warning: The plugin firebase_storage requires Android SDK version 31. One or more plugins require a higher Android SDK version 何时/如何更新 Firebase Web SDK 版本号? - When/how to update Firebase web SDK version number? 如何重命名 firebase 存储中的文件夹 - Android studio - how rename folder in firebase storage - Android studio 如何在没有X的Flutter中为ios添加firebase SDK - 代码 - How to add firebase SDK for ios in Flutter without X - Code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM