Closed zhengzhuoxing closed 6 years ago
if (!isV2SignatureSchemeEnabled(variant)) {
throw new ProjectConfigurationException("Plugin requires 'APK Signature Scheme v2 Enabled' for ${variant.name}.", null);
}
14:17 Executing tasks: [:API:generateDebugSources, :API:mockableAndroidJar, :API:prepareDebugUnitTestDependencies, :API:generateDebugAndroidTestSources, :BaseUI:generateDebugSources, :BaseUI:mockableAndroidJar, :BaseUI:prepareDebugUnitTestDependencies, :BaseUI:generateDebugAndroidTestSources, :StudentApp:generateDebugSources, :StudentApp:generateDebugAndroidTestSources, :StudentApp:mockableAndroidJar, :StudentApp:prepareDebugUnitTestDependencies, :TeacherApp:generateDebugSources, :TeacherApp:generateDebugAndroidTestSources, :TeacherApp:mockableAndroidJar, :TeacherApp:prepareDebugUnitTestDependencies, :androidtagview:generateDebugSources, :androidtagview:mockableAndroidJar, :androidtagview:prepareDebugUnitTestDependencies, :androidtagview:generateDebugAndroidTestSources, :ptrRefreshlibrary:generateDebugSources, :ptrRefreshlibrary:generateDebugAndroidTestSources, :ptrRefreshlibrary:mockableAndroidJar, :ptrRefreshlibrary:prepareDebugUnitTestDependencies]
14:22 Gradle build finished with 1 warnings(s) in 4m 54s 655ms
14:23 Gradle sync started
14:23 Gradle sync failed: Plugin requires 'APK Signature Scheme v2 Enabled' for sourceSets. Consult IDE log for more details (Help | Show Log)
15:29 Gradle sync started
15:29 Gradle sync failed: Plugin requires 'APK Signature Scheme v2 Enabled' for sourceSets. Consult IDE log for more details (Help | Show Log)
Signature Scheme v2 Enabled 在gradle2.2之后是自动开启的不是么
Android 7.0 引入一项新的应用签名方案 APK Signature Scheme v2,它能提供更快的应用安装时间和更多针对未授权 APK 文件更改的保护。在默认情况下,Android Studio 2.2 和 Android Plugin for Gradle 2.2 会使用 APK Signature Scheme v2 和传统签名方案来签署您的应用。 我并没有手动去关闭它啊
build.gradle里开启V2签名了吗?或者把walle注释掉,打一个包看看是否有签名区(在Apk文件中通过字符串查找 “APK Sig Block 42”)
在Apk中有 APK Sig Block 42PK,但是我这还是提示未开启 APK Signature Scheme v2
project.afterEvaluate {
project.android.applicationVariants.all { BaseVariant variant ->
def variantName = variant.name.capitalize();
if (!isV2SignatureSchemeEnabled(variant)) {
throw new ProjectConfigurationException("Plugin requires 'APK Signature Scheme v2 Enabled' for ${variant.name}.", null);
}
}
}
boolean isV2SignatureSchemeEnabled(BaseVariant variant) throws GradleException {
def signingConfig = getSigningConfig(variant);
if (signingConfig == null || !signingConfig.isSigningReady()) {
return false;
}
// check whether APK Signature Scheme v2 is enabled.
if (signingConfig.hasProperty("v2SigningEnabled") &&
signingConfig.v2SigningEnabled == true) {
return true;
}
return false;
}
这个是判断逻辑, 把这段贴到项目的build.gradle中跑下看看是否会出错
BaseVariant 找不到
com.android.build.gradle.api.BaseVariant
把这段代码添加上之后 还是报 这个错 Error:Plugin requires 'APK Signature Scheme v2 Enabled' for sourceSets.
SigningConfig getSigningConfig(BaseVariant variant) {
return variant.buildType.signingConfig == null ? variant.mergedFlavor.signingConfig : variant.buildType.signingConfig;
}
def signingConfig = getSigningConfig(variant);
if (signingConfig == null || !signingConfig.isSigningReady()) {
return false;
}
// check whether APK Signature Scheme v2 is enabled.
if (signingConfig.hasProperty("v2SigningEnabled") &&
signingConfig.v2SigningEnabled == true) {
return true;
}
return false;
这个条件满足吗?
Error:(102, 0) Could not find method getSigningConfig() for arguments [com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@7c88a66e] on project 找不到这个方法
加上这个
SigningConfig getSigningConfig(BaseVariant variant) {
return variant.buildType.signingConfig == null ? variant.mergedFlavor.signingConfig : variant.buildType.signingConfig;
}
我用命令行打包了,不用配置gradle了 谢谢你的帮助
这个问题怎么解决的啊?
加上--stacktrace把详细的日志信息发出来, 一般这种情况是未开启V2签名或者V2签名被破坏了