J'essaie de libérer mon application Android avec Gradle.
Tout fonctionne, y compris le ./gradlew clean build assembleRelease
commande.
Cependant, dès que j'essaie d'utiliser proguard, Gradle ne parvient pas à créer la version.
Voici l'erreur que je reçois (trace de pile activée):
...
:OSkin:validateDebugSigning
:OSkin:packageDebug
:OSkin:assembleDebug
:OSkin:prepareReleaseDependencies
:OSkin:compileReleaseAidl
:OSkin:generateReleaseBuildConfig
:OSkin:mergeReleaseAssets
:OSkin:compileReleaseRenderscript
:OSkin:mergeReleaseResources
:OSkin:processReleaseManifest
:OSkin:processReleaseResources
:OSkin:compileRelease UP-TO-DATE
:OSkin:proguardRelease
ProGuard, version 4.9
Reading input...
Reading program directory [/home/geantvert/workspace/OSkinProject/OSkin/build/classes/release]
:OSkin:proguardRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':OSkin:proguardRelease'.
> Can't read [/home/geantvert/workspace/OSkinProject/OSkin/build/classes/release] (No such file or directory)
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':OSkin:proguardRelease'.
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:62)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.Java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.Java:42)
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.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.Java:286)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.Java:80)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.Java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTaskWithCacheLock(AbstractTaskPlanExecutor.Java:58)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.Java:47)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$1.run(DefaultTaskPlanExecutor.Java:33)
at org.gradle.internal.Factories$1.create(Factories.Java:22)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.Java:214)
at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.Java:276)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.Java:142)
at org.gradle.api.internal.changedetection.state.DefaultTaskArtifactStateCacheAccess.longRunningOperation(DefaultTaskArtifactStateCacheAccess.Java:78)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.Java:31)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.Java:89)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.Java:29)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:61)
at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.Java:23)
at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.Java:67)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.Java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:61)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.Java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.Java:166)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.Java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.Java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.Java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.Java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.Java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.Java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.Java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.Java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.Java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.Java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.Java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.Java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.Java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.Java:22)
at org.gradle.launcher.Main.doAction(Main.Java:48)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.Java:45)
at org.gradle.launcher.Main.main(Main.Java:39)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.Java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.Java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.Java:26)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.Java:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.Java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.Java:48)
Caused by: Java.io.IOException: Can't read [/home/geantvert/workspace/OSkinProject/OSkin/build/classes/release] (No such file or directory)
at proguard.InputReader.readInput(InputReader.Java:230)
at proguard.InputReader.readInput(InputReader.Java:200)
at proguard.InputReader.readInput(InputReader.Java:178)
at proguard.InputReader.execute(InputReader.Java:78)
at proguard.ProGuard.readInput(ProGuard.Java:197)
at proguard.ProGuard.execute(ProGuard.Java:79)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.Java:958)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.Java:248)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.Java:136)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.Java:147)
at proguard.gradle.ProGuardTask_Decorated.invokeMethod(Unknown Source)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.Java:248)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.Java:136)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.Java:147)
at proguard.gradle.ProGuardTask_Decorated.invokeMethod(Unknown Source)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.Java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.Java:213)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.Java:202)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.Java:530)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.Java:513)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.Java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.Java:61)
... 53 more
Caused by: Java.io.IOException: No such file or directory
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.Java:50)
at proguard.InputReader.readInput(InputReader.Java:226)
... 75 more
BUILD FAILED
Total time: 42.363 secs
Voici mon fichier de classement:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.Android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'Android'
repositories {
mavenCentral()
maven {
url 'http://www.bugsense.com/gradle/'
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.google.guava:guava:14.+'
compile 'com.google.code.gson:gson:2.+'
compile 'org.zeroturnaround:zt-Zip:1.+'
compile 'com.github.japgolly.Android:svg-Android:2.+'
compile('de.keyboardsurfer.Android.widget:crouton:1.8.1') {
exclude module: 'support-v4'
compile 'com.Android.support:support-v4:18.+'
}
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.okhttp:okhttp:1.2.+'
compile 'com.squareup.picasso:picasso:1+'
compile 'com.bugsense.trace:bugsense:3.5'
//Google Drive SDK
compile 'com.google.Android.gms:play-services:3.+'
compile 'com.google.apis:google-api-services-drive:v2+'
compile('com.google.api-client:google-api-client:1.+') {
exclude(group: 'xpp3', module: 'xpp3')
exclude(group: 'org.Apache.httpcomponents', module: 'httpclient')
exclude(group: 'junit', module: 'junit')
exclude(group: 'com.google.Android', module: 'Android')
}
compile('com.google.api-client:google-api-client-Android:1.+') {
exclude group: 'xpp3'
exclude group: 'com.google.Android.google-play-services'
}
compile('com.google.http-client:google-http-client-jackson:1.+') {
exclude group: 'xpp3'
}
compile('com.google.http-client:google-http-client-gson:1.+') {
exclude group: 'xpp3'
}
compile 'com.google.apis:google-api-services-plus:v1+'
compile 'com.netflix.rxjava:rxjava-Android:+'
compile('com.github.frankiesardo:icepick:2+') {
exclude module: 'support-v4'
compile 'com.Android.support:support-v4:18.+'
}
// compile (group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev56-1.15.0-rc')
}
Android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
signingConfigs {
release {
storeFile file('path_to_file')
storePassword '***'
keyAlias '***'
keyPassword '***'
}
}
buildTypes
{
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-Android.txt')
proguardFile 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
}
Est-ce que quelqu'un a une idée de quel est le problème?
Cordialement
Modifier: ./gradlew clean assembleDebug
fonctionne parfaitement! et ./gradlew clean build assembleRelease
fonctionne si runProguard est désactivé. C'est donc un problème 100% proGuard.
Je lutte contre ce problème depuis quelques heures. Fondamentalement, la tâche proguard arrêtera l'exécution s'il y a des avertissements. Vous pouvez voir les avertissements Proguard et le stacktrace en ajoutant -d
à la construction (comme dans: gradle clean assembleRelease -d
). Notez que le stacktrace mentionne "Veuillez corriger les avertissements ci-dessus en premier."
Afin d'arriver à un point où la construction passerait à travers proguard, je devais ajouter -dontwarn
entrées pour les paquets dont il se plaignait auprès de mon proguard-project.txt
fichier. Quelque chose dans le genre de:
-dontwarn org.Apache.lang.**
...etc
Donc, faites simplement… faites comme le stacktrace vous le demande. Fixer les avertissements! :)
BTW, je m'excuse, car je reconnais maintenant que le stacktrace du message d'origine n'est pas tout à fait le même que celui que j'ai rencontré. Cependant, j’estime que ma réponse est utile, car j’ai bien évidemment fini par chercher ici des réponses à mon problème.
Hmmm, je ne comprends pas pourquoi mais il semble que si je commence deux fois la même tâche avec les mêmes paramètres (proguard ...), la seconde est la bonne.
Mais si le second paramètre change, la tâche échoue.
J'espère que ça va aider quelqu'un.
Cordialement
Vous pouvez utiliser -ignorewarnings dans proguard-project.txt pour ne pas avoir à spécifier chaque paquet.