Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease

I am trying to export apk and I want to enable Proguard but it throwing below error. I read so many answers and tried but didn't worked. Getting below error:

Warning:Exception while processing task java.io.IOException: java.lang.NullPointerException  Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease 

StackTrace:

:app:transformClassesAndResourcesWithProguardForRelease ProGuard, version 5.2.1 Warning: Exception while processing task java.io.IOException: java.lang.NullPointerException :app:transformClassesAndResourcesWithProguardForRelease FAILED  FAILURE: Build failed with an exception.   * What went wrong: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. > Job failed, see logs for details  * Try: Run with --info or --debug option to get more log output.   * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)         at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)         at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)         at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)         at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)         at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)         at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)         at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)         at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)         at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)         at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)         at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)         at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)         at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)         at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)         at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)         at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)         at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)         at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)         at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)         at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)         at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153)         at org.gradle.internal.Factories$1.create(Factories.java:22)         at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)         at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)         at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)         at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)         at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)         at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)         at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)         at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)         at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)         at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)         at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)         at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)         at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)         at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)         at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)         at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)         at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)         at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)         at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)         at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)         at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)         at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)         at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212)         at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)         at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)         at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)         at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)         at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205)         at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)         at org.gradle.launcher.Main.doAction(Main.java:33)         at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)         at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)         at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)         at org.gradle.launcher.GradleMain.main(GradleMain.java:23)         at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)         at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)         at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: java.lang.RuntimeException: Job failed, see logs for details         at com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:196)         at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:178)         at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:174)         at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)         at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)         at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)         at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)         at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)         ... 60 more Caused by: java.io.IOException: java.lang.NullPointerException         at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:283)         at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:63)         at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:173)         at com.android.builder.tasks.Job.runTask(Job.java:49)         at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)         at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:223) Caused by: java.lang.NullPointerException         at proguard.util.FixedStringMatcher.matches(FixedStringMatcher.java:52)         at proguard.util.OrMatcher.matches(OrMatcher.java:46)         at proguard.classfile.util.WarningPrinter.accepts(WarningPrinter.java:89)         at proguard.classfile.util.WarningPrinter.print(WarningPrinter.java:77)         at proguard.KeepClassMemberChecker.checkClassSpecifications(KeepClassMemberChecker.java:76)         at proguard.ConfigurationChecker.check(ConfigurationChecker.java:136)         at proguard.ProGuard.execute(ProGuard.java:73)         at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:54)         at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:254)         ... 5 more 

Gradle file:

buildscript { repositories {     maven { url 'https://maven.fabric.io/public' }    }  dependencies {     classpath 'io.fabric.tools:gradle:1.+'    } }  apply plugin: 'com.android.application' apply plugin: 'io.fabric'  repositories {     maven { url 'https://maven.fabric.io/public' } }  android { compileSdkVersion 25 buildToolsVersion "25"  defaultConfig {     applicationId "package_name"     minSdkVersion 14     targetSdkVersion 25     versionCode 22     versionName "2.3.1"     multiDexEnabled true } buildTypes {     release {         minifyEnabled true         shrinkResources true         debuggable false         proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'         buildConfigField "String", "BASE_URL", "\"http://release.com/\""                 }     debug {         testCoverageEnabled false         minifyEnabled false         shrinkResources false         debuggable true         versionNameSuffix '-dev'         applicationIdSuffix '.dev'          proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'         buildConfigField "String", "BASE_URL", "\"http://test.com/\""         jackOptions {             enabled false         }     }    } productFlavors {  }  dexOptions {     javaMaxHeapSize "2048M"     jumboMode true }  sourceSets {     main { assets.srcDirs = ['src/main/assets', 'src/stage'] }     stage {         res.srcDirs = ['src/stage/res', 'src/main/res/mipmap', 'src/stage/res/mipmap', 'src/stage/res/values']     }     release { java.srcDirs = ['src/release/java', 'src/release/java/'] }     debug { res.srcDirs = ['src/debug/res', 'src/debug/res/drawable'] } } }  dependencies { compile fileTree(dir: 'libs', include: ['*.jar'])  compile 'com.android.support:appcompat-v7:25.1.0' compile "com.android.support:support-v4:25.0.0" compile 'com.android.support:design:25.0.0' compile 'com.android.support:multidex:1.0.1' compile 'com.android.volley:volley:1.0.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.google.android.gms:play-services-analytics:10.0.0' compile 'com.google.android.gms:play-services-gcm:10.0.0' compile 'com.github.freshdesk:hotline-android:1.1.+' compile 'com.appsflyer:af-android-sdk:4+@aar' compile('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {     exclude module: 'support-v4' }   compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {     transitive = true; }  compile 'com.pusher:pusher-java-client:1.4.0' } 

Proguard File:

# Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in F:\android studio\android-sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see #   http://developer.android.com/guide/developing/tools/proguard.html  # Add any project specific keep options here:  # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { #   public *; #}     # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the ProGuard # include property in project.properties. # # For more details, see #   http://developer.android.com/guide/developing/tools/proguard.html  # Add any project specific keep options here:  # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { #   public *; #}  # Obfuscation parameters: #-dontobfuscate -useuniqueclassmembernames -keepattributes SourceFile,LineNumberTable -allowaccessmodification  # Ignore warnings: #-dontwarn org.mockito.** -dontwarn org.junit.** -keepclasseswithmembers class * {     @junit.** *; }  #-dontwarn com.robotium.** #-dontwarn org.joda.convert.**  # Ignore warnings: We are not using DOM model -dontwarn com.fasterxml.jackson.databind.ext.DOMSerializer # Ignore warnings: https://github.com/square/okhttp/wiki/FAQs -dontwarn com.squareup.okhttp.internal.huc.** # Ignore warnings: https://github.com/square/okio/issues/60 -dontwarn okio.** # Ignore warnings: https://github.com/square/retrofit/issues/435 -dontwarn com.google.appengine.api.urlfetch.**  # Keep the pojos used by GSON or Jackson -keep class com.futurice.project.models.pojo.** { *; }  # Keep GSON stuff -keep class sun.misc.Unsafe { *; } -keep class com.google.gson.** { *; }  # Keep Jackson stuff -keep class org.codehaus.** { *; } -keep class com.fasterxml.jackson.annotation.** { *; }  # Keep these for GSON and Jackson -keepattributes Signature -keepattributes *Annotation* -keepattributes EnclosingMethod  # Keep Retrofit -keep class retrofit.** { *; } -keepclasseswithmembers class * {     @retrofit.** *; } -keepclassmembers class * {     @retrofit.** *; }  # Keep Picasso -keep class com.squareup.picasso.** { *; } -keepclasseswithmembers class * {     @com.squareup.picasso.** *; } -keepclassmembers class * {     @com.squareup.picasso.** *; } -keepclassmembers class * {     @com.squareup.picasso.Utils.** *; } -keepattributes SourceFile,LineNumberTable -keep class com.parse.*{ *; } -dontwarn com.parse.** -dontwarn com.squareup.picasso.** -dontwarn com.demach.konotor.service.** -keepclasseswithmembernames class * { } -keep class javax.naming.** { *; } -keepclasseswithmembers class * {     @javax.naming.** *; } -dontwarn javax.naming.** -keep class junit.** { *; } -keepclasseswithmembers class * {     @junit.** *; } -dontwarn junit.**   -keep public class * extends java.lang.Exception -keep public class * extends android.support.v7.app.ActionBarActivity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgent -keep public class * extends android.preference.Preference -keep public class * extends android.support.v4.app.Fragment -keep public class * extends android.support.v4.app.DialogFragment -keep public class * extends android.app.Fragment -keep public class com.android.vending.licensing.ILicensingService  # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native -keepclasseswithmembernames class * {  native <methods>; }  -keep public class * extends android.view.View {  public <init>(android.content.Context);  public <init>(android.content.Context, android.util.AttributeSet);  public <init>(android.content.Context, android.util.AttributeSet, int);  public void set*(...); }  -keepclasseswithmembers class * {  public <init>(android.content.Context, android.util.AttributeSet); }  -keepclasseswithmembers class * {  public <init>(android.content.Context, android.util.AttributeSet, int); }  -keepclassmembers class * extends android.app.Activity {  public void *(android.view.View); }  # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * {  public static **[] values();  public static ** valueOf(java.lang.String); }  -keep class * implements android.os.Parcelable {  public static final android.os.Parcelable$Creator *; }  -keepclassmembers class **.R$* {  public static <fields>; }  -keep class android.support.v4.app.** { *; } -keep interface android.support.v4.app.** { *; } -keep class com.actionbarsherlock.** { *; } -keep interface com.actionbarsherlock.** { *; } # The support library contains references to newer platform versions. # Don't warn about those in case this app is linking against an older # platform version. We know about them, and they are safe. -dontwarn android.support.** -dontwarn com.google.ads.** -dontwarn com.google.android.gms.ads.**  -keep class com.google.android.gms.ads.** { *; }  -dontwarn com.demach.** -dontwarn com.freshdesk.hotline.**  -keep class com.demach.** { *; } -keep class com.freshdesk.hotline.** { *; } #-keep class com.google.gson.demach.** { #    *; #} # Application classes that will be serialized/deserialized over Gson  -keep class cn.trinea.android.** { *; } -keepclassmembers class cn.trinea.android.** { *; } -dontwarn cn.trinea.android.**  -keep class com.crashlytics.** { *; } -dontwarn com.crashlytics.**  # For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations -keepclassmembers enum * {     public static **[] values();     public static ** valueOf(java.lang.String); }  #volley -keep class org.apache.commons.logging.** -keep class com.android.volley.** { *; } -dontwarn com.android.volley.**   #GAID -keep class * extends java.util.ListResourceBundle {     protected Object[][] getContents();  }  -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {         public static final *** NULL;      }  -keepnames @com.google.android.gms.common.annotation.KeepName class * -keepclassmembernames class * {         @com.google.android.gms.common.annotation.KeepName *; }  -keepnames class * implements android.os.Parcelable {        public static final ** CREATOR; }  #pusher -keep class com.pusher.client.** { *; } -keepclassmembers class com.pusher.client.** { *; } -dontwarn com.pusher.client.**  -keep class pusher.java.client.** { *; } -keepclassmembers class pusher.java.client.** { *; } -dontwarn pusher.java.client.**  -dontwarn org.slf4j.**  #GAID -keep public class com.google.** { *; } -dontwarn com.google.**  -dontwarn com.appsflyer.AFKeystoreWrapper -dontwarn uk.co.chrisjenx.calligraphy.CalligraphyConfig -dontwarn uk.co.chrisjenx.calligraphy.CalligraphyUtils -dontwarn uk.co.chrisjenx.calligraphy.CalligraphyConfig -dontwarn uk.co.chrisjenx.calligraphy.CalligraphyUtils 

If anyone has any solution please share here.

like image 920
Vivek Bansal Avatar asked Dec 28 '16 12:12

Vivek Bansal


1 Answers

add the below to your ProGuard rules

-ignorewarnings  -keep class * {     public private *; } 

and rebuild your project.

like image 59
Tandoh Anthony Nwi-Ackah Avatar answered Sep 17 '22 13:09

Tandoh Anthony Nwi-Ackah