org.gradle.tooling.BuildException:java.io.IOException:无法生成 v1 签名

Posted

技术标签:

【中文标题】org.gradle.tooling.BuildException:java.io.IOException:无法生成 v1 签名【英文标题】:org.gradle.tooling.BuildException: java.io.IOException: Failed to generate v1 signature 【发布时间】:2018-10-16 02:05:11 【问题描述】:

有时我的项目此时无法运行(它重建成功但无法运行): 不幸的是我还不擅长gradle的东西,请帮助Q_Q

:app:mergeDebugJniLibFolders 4ms

:app:transformNativeLibsWithMergeJniLibsForDebug 359ms

:app:processDebugJavaRes

:app:transformResourcesWithMergeJavaResForDebug 436ms

:app:validateSigningDebug 1ms :app:packageDebug 428ms (导致错误)

执行taskAction 421ms

它说:原因:java.lang.IllegalArgumentException: Mandatory Manifest-Version 属性缺失

清单文件内容如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.c7j.wna">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>


    <application
        android:name="net.c7j.wna.MyApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <uses-library android:name="com.google.android.maps" />

        <service android:name="net.c7j.wna.presentation.service.ForegroundService"/>
        <receiver android:name="net.c7j.wna.presentation.service.MyAlarmReceiver">
            <intent-filter>
                <action android:name="com.example.helloandroid.alarms" />
            </intent-filter>
        </receiver>

        <service android:name="net.c7j.wna.presentation.bootservice.AlarmSetService"/>
        <receiver android:name="net.c7j.wna.presentation.bootservice.BootReceiver" android:enabled="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>


        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/google_maps_api_key" />

        <activity
            android:name="net.c7j.wna.presentation.view.ActivityPlay"
            android:windowSoftInputMode="adjustResize"
            android:screenOrientation="portrait"
            android:launchMode="singleTask"
            >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

这是构建 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'me.tatarka.retrolambda'

android 
    compileSdkVersion 27
    defaultConfig 
        applicationId "net.c7j.wna"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        javaCompileOptions 
            annotationProcessorOptions 
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            
        
    
    buildTypes 
        release 
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        
    
    packagingOptions 
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        pickFirst 'META-INF/*'
     // for butterknife
    lintOptions 
        disable 'ContentDescription'
    

    compileOptions 
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    


def ver = [:]
ver.butterknife = "8.8.1"
ver.constraint = "1.0.2"
ver.glide = "3.8.0"
ver.okhttp_logging_interceptor = "3.9.0"
ver.picasso = "2.71828"
ver.retrofit2 = "2.3.0"
ver.room = "1.1.0-beta2"
ver.rx_java2 = "2.1.3"
ver.rx_android2 = "2.0.1"
ver.stetho = "1.5.0"
ver.support = "27.1.0"
ver.play_services = "12.0.1";
//

dependencies 
    implementation "com.google.firebase:firebase-core:$ver.play_services"
    implementation "com.google.android.gms:play-services-ads:$ver.play_services"
    implementation "com.google.android.gms:play-services-maps:$ver.play_services"
    implementation "com.android.support:appcompat-v7:$ver.support"
    implementation "com.android.support:recyclerview-v7:$ver.support"
    implementation "com.android.support:design:$ver.support"
    implementation "com.android.support.constraint:constraint-layout:$ver.constraint"
    implementation "com.jakewharton:butterknife:$ver.butterknife"
    annotationProcessor "com.jakewharton:butterknife-compiler:$ver.butterknife"
    implementation "com.squareup.picasso:picasso:$ver.picasso"
    implementation "io.reactivex.rxjava2:rxjava:$ver.rx_java2"
    implementation "io.reactivex.rxjava2:rxandroid:$ver.rx_android2"
    implementation "com.squareup.retrofit2:retrofit:$ver.retrofit2"
    implementation "com.squareup.retrofit2:converter-gson:$ver.retrofit2"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$ver.retrofit2"
    implementation "android.arch.persistence.room:runtime:$ver.room"
    implementation "android.arch.persistence.room:rxjava2:$ver.room"
    annotationProcessor "android.arch.persistence.room:compiler:$ver.room"
    implementation "com.facebook.stetho:stetho:$ver.stetho"


//gradle assemble --stacktrace
//Don't move this apply plugin above or project will fail to build
apply plugin: 'com.google.gms.google-services'

根 build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.


buildscript 

    repositories 
        google()
        jcenter()
        mavenCentral()
    
    dependencies 
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
        classpath 'com.google.gms:google-services:3.2.0'
        classpath 'me.tatarka:gradle-retrolambda:3.7.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    


allprojects 
    repositories 
        google()
        jcenter()
        mavenCentral()
    


task clean(type: Delete) 
    delete rootProject.buildDir

运行 gradle assemble --stacktrace 后:

错误:失败:构建失败并出现异常。

出了什么问题: 在根项目“wna3”中找不到任务“gradle”。

尝试: 运行 gradle 任务以获取可用任务的列表。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

例外情况是: org.gradle.execution.TaskSelectionException:在根项目“wna3”中找不到任务“gradle”。 在 org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:116) 在 org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:81) 在 org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineTaskParser.java:42) 在 org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:44) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54) 在 org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$000(DefaultBuildConfigurationActionExecuter.java:25) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.proceed(DefaultBuildConfigurationActionExecuter.java:54) 在 org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:48) 在 org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:36) 在 org.gradle.initialization.DefaultGradleLauncher$CalculateTaskGraph.run(DefaultGradleLauncher.java:268) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在 org.gradle.initialization.DefaultGradleLauncher.constructTaskGraph(DefaultGradleLauncher.java:175) 在 org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:130) 在 org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109) 在 org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78) 在 org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75) 在 org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152) 在 org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100) 在 org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75) 在 org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53) 在 org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 在 org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 在 org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32) 在 org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在 org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40) 在 org.gradle.tooling.internal.provider.SubscribableBuildActionRunner.run(SubscribableBuildActionRunner.java:51) 在 org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47) 在 org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30) 在 org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:39) 在 org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:25) 在 org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:80) 在 org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:53) 在 org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:57) 在 org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32) 在 org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36) 在 org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25) 在 org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43) 在 org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29) 在 org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:69) 在 org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:30) 在 org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:59) 在 org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:44) 在 org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:45) 在 org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30) 在 org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67) 在 org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) 在 org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) 在 org.gradle.util.Swapper.swap(Swapper.java:38) 在 org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62) 在 org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82) 在 org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) 在 org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) 在 org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) 在 org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295) 在 org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 在 org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) 在 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)

通过https://help.gradle.org获得更多帮助

3 秒内构建失败

完整的堆栈跟踪:

org.gradle.api.tasks.TaskExecutionException:任务“:app:packageDebug”执行失败。 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100) 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) 在 org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) 在 org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62) 在 org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) 在 org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60) 在 org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97) 在 org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87) 在 org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) 在 org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) 在 org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) 在 org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 在 org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) 在 org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在 org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) 在 org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) 在 org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123) 在 org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79) 在 org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104) 在 org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98) 在 org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626) 在 org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581) 在 org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) 在 org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 在 org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 在 org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 在 java.lang.Thread.run(Thread.java:745) 原因:org.gradle.tooling.BuildException: java.io.IOException: Failed to generate v1 signature 在 com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:241) 在 java.util.ArrayList.forEach(ArrayList.java:1251) 在 com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236) 在 com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197) 在 com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181) 在 com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTask​​Action(PackageAndroidArtifact.java:471) 在 com.android.build.gradle.internal.tasks.IncrementalTask​​.taskAction(IncrementalTask​​.java:109) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) 在 org.gradle.api.internal.project.taskfactory.IncrementalTask​​Action.doExecute(IncrementalTask​​Action.java:46) 在 org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) 在 org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) 在 org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110) 在 org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) ... 32 更多 原因:java.lang.RuntimeException: java.io.IOException: Failed to generate v1 signature 在 java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431) 在 java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) 在 java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) 在 java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) 在 java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) 原因:java.io.IOException:无法生成 v1 签名 在 com.android.apkzlib.sign.SigningExtension.onOutputZipReadyForUpdate(SigningExtension.java:297) 在 com.android.apkzlib.sign.SigningExtension.access$200(SigningExtension.java:55) 在 com.android.apkzlib.sign.SigningExtension$1.lambda$beforeUpdate$2(SigningExtension.java:175) 在 com.android.apkzlib.zip.ZFile.notify(ZFile.java:2099) 在 com.android.apkzlib.zip.ZFile.update(ZFile.java:871) 在 com.android.apkzlib.zip.ZFile.close(ZFile.java:1161) 在 com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:189) 在 com.google.common.io.Closer.close(Closer.java:216) 在 com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:332) 在 com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:700) 在 com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:522) 在 com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186) 在 com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203) 在 com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225) 在 java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424) ... 4 更多 原因:java.lang.IllegalArgumentException: Mandatory Manifest-Version 属性缺失 在 com.android.apksig.internal.jar.ManifestWriter.writeMainSection(ManifestWriter.java:47) 在 com.android.apksig.internal.apk.v1.V1SchemeSigner.generateManifestFile(V1SchemeSigner.java:363) 在 com.android.apksig.internal.apk.v1.V1SchemeSigner.sign(V1SchemeSigner.java:253) 在 com.android.apksig.DefaultApkSignerEngine.outputJarEntries(DefaultApkSignerEngine.java:372) 在 com.android.apkzlib.sign.SigningExtension.onOutputZipReadyForUpdate(SigningExtension.java:295) ... 18 更多

【问题讨论】:

【参考方案1】:
packagingOptions 
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        pickFirst 'META-INF/*'
     // for butterknife

这行是原因。删除,一切都很好。

【讨论】:

以上是关于org.gradle.tooling.BuildException:java.io.IOException:无法生成 v1 签名的主要内容,如果未能解决你的问题,请参考以下文章