2016-12-15 88 views
0

我想使用this指南整合google admob。解决了一些问题后,gradle现在告诉我,我需要一个google-services.json文件来处理'app:processDebugGoogleServices'。要获得这个文件,我需要去here,基本上只是下载它专门为我的应用程序。Google admob for android without google-services.json

有没有办法使用谷歌admob没有绑定每个应用程序与独特的google-services.json文件?我的意思是我能够为不同的应用程序使用单个文件,或者根本就不使用此文件?据我所知,有几个广告网络(例如Appodeal)使用谷歌admob,但安装Appodeal我根本不需要使用这个google-services.json

我的意思是,对于每个独特应用的Appodeal,我只需要一个唯一的广告单元ID。对于Google Admob,我需要唯一的广告单元ID和唯一的google-services.json,这对我来说不方便。有工作吗?

回答

0

你应该能够做这样的事情:

FirebaseOptions firebaseOptions = new FirebaseOptions.Builder() 
      .setApiKey(apiKey) 
      .setApplicationId(context.getString(R.string.google_app_id)) 
      .build(); 
    return FirebaseApp.initializeApp(context, firebaseOptions, "MyApp"); 
+0

1.我需要首先编译我的项目,但没有谷歌,services.json gradle这个不同步; 2.我在哪里获得apiKey和google_app_id?我只有广告单元ID。 –

+0

它给了什么错误? –

+0

我在问题中提到它:'错误:执行任务失败:app:processDebugGoogleServices'。 >文件google-services.json从模块根文件夹中丢失。如果没有Google服务插件,Google服务插件将无法正常运行。# –