2

从android studio生成签名apk时出错。几天后一切正常,而从最近 2 天开始,我遇到了生成签名 apk 的问题。

错误是 -

FAILURE:构建失败并出现异常。什么地方出了错:

发现任务 ':app:packageRelease' 的配置有问题。为属性“resourceFile”指定的文件“/media/user86/data/MySIPonline/app/build/intermediates/res/resources-release-stripped.ap_”不存在。

我将检查该文件夹和 release-stripped.ap 文件是否存在于其中。我无法找出错误。

这是 build.gradle (app)

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.xxxxxxxxxx"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 15
    versionName "1.5.1"
    multiDexEnabled true
}

buildTypes {
    release {
        minifyEnabled false
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dexOptions {
    javaMaxHeapSize "2048M"
}}


repositories {
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }}



dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile files('libs/paynimo_v2.0_live.jar')
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
    transitive = true;
}
compile files('libs/paynimo.scanner.jar')
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
}
apply plugin: 'com.google.gms.google-services

这是 pro-guard 文件的链接 - https://gist.github.com/Sanwal13/b667326812b87702c86fa02870b28240

请提前帮助和感谢。

4

3 回答 3

2

您需要将该shrinkResources属性设置为 false,因为它不适用于Instant Run功能。如果您使用的是Android Studio 2.2,只需在清单中将其指定为:

buildTypes {
release {
    minifyEnabled false
    shrinkResources false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

如果您使用的是Android Studio 2.0

  1. 打开设置。
  2. 选择构建、执行和部署。
  3. 取消选中启用即时运行选项。
于 2016-10-17T06:21:05.670 回答
0

清理你的项目并尝试生成签名的 APK 我有同样的问题我清理项目重建了它为我工作的项目。

于 2016-10-17T06:15:02.393 回答
0

请按照以下步骤删除您的错误 -

第 1 步: - 清理您的项目

第 2 步: - 重建您的项目

第 3 步: - 使 Android Studio 无效并重新启动

第 4 步: - 使用以下代码编辑 build.gradle

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

只需删除- 这条线

收缩资源假

问题解决 :)

于 2016-10-17T06:40:54.127 回答