5

I updated Android studio from Preview 2 to Preview 3 and now I get this error when I try to generate a release APK:

Error:A problem was found with the configuration of task ':app:packageProdRelease'.
> File '/Users/jay/repositories/test/app/build/intermediatesError:A problem was found with the configuration of task ':app:packageProdRelease'.
> File '/Users/jay/repositories/test/app/build/intermediates/res/resources-prod-release-stripped.ap_' specified for property 'resourceFile' does not exist.

I've read that it might be related to instant run feature so I disabled it and still the same error. And then, I tried to set shrinkResources attribute to false and then It works. BUT when I tried uploading the apk in Google Developper Console, it says my apk is not Zipaligned...

Wherever you are Google Developper, Help me out! :O

Phileo99
  • 5,581
  • 2
  • 46
  • 54
Jaythaking
  • 2,200
  • 4
  • 25
  • 67
  • Why are you using a version of AS that's not stable to release APKs? – Pztar Jun 09 '16 at 19:42
  • That's a good question actually... Because I like trouble? -___-" – Jaythaking Jun 09 '16 at 19:49
  • No but seriously, previous preview was okay... I didn't though it could get that worse – Jaythaking Jun 09 '16 at 19:50
  • I am having exactly the same problem. "tried to set shrinkResources attribute to false and then It works. BUT when I tried uploading the apk in Google Developper Console, it says my apk is not zipaligned..." – chubao Jun 16 '16 at 08:31
  • Go back to the last stable release to create your APK...It's working that way – Jaythaking Jun 16 '16 at 16:06
  • 1
    @Pztar don't all Android developers do that? I like AS and love to use the bleeding edge. :D – Sufian Jun 17 '16 at 09:24
  • @Jaythaking try running `./gradlew --refresh-dependencies` in your AndroidStudio's Terminal. Then try generating signed APK. If it doesn't, then post your dependencies portion of your `build.gradle` – Sufian Jun 17 '16 at 09:28
  • This is an issue building a release build of my app in STABLE Android Studio 2.2, just released! – Jeff Lockhart Sep 20 '16 at 21:58
  • This issue in the bug tracker seems to be related: https://code.google.com/p/android/issues/detail?id=211536 It would be good to star and provide additional info for them there. – Jeff Lockhart Sep 20 '16 at 22:01
  • Its not really relevant anymore since there is a RC – Jaythaking Sep 20 '16 at 22:04
  • @wojtek.kalicinski Cannot be a duplicate of a more recent post... You should have posted this on the other post – Jaythaking Jan 09 '17 at 16:47
  • you're right, I didn't paste the correct question ID. Let me try once again: this is a duplicate of: http://stackoverflow.com/questions/36540676/build-intermediates-res-resources-anzhi-debug-stripped-ap-specified-for-prope – wojtek.kalicinski Jan 09 '17 at 17:54
  • @wojtek.kalicinski You have lots of free time to dig a old topic related to a deprecated beta version of Android Studio... This isn't gonna help anyone – Jaythaking Jan 09 '17 at 18:00
  • actually, I was asked about this on Twitter just now. There's an open bug on b.android.com and about 6 questions on SO, still relevant to the current 2.3 beta1 version of Studio. Cleaning them up and providing a correct answer would help a lot of people who are still having problems with this today. – wojtek.kalicinski Jan 09 '17 at 18:03
  • @wojtek.kalicinski My bad... – Jaythaking Jan 09 '17 at 18:39

3 Answers3

5

This problem occurs to me if I am using gradle 2.2.0-alpha3. I found a workaround to this problem. You can solve this by disabling shrinkResources and zipalign in gradle and then run zipalign using command line.

build.gradle:

shrinkResources false
zipAlignEnabled false

Run the zipalign command manually:

<your-android-sdk-path>/sdk/build-tools/23.0.3$ 
./zipalign -v 4 <your-input>.apk <your-output>.apk

Edit:

I just have a try on using older version of gradle 2.1.0, it works without this problem. zipalign problem in gradle 2.2.0-alpha3 is mentioned in this SO thread as well.

Community
  • 1
  • 1
chubao
  • 5,871
  • 6
  • 39
  • 64
  • I don't find it safe to generate the APK using Android Studio Preview 3... If this is hapenning, what else could go wrong? I reverted to the last stable version to generate my Signed APK and it went fine... – Jaythaking Jun 16 '16 at 14:46
  • Yes it could be gradle's plugin version. It causes some bad UI problems as well, [such as this](https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=-opened&id=212804). – Sufian Jun 17 '16 at 09:33
  • I'm seeing no end to problems with gradle and Android Studio. I wish the team would just simply stop developing on their product and go home. They're making life miserable for those of us who actually have to deliver products with this crap – Coder Roadie Dec 09 '16 at 22:45
  • 1
    @CoderRoadie The problem is yours for using a beta release of a product expecting no errors. As software developers you should know what `Beta/Preview` means. – Alberto Méndez Feb 02 '17 at 10:29
1

I was trying to use com.android.tools.build:gradle:2.2.3 in the project build.gradle file which was causing me issues.

I found that I was able to successfully generate a signed APK whenever I changed it to com.android.tools.build:gradle:2.1.0

Mark O'Sullivan
  • 10,138
  • 6
  • 39
  • 60
0

According to a Google Engineer, enabling both minifyEnabled and shrinkResources should work:

buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled true
        shrinkResources true
        zipAlignEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
Phileo99
  • 5,581
  • 2
  • 46
  • 54