Step 5 The Eclipse IDE does not support the AppGallery Connect plug-in. Therefore, you need to place the
agconnect-services.json file in the
assets directory of your project and add the following code to the
Application subclass of the project. If the project does not have an
Application subclass, you need to create a subclass that is inherited from the
Application subclass. For example, create a
MyApplication class.
- public class MyApplication extends Application{
- @Override
- public void onCreate() {
- super.onCreate();
- }
- // TODO: Add the following code:
- @Override
- protected void attachBaseContext(Context context) {
- super.attachBaseContext(context);
- AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context);
- config.overlayWith(new LazyInputStream(context) {
- public InputStream get(Context context) {
- try {
- return context.getAssets().open("agconnect-services.json");
- } catch (IOException e) {
- return null;
- }
- }
- });
- }
- // TODO: End
- }