Hélder Lima
Hélder Lima

Reputation: 21

Error generating signed APK with proguard - Project with GMS

I'm getting errors when try generates assigned APK with proguard. Bellow the messages returned:

  Warning: com.google.gms.googleservices.GoogleServicesPlugin: can't find superclass or interface org.gradle.api.Plugin
  Warning: com.google.gms.googleservices.GoogleServicesPlugin: can't find superclass or interface groovy.lang.GroovyObject
  ...
  Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
  > java.io.IOException: Please correct the above warnings first.

The problems started after adding Firebase Cloud Messaging into the project. Bellow my build.gradle file.

  apply plugin: 'com.android.application'

  android {
  compileSdkVersion 25
  buildToolsVersion "25.0.2"
  defaultConfig {
  applicationId 'com...'
  minSdkVersion 15
  targetSdkVersion 25
  versionCode 29
  versionName "2.1"
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  multiDexEnabled true
  resConfigs "en", "pt", "fr", "es", "it", "de", "ru"
  }
  buildTypes {
  release {
  shrinkResources true
  minifyEnabled true
  proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  }
  }
  productFlavors {
  }
  packagingOptions {
  exclude 'META-INF/LICENSE'
  exclude 'META-INF/LICENSE-FIREBASE.txt'
  exclude 'META-INF/NOTICE'
  }
  }

  dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
  exclude group: 'com.android.support', module: 'support-annotations'
  })
  compile 'com.android.support:appcompat-v7:25.2.0'
  compile 'com.android.support:design:25.2.0'
  compile 'com.android.support:cardview-v7:25.2.0'
  compile 'com.google.android.gms:play-services:10.2.0'
  compile 'com.google.firebase:firebase-ads:10.2.0'
  compile 'com.android.support:multidex:1.0.1'
  compile 'com.google.gms:google-services:3.0.0'
  compile 'com.google.code.findbugs:jsr305:2.0.1'
  compile 'com.google.firebase:firebase-core:10.2.0'
  compile 'com.google.firebase:firebase-messaging:10.2.0'
  testCompile 'junit:junit:4.12'
  compile project(path: ':backend', configuration: 'android-endpoints')
  }

  apply plugin: 'com.google.gms.google-services'

And now my proguard-rules.pro file.

  -keep class org.gradle.api.** { *; }
  -keep interface org.gradle.api.** { *; }

  -keep class groovy.lang.** { *; }
  -keep interface groovy.lang.** { *; }

  -keep class sun.misc.** { *; }
  -keep interface sun.misc.** { *; }

  -keep class org.codehaus.groovy.runtime.** { *; }
  -keep interface org.codehaus.groovy.runtime.** { *; }

  -keep class org.codehaus.groovy.reflection.** { *; }
  -keep interface org.codehaus.groovy.reflection.** { *; }

  -keep class com.google.gson.** { *; }
  -keep interface com.google.gson.** { *; }

I already try everything that what have the Internet.

Upvotes: 1

Views: 729

Answers (2)

Sayed Abolfazl Fatemi
Sayed Abolfazl Fatemi

Reputation: 3911

I solve the problem by remove com.github.dcendents:android-maven-gradle-plugin:2.0 module from build.gradle of module that I imported its source code in my project.

Upvotes: 0

ianhanniballake
ianhanniballake

Reputation: 199805

You have the following dependency:

compile 'com.google.gms:google-services:3.0.0'

This is not a dependency that your Android app should include, but a line that can be included in the classpath section.

Remove that dependency.

Upvotes: 2

Related Questions