Reputation: 25
I have some problem about apply plugin: 'com.google.gms.google-services'
.
when I insert
apply plugin: 'com.google.gms.google-services'
in build.gradle
, it makes error
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
and when I erase that code, sync works well. But I have to use:
apply plugin: 'com.google.gms.google-services'
because I want to make FirebaseApp notification.
If I erase that code,
Make sure to call FirebaseApp.initializeApp(Context)
first
Error comes. I can't figure what should I do.
Upvotes: 1
Views: 2168
Reputation: 16976
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api
Is actually referring to dependencies compile use which you should replace it with implementation
instead of compile
and of course you should initialize FireBase first.
Don't remove:
apply plugin: 'com.google.gms.google-services'
And in build.gradle
, change dependencies which starts by compile
to implementation
.
That's just a warning however which you can ignore it and replace it with implementation
like I said
Upvotes: 0
Reputation: 11419
Summarizing what you need to do:
in your build.gradle
file:
dependencies {
classpath 'com.google.gms:google-services:4.1.0'
// ...
}
as the last line in your build.gradle
add:
apply plugin: 'com.google.gms.google-services'
then define your Application class:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FirebaseApp.initializeApp(getApplicationContext());
...
}
...
}
and in your AndroidManifest
file:
<application
android:name="your.packagename.MyApplication"
Upvotes: 1