Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Getting Started with Android Creating the Fun Facts Project

Gradle Errors

After creating the Fun Facts project, I get a number of error messages before doing anything. At the top of the window I see "Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly." At the bottom I see "Gradle 'FunFacts' project refresh failed Error:Cause: org.objectweb.asm.ClassReader.getMaxStringLength()I"

I am new to all of this and I've looked on Google for solutions. However, nothing has worked yet. Any advice would be greatly appreciated.

5 Answers

Hello,

I have never encountered this problem myself, but according to the stackoverflow post here you might be able to fix this by uninstalling your current version of the JDK and update to most recent version available on Oracle's site. Please let me know if this helps, if not, we can try other troubleshooting methods.

Thank you for your response, but unfortunately this didn't work for me.

So that I'm on the same page, what version of Android Studio and the JDK are you running? Also, could you provide both of your build.gradle files(the app and module versions)?

I am running Android Studio 0.8.2 and jdk1.8.0_45.

The build.gradle file in the app folder looks like this:

apply plugin: 'com.android.application'

android { compileSdkVersion 19 buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.everiosofsky.funfacts"
    minSdkVersion 14
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }

There's nothing in the other build.gradle file.

I'm not sure if this will help, but I would recommend updating to the latest version of Android Studio. The version you are using is a beta version and did have issues associated with it. I'm also not sure if that version of Android Studio supported Java 8. You can obtain the most recent version of Android Studio here.

Unfortunately I get the same error in the latest version of Android Studio.

I'd recommend trying to delete your .gradle folder(located in C:\Users<Your User>.gradle on Windows and ~/.gradle on Linux) and letting Android Studio recreate it. I'm not sure what's wrong at the moment, so trying to clear out things that could have been left by the older version. Also, I'm double checking, but the build.gradle file in the root of your project was completely empty? That seems a bit odd to me. The project files for the start of this lesson have what I find to be normal content(which also includes what gradle plugin to use). If your project is a completely fresh one. I'd also recommend trying to create it again.

I've deleted the .gradle folder and created a new project in the latest version of Android Studio. Still no luck. The build.gradle files in the new project are not empty, however. Here is the new build.gradle in the app folder:

apply plugin: 'com.android.application'

android { compileSdkVersion 19 buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example.everiosofsky.funfacts"
    minSdkVersion 14
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }

And here is the other build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects { repositories { jcenter() } }

I just want to verify that the error message is still the same and hasn't changed at all?

I am getting the same error, only with more detail now. At the bottom under "Failed to sync Gradle project 'Fun Facts'" I see:

Error:Unable to find method 'org.objectweb.asm.ClassReader.getMaxStringLength()I'. Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) <a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. <a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Hello,

I'm only finding one more thing that might help in this case. Its from the stackoverflow post here. It says to update the JDK location information located at File, Project Structure, SDK Location. I'll keep looking when I can, but I'm not seeing much else on this error.

Both the Android SDK path and the JDK path seem to be correct, so that's not the issue. Thank you for trying to help though!