无效的成员类型插件导致构建失败

时间:2018-10-01 20:38:52

标签: android-studio android-gradle apk

今天,我打开了Android Studio并尝试构建APK,但没有进行任何更改,却收到了以下错误消息:Invalid type in member Type: com/google/gms/googleservices/GoogleServicesPlugin$PluginType; android studio

这是编译器向我抛出的其他一些错误:

errors

我尝试从相应的文件夹中删除0.jar文件,看看是否可以修复其中一个错误,但什么也没有。有任何想法吗?我没有得到应该改变的东西或做错了的事情,因为我什么都没弄乱。

编辑:

public class DokkanCardsApplication extends Application {
@Override
public void onCreate() {
    super.onCreate();
    registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
        @Override
        public void onActivityCreated(Activity activity, Bundle bundle) {

            // Fix for the Full Screen Activities bug with Android O
            if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
                activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            }
        }

        @Override
        public void onActivityStarted(Activity activity) {

        }

        @Override
        public void onActivityResumed(Activity activity) {

        }

        @Override
        public void onActivityPaused(Activity activity) {

        }

        @Override
        public void onActivityStopped(Activity activity) {

        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {

        }

        @Override
        public void onActivityDestroyed(Activity activity) {

        }
    });
}

}

1 个答案:

答案 0 :(得分:1)

您可以从Android Studio左侧的顶部将视图从Android更改为Project,然后删除.gradle文件,这可能会对您有所帮助。 而且我认为您也必须在应用程序中启用multidex

这样做:

android {
        defaultConfig {
           multiDexEnabled true
        }
    }

第二,将其添加到四个依赖项:

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

最后创建一个像这样的应用程序类:

public class MyApplication extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}

最后不要忘了像这样将应用程序类添加到清单中:

 <application
    android:name=".MyApplication"

更新:

您的应用程序类应如下:

public class DokkanCardsApplication extends Application {


  @Override
  protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
  }

  @Override
  public void onCreate() {
    super.onCreate();
    registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
      @Override
      public void onActivityCreated(Activity activity, Bundle bundle) {

        // Fix for the Full Screen Activities bug with Android O
        if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
          activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
      }

      @Override
      public void onActivityStarted(Activity activity) {

      }

      @Override
      public void onActivityResumed(Activity activity) {

      }

      @Override
      public void onActivityPaused(Activity activity) {

      }

      @Override
      public void onActivityStopped(Activity activity) {

      }

      @Override
      public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {

      }

      @Override
      public void onActivityDestroyed(Activity activity) {

      }
    });
  }