4

I updated Android Studio 2.0 Preview from 4 to 5 this morning. If I continue to build with:

dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}

this will still compile successfully. But if I move up to -alpha5 I get this error:

Error:Execution failed for task ':app:compileReleaseJavaWithJavac'. java.io.FileNotFoundException: C:....\intermediates\exploded-aar\com.google.android.gms\play-services\8.4.0\jars\classes.jar (The system cannot find the path specified)

KairisCharm
  • 1,363
  • 1
  • 13
  • 32
  • I am having the same problem. I am also using `com.google.gms:google-services:2.0.0-alpha5`. Like you, I can go back to `alpha3` and it works fine. – Chad Bingham Jan 15 '16 at 02:22
  • I reported the issue here. https://code.google.com/p/android/issues/detail?id=198904 – Chad Bingham Jan 15 '16 at 02:37
  • Any luck? @ChadBingham – gbhall Jan 15 '16 at 05:14
  • @gbhall No. Ill post an answer if i find anything out and Ill let you know. For now, just use `alpha3`. – Chad Bingham Jan 15 '16 at 05:20
  • @ChadBingham Yeah I had a similar problem which I posted about on SO, but deleted after I realised it was trivial and due to my setup. I was referencing a file to include in my build that I no longer had. On previous versions of Gradle it did not care, however alpha-5 it threw the same FileNotFoundException. I think alpha-5 may be more strict. – gbhall Jan 15 '16 at 06:03
  • how to go back to alpha-3 then? I'm getting this error too and not sure how to get past it – user1406716 Jan 15 '16 at 06:13
  • @user1406716 In your projects (not app) build.gradle file, change the classpath which will have ``2.0.0-alpha5`` to ``2.0.0-alpha3`` – gbhall Jan 15 '16 at 06:16

2 Answers2

8

From now on, I think Google expects us to not use this:

'com.google.android.gms:play-services:8.4.0'

But rather add the services you need specifically. Find a list of them here

compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'

Also, you need to apply play service plugin in last line of your application's gradle:

apply plugin: 'com.google.gms.google-services'
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
Shawn Thye
  • 386
  • 3
  • 11
  • Just tried it. Wohoo that works! Thanks man. Keeping up with all the different new ways Google wants you to do things is a nightmare. – gbhall Jan 15 '16 at 09:42
  • 2
    When I try to add the line "apply plugin: 'com.google.gms.google-services'" I get the error "Plugin with id 'com.google.gms.google-services' not found." – KairisCharm Jan 15 '16 at 15:04
  • 1
    But... if I DON'T include that line, this works! Thanks Shawn! You're a rock star! – KairisCharm Jan 15 '16 at 15:19
  • 1
    Yes, they did it again. This change will help to avoid the 64k limit read the link Shawn sent. – Pedro Varela Jan 15 '16 at 15:26
  • Excellent answer. Looks like they are going to work a real fix this, but this seems like a really efficient workaround. – Chad Bingham Jan 15 '16 at 17:07
  • @KairisCharm you need to also add the services plug in dependency in the root gradle which 'com.google.gms:google-services:2.0.0-alpha5' – Shawn Thye Jan 15 '16 at 17:31
  • @ChadBingham I think it better now, because google allow you to include by needs, and i found that gradle build was actually faster – Shawn Thye Jan 15 '16 at 17:33
  • 1
    @ShawnThye yeah, i agree. It put me below the dex limit and my instant run is much faster. I think this is more than a workaround, but a sufficient solution. – Chad Bingham Jan 15 '16 at 17:34
  • Actually, this solution worked, but now I have a new problem: http://stackoverflow.com/questions/34818026/android-preview-build-tools-alpha-5-wont-deploy-apk – KairisCharm Jan 15 '16 at 19:06
7

I posted a bug here. They came out with a fix very quickly. Now just use alpha6:

dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115