web-dev-qa-db-fra.com

Echec de l'exécution pour la tâche ': app: transformClassesAndResourcesWithProguardForRelease

J'essaye d'exporter apk et je veux activer Proguard mais il jette en dessous de l'erreur. J'ai lu tellement de réponses et essayé mais je n'ai pas travaillé. Obtenir en dessous de l'erreur:

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

Trace de la pile:

: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'
}

Fichier Proguard:

# 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

Si quelqu'un a une solution s'il vous plaît partager ici.

33
Vivek Bansal

ajoutez ce qui suit à vos règles ProGuard

-ignorewarnings

-keep class * {
    public private *;
}

et reconstruisez votre projet.

79
A.N.T

essayez ceci à votre proguard-rules.pro

-ignorewarnings
-keep class * {
    public private *;
}
7
Ashwin H

Seulement -ignorewarnings cette ligne a résolu mon problème.

Ajoutez également la ligne suivante à <ProjectRoot>/Android/gradle.properties à Obfuscating Dart Code:

extra-gen-snapshot-options=--obfuscate

Pour référence

Aussi, si vous utilisez Firebase Auth , ajoutez-le au fichier proguard-rules.pro:

-keep class com.google.firebase.** { *; }

Partage de mon fichier /Android/app/proguard-rules.pro

#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-ignorewarnings

J'espère que quelqu'un va aider cela

2
Rahul Mahadik

Fermez le projet et Android Studio. Ouvrez à nouveau le projet, reconstruisez le projet. Et ensuite, vous pouvez essayer de générer l'APK. Cela a fonctionné pour moi. Bien câblé! 

0
Jakir Hossain

Vous pouvez essayer ce keep class com.xyz.** { *; } -dontwarn com.xyz.**

0
saurabh dixit