【问题标题】:Android APK generated via Android Studio is missing MANIFEST.MF file通过 Android Studio 生成的 Android APK 缺少 MANIFEST.MF 文件
【发布时间】:2020-04-13 15:59:28
【问题描述】:

我有一个使用 android studio 3.6.1 的 android 项目。当我从 Android Studio 生成 apk 时,生成的 APK 文件缺少 META-INF/MANIFEST.MF 文件。但是,当我通过控制台构建 apk 时,一切正常。

我不确定 build.gradle 中的哪些设置控制此文件的创建以及创建时间。在这方面的任何帮助将不胜感激。

在我的 build.gradle 文件中

buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta09' classpath 'com.android.tools.build.jetifier:jetifier-core:1.0.0-beta09' } } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android-extensions' apply from: '../config/quality.gradle' apply plugin: 'com.github.spotbugs' project.extensions.extraProperties.set('SpotBugsTask', com.github.spotbugs.SpotBugsTask) // loads the current project's local settings file Properties localProperties = new Properties() def localPropertiesFile = project.file('../local.properties') if (localPropertiesFile.exists()) { localProperties.load(new FileInputStream(localPropertiesFile)) localProperties.list(System.out) } android { compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } tasks.withType(Test) { // pass the proxy configuration to the gradle test executor systemProperty "http.proxyHost", System.getProperty('http.proxyHost') systemProperty "http.proxyPort", System.getProperty('http.proxyPort') systemProperty "http.proxyUser", System.getProperty('http.proxyUser') systemProperty "http.proxyPassword", System.getProperty('http.proxyPassword') systemProperty "https.proxyHost", System.getProperty('https.proxyHost') systemProperty "https.proxyPort", System.getProperty('https.proxyPort') systemProperty "https.proxyUser", System.getProperty('https.proxyUser') systemProperty "https.proxyPassword", System.getProperty('https.proxyPassword') } def appName = "app_name" def appIdSuffix = "" if (project.hasProperty('appSuffix') && appSuffix ==~ /^[a-zA-Z0-9]*$/) { println("Appending suffix: " + appSuffix) appIdSuffix = appSuffix } compileSdkVersion parent.ext.androidCompileSdkVersion buildToolsVersion parent.ext.androidBuildToolsVersion testOptions { unitTests { includeAndroidResources = true } animationsDisabled = true unitTests.returnDefaultValues = true unitTests.all { maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 systemProperty "testResponse", "${projectDir}/src/testServerDebug/res/raw" testLogging { showStackTraces = true exceptionFormat = "full" events 'passed', 'failed', 'skipped' } maxHeapSize = "4g" } execution 'ANDROIDX_TEST_ORCHESTRATOR' } android { lintOptions { warning "TrustAllX509TrustManager" } } sourceSets { main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/production/kotlin' main.java.srcDirs += 'src/server/kotlin' test.java.srcDirs += 'src/test/kotlin' test.java.srcDirs += 'src/testServerDebug/kotlin' test.java.srcDirs += 'src/testServerDebug/java' androidTest.java.srcDirs += 'src/androidTest/kotlin' } packagingOptions { exclude 'LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/services/javax.annotation.processing.Processor' exclude 'META-INF/app_serverRelease.kotlin_module' } defaultConfig { minSdkVersion parent.ext.androidMinSdkVersion targetSdkVersion parent.ext.androidTargetSdkVersion multiDexEnabled true versionCode 1 versionName "1.0.0" vectorDrawables.useSupportLibrary = true } signingConfigs { debug { storeFile file("keystore.jks") storePassword "test" keyAlias "test" keyPassword "test" } } buildTypes { release { debuggable false minifyEnabled false shrinkResources false multiDexEnabled false if (project.hasProperty("RELEASE_STORE_FILE")) { signingConfig signingConfigs.release } else { signingConfig signingConfigs.debug } proguardFile getDefaultProGuardFile('proguard-release.pro') proguardFile getDefaultProGuardFile('proguard-androidx.pro') proguardFile 'proguard-project.pro' } debug { testCoverageEnabled false ext.enableCrashlytics = false signingConfig signingConfigs.debug } } flavorDimensions "default" productFlavors { production { dimension "default" } server { dimension "default" applicationIdSuffix ".server" + appIdSuffix resValue "string", appName, appIdSuffix } } dexOptions { javaMaxHeapSize "4g" preDexLibraries false } } dependencies { serverImplementation('com.github.tomakehurst:wiremock:2.8.0') { exclude group: 'com.fasterxml.jackson.core' exclude group: 'com.google.guava' exclude group: 'org.apache.httpcomponents' exclude group: 'org.ow2.asm', module: 'asm' } def nav_version = "1.0.0" implementation "android.arch.navigation:navigation-fragment:$nav_version" implementation "android.arch.navigation:navigation-ui:$nav_version" implementation "androidx.core:core-ktx:1.2.0" implementation "android.arch.navigation:navigation-ui-ktx:1.0.0" implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine" kaptAndroidTest 'org.parceler:parceler:1.1.12' testImplementation 'joda-time:joda-time:2.9.6' testImplementation 'junit:junit:4.12' testImplementation 'org.powermock:powermock-api-easymock:1.6.2' testImplementation 'org.powermock:powermock-core:1.6.2' testImplementation 'org.powermock:powermock-module-junit4:1.6.2' testImplementation 'org.powermock:powermock-api-mockito:1.6.2' testImplementation('org.robolectric:robolectric:4.2') { exclude group: 'com.google.guava' } testImplementation 'org.apache.commons:commons-lang3:3.6' testImplementation('org.mockito:mockito-all:1.10.19') { exclude group: 'org.hamcrest', module: 'hamcrest-core' } testImplementation 'org.mockito:mockito-all:1.10.19' testImplementation('com.squareup:fest-android:1.0.8') { exclude group: 'com.android.support', module: 'support-v4' } testImplementation 'androidx.test:core:1.2.0' testImplementation 'androidx.test.ext:junit:1.1.1' testImplementation 'org.apache.httpcomponents:httpclient:4.5.6' androidTestImplementation 'junit:junit:4.12' androidTestImplementation 'com.capitalone.easyscreenshots:easyscreenshots:1.1.0@aar' androidTestImplementation 'com.jraska:falcon:2.1.1' androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0') { exclude module: 'support-annotations' } androidTestImplementation('androidx.test:runner:1.2.0') { exclude module: 'support-annotations' } androidTestImplementation('androidx.test:rules:1.2.0') { exclude module: 'support-annotations' } androidTestImplementation('androidx.test.espresso:espresso-intents:3.2.0') { exclude module: 'design' exclude module: 'support-annotations' exclude module: 'support-v4' exclude module: 'recyclerview-v7' exclude module: 'appcompat' } androidTestImplementation('androidx.test.espresso:espresso-contrib:3.2.0') { exclude module: 'design' exclude module: 'support-annotations' exclude module: 'support-v4' exclude module: 'recyclerview-v7' exclude module: 'appcompat' } androidTestImplementation('androidx.test.espresso:espresso-web:3.2.0') { exclude module: 'design' exclude module: 'support-annotations' exclude module: 'support-v4' exclude module: 'recyclerview-v7' exclude module: 'appcompat' } } apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 你能发布你的 gradle 文件吗?另外,只有当您从 Android Studio 构建时才会发生这种情况吗?从终端构建 APK 怎么样?
  • 当我通过终端构建时,它包含所有文件。只有通过 Android Studio,它不包含上述文件。
  • 我还注意到 CERT.RSA 和 CERT.SF 文件也不存在。
  • 您找到解决方法了吗?问题仅在使用 gradle plugin >= v3.6.0 和 gradle version >= v5.6.4 构建应用程序时
  • Google 问题跟踪器上针对此错误 issuetracker.google.com/issues/168013083 提出了一张票

标签: android android-studio android-signing


【解决方案1】:

我也遇到了同样的问题。它不能通过 Android Studio 工作,也不能直接从终端构建。我已经通过添加解决了它

signingConfigs {
    myDefaultSigningConfigs {
        ...
        v1SigningEnabled true
    }
}

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-15
    • 1970-01-01
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-08
    相关资源
    最近更新 更多