android - 通过 Android Studio 生成的 Android APK 缺少 MANIFEST.MF 文件
问题描述
我有一个使用 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'
解决方案
我有同样的问题。它不能通过 Android Studio 工作,也不能直接从终端构建。我已经通过添加解决了
signingConfigs {
myDefaultSigningConfigs {
...
v1SigningEnabled true
}
}
我希望它对你的情况有所帮助。
推荐阅读
- linux - 如何动态切换标准输入?- >雷达2
- php - 搜索特定键/值的多维数组
- java - TCP Socket HTTP GET 请求 Content-Length > 0 但不返回实际内容
- vue.js - 根据 Vue-Form-Wizard 中当前步骤中的选择动态加载组件
- sql - 关于使用 powershell 步骤然后使用 SQL DTSX 文件的作业的问题
- umbraco - 出版时的 Umbraco 文化不同
- python - 使用 Python 获取错误输入(Trinket)
- c# - Wix 工具集 - 配置文件的最佳实践?
- tensorflow - Tensorflow GAN:“没有为任何变量提供梯度”
- python - 编写 csv 时循环错误或语法不正确?