diff --git a/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy b/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy index 7fe73b38..102b626d 100644 --- a/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy +++ b/AndResGuard-gradle-plugin/src/main/groovy/com/tencent/gradle/AndResGuardTask.groovy @@ -37,11 +37,15 @@ class AndResGuardTask extends DefaultTask { variant.productFlavors, variant.buildType.name) || variantName.equalsIgnoreCase(AndResGuardPlugin.USE_APK_TASK_NAME)) { - def outputFile - if (variant.metaClass.respondsTo(variant, "getPackageApplicationProvider")) { - outputFile = { File(variant.packageApplicationProvider.get().outputDirectory, output.outputFileName) } - } else { - outputFile = output.outputFile + def outputFile = null + try { + if (variant.metaClass.respondsTo(variant, "getPackageApplicationProvider")) { + outputFile = new File(variant.packageApplicationProvider.get().outputDirectory, output.outputFileName) + } + } catch (Exception ignore) { + // no-op + } finally { + outputFile = outputFile ?: output.outputFile } buildConfigs << new BuildInfo(