[英]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:
首先检查所需的流程,例如:
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.