ClassCastException. ...Symbol$ClassSymbol cannot be cast to javax.lang.model.element.PackageElement

147 views
Skip to first unread message

Jan Kulinski

unread,
Nov 25, 2014, 11:26:47 AM11/25/14
to realm...@googlegroups.com
Getting this Error as soon as I try to as I try to
 import io.realm.RealmObject;

Tested in a brand new Android project. Not sure what's going wrong. Attached screenshot and full stack trace.

Note: Stack tace mentions inability to find the method jcenter().  I've found jcenter() works just fine until any Realm classes are imported, and therefore compiled. 

Using Gradle 2.1, with 
'com.android.tools.build:gradle:0.13.2'


FAILURE: Build failed with an exception.
         
* Where:
Build file '/Users/Jan/Documents/DevTests/Quicky/build.gradle' line: 5
         
* What went wrong:
A problem occurred evaluating root project
'Quicky'.
> Could not find method jcenter() for arguments [] on repository container.
         
* Try:  
Run with --info or --debug option to get more log output.
         
* Exception is:
org
.gradle.api.GradleScriptException: A problem occurred evaluating root project 'Quicky'.
        at org
.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
        at org
.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:116)
        at org
.gradle.configuration.BuildScriptProcessor.execute(BuildScriptProcessor.java:36)
        at org
.gradle.configuration.BuildScriptProcessor.execute(BuildScriptProcessor.java:23)
        at org
.gradle.configuration.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org
.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        at org
.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:465)
        at org
.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:76)
        at org
.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
        at org
.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
        at org
.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
        at org
.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
        at org
.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
        at org
.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org
.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org
.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
        at org
.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org
.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
        at org
.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org
.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
        at org
.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
        at org
.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
        at org
.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
        at org
.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org
.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org
.gradle.launcher.Main.doAction(Main.java:48)
        at org
.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org
.gradle.launcher.Main.main(Main.java:39)
        at org
.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
        at org
.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
        at org
.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method jcenter() for arguments [] on repository container.
        at org
.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
        at org
.gradle.api.internal.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:56)
        at org
.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:172)
        at org
.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler_Decorated.invokeMethod(Unknown Source)
        at build_4odvc2ajr0j14ot4o334ic2rj7$_run_closure1_closure2
.doCall(/Users/Jan/Documents/DevTests/Quicky/build.gradle:5)
        at org
.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
        at org
.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
        at org
.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:113)
        at org
.gradle.api.internal.artifacts.DefaultArtifactRepositoryContainer.configure(DefaultArtifactRepositoryContainer.java:76)
        at org
.gradle.api.internal.artifacts.DefaultArtifactRepositoryContainer.configure(DefaultArtifactRepositoryContainer.java:44)
        at org
.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:50)
        at org
.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
        at org
.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:94)
        at org
.gradle.api.internal.initialization.AbstractScriptHandler.repositories(AbstractScriptHandler.java:66)
        at build_4odvc2ajr0j14ot4o334ic2rj7$_run_closure1
.doCall(/Users/Jan/Documents/DevTests/Quicky/build.gradle:4)
        at org
.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
        at org
.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:133)
        at org
.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:94)
        at org
.gradle.api.internal.project.AbstractProject.buildscript(AbstractProject.java:880)
        at org
.gradle.api.Project$buildscript.call(Unknown Source)
        at org
.gradle.api.internal.project.ProjectScript.buildscript(ProjectScript.groovy:42)
        at org
.gradle.api.Script$buildscript.callCurrent(Unknown Source)
        at build_4odvc2ajr0j14ot4o334ic2rj7
.run(/Users/Jan/Documents/DevTests/Quicky/build.gradle:3)
        at org
.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
       
... 30 more
         
         
BUILD FAILED


Any ideas?

Christian Melchior

unread,
Nov 25, 2014, 1:17:04 PM11/25/14
to Jan Kulinski, realm...@googlegroups.com
Hi Jan

It looks like your build.gradle isn't quite right. Most likely it is your repository definition that is wrong somehow. Can you post the content of both your top level and project build.gradle file.

--
Christian Melchior
Senior Android Developer


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/6f1381cc-b8d5-409f-aeb2-26b471d3d595%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:56976136-57#}

Jan Kulinski

unread,
Nov 25, 2014, 1:27:52 PM11/25/14
to realm...@googlegroups.com, jan.t.k...@gmail.com, he...@realm.io
Yup, here you go

Project: 
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "j.quicky"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'io.realm:realm-android:0.74.0'
}



// 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:0.13.2'

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

allprojects {
    repositories {
        jcenter()
    }
}

Christian Melchior

unread,
Nov 25, 2014, 1:40:04 PM11/25/14
to Jan Kulinski, realm...@googlegroups.com
Hmm, that seems to be all right.
Are you using Eclipse or Android Studio?
Because this SO answers seems to suggest there might be problems with Eclipse if not configured to use the Gradle wrapper?


--
Christian Melchior
Senior Android Developer


{#HS:56976136-57#}

Jan Kulinski

unread,
Nov 25, 2014, 2:11:41 PM11/25/14
to realm...@googlegroups.com, jan.t.k...@gmail.com, he...@realm.io
Using Android Studio 0.8.14.

Here's the wrapper props
#Tue Nov 25 14:07:24 EST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

...

Christian Melchior

unread,
Nov 26, 2014, 5:32:05 AM11/26/14
to Jan Kulinski, realm...@googlegroups.com
That is odd.

A few things to try out:

1)
Try upgrading your Android Studio to the 1.0.0 RC1, and set the build tools to

classpath 'com.android.tools.build:gradle:0.14.4'

which is the newest version.

2) Try running it from the commandline
> ./gradlew clean assemble

If that works, it is related to some setup inside Android Studio that is not correct

3) Try cleaning the .gradle dir, which contains the Gradle cache.

They are all longshots, but from your posted config it should work.


--
Christian Melchior
Senior Android Developer


{#HS:56976136-57#}

Jan Kulinski

unread,
Nov 26, 2014, 1:02:24 PM11/26/14
to realm...@googlegroups.com, jan.t.k...@gmail.com, he...@realm.io
Did all three. Also tried updating my Java SDK and re-downloaded the android SDK. Still get the same error. 

I don't know what else to try aide from reinstalling the computer's OS at this point, which feels a bit extreme.

Christian Melchior

unread,
Nov 26, 2014, 1:23:04 PM11/26/14
to Jan Kulinski, realm...@googlegroups.com
Installing the OS shouldn't be needed. Have you tried our examples, do they fail the same way?


--
Christian Melchior
Senior Android Developer


{#HS:56976136-57#}

Yolanda Septiana Dewi

unread,
Dec 23, 2014, 4:24:01 AM12/23/14
to realm...@googlegroups.com
Hei I'm getting this error too. Jan Kulinski, how did you manage to resolve this?

Yolanda Septiana Dewi

unread,
Dec 23, 2014, 5:41:57 AM12/23/14
to realm...@googlegroups.com
Hi, I resolved this. Basically you can't have nested class in your Realm models, even if it's static class.
Reply all
Reply to author
Forward
0 new messages