GradleでAndroidアプリケーションをリリースしようとしています。
./gradlew clean build assembleRelease
コマンドを含むすべてが機能します。
ただし、proguardを使用しようとすると、Gradleはリリースバージョンのビルドに失敗します。
ここに私が得るエラーがあります(スタックトレースがアクティブになっています):
...
: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
ここに私のgradleファイルがあります:
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
}
}
}
誰が問題が何かを知っていますか?
よろしく
編集:./gradlew clean assembleDebug
は完全に機能します! runProguardがオフに設定されている場合、./gradlew clean build assembleRelease
は機能します。したがって、これは100%proGuardの問題です。
私は過去数時間、この問題と闘ってきました。基本的に、警告がある場合、プロガードタスクは実行を停止します。 -d
をビルドに追加すると、Proguardの警告とスタックトレースを確認できます(例:gradle clean assembleRelease -d
)。スタックトレースには、「上記の警告を最初に修正してください」と記載されていることに注意してください。
ビルドがproguardを通過するポイントに到達するために、-dontwarn
ファイルに文句を言っているproguard-project.txt
エントリを追加する必要がありました。以下のラインに沿ったもの:
-dontwarn org.Apache.lang.**
...等
簡単に言えば...スタックトレースが指示するとおりに実行してください。警告を修正してください! :)
ところで、元の投稿のスタックトレースは、私が遭遇したものとまったく同じではないことを認識したため、申し訳ありません。しかし、明らかに私の問題に対する答えを検索しようとしてここにたどり着いたので、私の答えは役立つと感じています。
うーん、理由はわかりませんが、同じパラメーターを使用して同じタスクを2回開始すると(proguard ...)、2番目のタスクが良いタスクになります。
ただし、2番目のパラメーターが変更されると、タスクは失敗します。
それが誰かを助けることを願っています。
よろしく
Proguard-project.txtで-ignorewarningsを使用できるため、各パッケージを指定する必要はありません。