Android Studio 0.2.0 update … encountering issues with both new AND existing projects.

I’m fortunate that  using the latest and (sometimes not so) greatest is actually my job. With that I’ve been able to heavily use Android Studio ever since it was first released. To my knowledge, I’ve installed and heavily used every public update since the release.

Everyone of those updates went pretty smooth … until this one.

The switch to Android Studio 0.2.0 has, by far, been the bumpiest upgrade yet. After installing it…

  • I can’t generate new projects
  • I can’t build existing projects.

Not much I can get done without being able to do one or the other. 🙂

The good news is that resolving these issues was pretty easy.

Can’t generate new projects

This issue appears to be specific to folks using Android Studio on Windows.

I initially let Android Studio handle the install as I had always done previously. Once the install completed, any attempt to create a new project resulted in the following error…

CantGenProjectBadDependencyMSg

Basically, the message indicates that Android Studio can’t find a dependency.

The solution turned out to be that a fresh install is requried ….

  1. I exited all instances of Android Studio
  2. I changed the name of the existing installation folder
    • The default installation folder is
      C:\Users\[user name]\AppData\Local\Android\android-studio
  3. I then downloaded and installed the latest Android Studio installer

And that took care of the problem

Can’t build existing projects

This turned out to be a two-fold problem for me.

The first issue has to do with a fairly well documented change that’s been made to Android Studio. They’ve changed to a new version of Gradle that’s not backward compatible. As a result an attempt to build a project that was created with a prior version of Android Studio shows the following error.

GradleBuildIssue

The fix is to change the version of Gradle that’s referenced in your project’s build.gradle file (located in top-level of project folder). If you click on the “Search in build.gradle files” link in the above dialog it’ll open the build.gradle file for you. Or you can just open the build.gradle file yourself. It’s quite small and easy to navigate.

To fix the problem simply change the line that reads

classpath ‘com.android.tools.build:gradle:0.4

to

classpath ‘com.android.tools.build:gradle:0.5.+’

This will cause Android Studio to use the required version of Gradle.

But trouble continues…

With that fix made, I would then get an error indicating

FAILURE:Could not determine which tasks to execute

The problem is related to extraneous entries that were added to the [ProjectName].iml file (in your project’s top-level folder) by earlier versions of Android Studio.

To fix the problem, exit Android Studio and open the [ProjectName].iml file in an editor and delete the entire component element with the name “FacetManager”.

This changes the file from…

<?xml version="1.0" encoding="UTF-8"?>
<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
  <!-- *** Remove From here *** -->
  <component name="FacetManager">
    <facet type="android-gradle" name="Android-Gradle">
      <configuration>
        <option name="GRADLE_PROJECT_PATH" value=":" />
      </configuration>
    </facet>
  </component>
  <!-- ***  To Here   *** -->
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/.gradle" />
      <excludeFolder url="file://$MODULE_DIR$/build" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

to

<?xml version="1.0" encoding="UTF-8"?>
<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/.gradle" />
      <excludeFolder url="file://$MODULE_DIR$/build" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

And with that … SUCCESS!!  … I’m now able to build the project without difficulty.

Wrap Up

So the cleanup isn’t too difficult but does require some work. If you’re encountering issues other than those I’ve mentioned above the Android Studio folks have posted a couple of helpful pages addressing a variety of issues

To Learn more about Android programming, checkout Jim’s courses at Pluralsight.

PSAndroid_216x155

Posted by hedgehogjim

30+ years as a professional software dev, 17+ years developing mobile solutions, Pluralsight Author, Founder JWHH, LLC

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s