Realm.io / Dagger / Databinding in the same project - android

I am having issues with compiling my project after I added Realm.io as a dependency via gradle. The generated files created by dagger and databinding can not be found. If I remove realm.io the app compiles correctly.
Here is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
multiDexEnabled true
applicationId "com.foo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.facebook.stetho:stetho:1.2.0'
compile 'com.facebook.stetho:stetho-okhttp:1.2.0'
compile 'io.reactivex:rxandroid:0.24.0'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okio:okio:1.4.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:design:23.1.0'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'io.realm:realm-android:0.85.1'
compile 'com.google.dagger:dagger:2.0.1'
provided 'javax.annotation:jsr250-api:1.0'
apt "com.google.dagger:dagger-compiler:2.0.1"
apt 'com.android.databinding:compiler:1.0-rc4'
}
I see that Realm is also generating files and maybe the compilers are not playing nice together. Any ideas on how to get this working?
Thanks

I see that you also received the error:
No setter found for field goalInfo
Make sure the field names are the same as the getters and setters. Do not prepend "m" to the field names. Example:
#RealmClass
public Goal extends RealmObject {
//private String mGoalInfo;
private String goalInfo;
public String getGoalInfo() {
return goalInfo;
}
public void setGoalInfo(String goalInfo) {
this.goalInfo = goalInfo;
}
}

Databinding works with RealmObjects, but you have to implement Observable.
public class Post extends RealmObject implements Observable {
#PrimaryKey
private long id;
private String text;
#Ignore
private transient PropertyChangeRegistry mCallbacks;
#Bindable
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
if(!isValid()) { // !isManaged() in Realm 2.0
notifyPropertyChanged(BR.id);
}
}
#Bindable
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
if(!isValid()) { // !isManaged() in Realm 2.0
notifyPropertyChanged(BR.text);
}
}
#Override
public synchronized void addOnPropertyChangedCallback(OnPropertyChangedCallback callback) {
if (mCallbacks == null) {
mCallbacks = new PropertyChangeRegistry();
}
mCallbacks.add(callback);
}
#Override
public synchronized void removeOnPropertyChangedCallback(OnPropertyChangedCallback callback) {
if (mCallbacks != null) {
mCallbacks.remove(callback);
}
}
/**
* Notifies listeners that all properties of this instance have changed.
*/
public synchronized void notifyChange() {
if (mCallbacks != null) {
mCallbacks.notifyCallbacks(this, 0, null);
}
}
/**
* Notifies listeners that a specific property has changed. The getter for the property
* that changes should be marked with {#link Bindable} to generate a field in
* <code>BR</code> to be used as <code>fieldId</code>.
*
* #param fieldId The generated BR id for the Bindable field.
*/
public void notifyPropertyChanged(int fieldId) {
if (mCallbacks != null) {
mCallbacks.notifyCallbacks(this, fieldId, null);
}
}
}
And Dagger + Databinding can break each other, for which you need to add
apt 'com.google.guava:guava:19.0' // dagger + databind workaround

Realm, Dagger2 and Databinding are all working in my project.
The difference is:
I'm using android gradle plugin 1.5.0 and enable databinding by following configuration.
android {
...
dataBinding {
enabled = true
}
...
}
And I don't have
apt 'com.android.databinding:compiler:1.0-rc4'
in dependencies.
Whole working project is here: https://github.com/zaki50/realm_template

It is now possible to implement the RealmModel interface and add an annotation #RealmClass to the class instead of extending RealmObject. This lets you extends BaseObservable however it is still not working.
You get a databinding error: package mypackage.databinding does not exist
See this issue on github: https://github.com/realm/realm-java/issues/2716

Related

I got error message when I try put some data inside room database

I created simple offline database using room but I got this error
Caused by: java.lang.RuntimeException: cannot find implementation for
com.test.test.AppDatabase.SplashScreenActivity_AppDatabase_Impl does
not exist
Code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
AppDatabase appDatabase = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "testDatabase").build();
Categories category = new Categories();
category.setId(0);
category.setId(1);
category.setCategoryName("Te");
category.setCategoryName("Test");
appDatabase.categoriesDao().insertAll(category);
}
#Entity
class Categories {
#PrimaryKey
int id;
#ColumnInfo(name = "category_name")
String categoryName;
void setId(int id) {
this.id = id;
}
void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
}
#Dao
public interface CategoriesDao {
#Insert
void insertAll(Categories... categories);
}
#Database(entities = {Categories.class}, version = 1)
abstract class AppDatabase extends RoomDatabase {
abstract CategoriesDao categoriesDao();
}
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.**********"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Material Design
implementation 'com.google.android.material:material:1.2.0-alpha01'
//Butter Knife
implementation 'com.jakewharton:butterknife:10.2.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
//Volley
implementation 'com.android.volley:volley:1.1.1'
//Room
implementation "androidx.room:room-runtime:2.2.0"
}
apply plugin: 'com.jakewharton.butterknife'
I found many solutions on this website but all not working with me, Thank you.
First of all you have add annotationProcessor in your build.gradle file
annotationProcessor "androidx.room:room-compiler:2.2.0"
Either make your AppDatabase class static inside SplashScreenActivity like:
#Database(entities = {Categories.class}, version = 1)
abstract static class AppDatabase extends RoomDatabase {
abstract CategoriesDao categoriesDao();
}
Or Create separate file for AppDatabase rather than inner class

Greenrobot Android Eventbus - No option eventbusindex passed to annotation processor

I'm trying to set up a simple subscriber in my Android application using Greenrobot's Eventbus, but I am getting a gradle build error. I have shown my code below.
Event class
public final class OffersProcessedEvent {}
Base Fragment
public class BaseFragment extends Fragment {
private boolean registered;
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
EventBus.getDefault().register(this);
registered = true;
}
#Override
public void onResume() {
super.onResume();
if (!registered) {
EventBus.getDefault().register(this);
registered = true;
}
}
#Override
public void onPause() {
super.onPause();
EventBus.getDefault().unregister(this);
registered = false;
}
public AppCompatActivity getAppCompatActivity() {
return (AppCompatActivity) getActivity();
}
}
Event post'
EventBus.getDefault().post(new OffersProcessedEvent());
Subscribe code
#Subscribe
public void onMessageEvent(OffersProcessedEvent event){
*do whatever*
}
The following are my errors
Build Gradle Errors
Error:No option eventBusIndex passed to annotation processor
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Gradle dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.jakewharton:butterknife:8.6.0'
compile 'com.jakewharton:butterknife-compiler:8.6.0'
compile 'com.jakewharton:butterknife:8.7.0'
compile 'com.jakewharton:butterknife-compiler:8.7.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'org.greenrobot:eventbus-annotation-processor:3.0.1'
}
apply plugin: 'kotlin-kapt' // ensure kapt plugin is applied
dependencies {
implementation 'org.greenrobot:eventbus:3.1.1'
kapt 'org.greenrobot:eventbus-annotation-processor:3.1.1'
}
kapt {
arguments {
arg('eventBusIndex', 'com.example.myapp.MyEventBusIndex')
}
}
Base on this link http://greenrobot.org/eventbus/documentation/faq/
This happens when you set up the build script, and you did not add any
annotations to your code yet. Without any #Subscribe annotations,
annotation processor for indexing will not be triggered to consume the
‘eventBusIndex’ option. So, just add some #Subscribe annotations and
you should be fine.
So you must add
#Subscribe
fun onEvent(event: SomeEvent) {
}
But is you steel getting Error:No option eventBusIndex passed to annotation processor
Add this to your app.gradle
If using annotationProcessor
defaultConfig {
//other code
javaCompileOptions {
annotationProcessorOptions {
arguments = [eventBusIndex: "com.example.myapp.MyEventBusIndex"]
}
}
}
If using kapt
dependencies {
//other codes
}
kapt {
arguments {
arg('eventBusIndex', 'com.example.myapp.MyEventBusIndex')
}
}
And if using android-apt
dependencies {
//other codes
}
apt {
arguments {
eventBusIndex "com.example.myapp.MyEventBusIndex"
}
}
And this file will be generate by EventBus
/** This class is generated by EventBus, do not edit. */
public class MyEventBusIndex implements SubscriberInfoIndex {
private static final Map<Class<?>, SubscriberInfo> SUBSCRIBER_INDEX;
static {
SUBSCRIBER_INDEX = new HashMap<Class<?>, SubscriberInfo>();
putIndex(new SimpleSubscriberInfo(MainActivity.class, true, new SubscriberMethodInfo[] {
new SubscriberMethodInfo("onBleClick", com.example.myapp.Events.BleClickListener.class),
}));
}
private static void putIndex(SubscriberInfo info) {
SUBSCRIBER_INDEX.put(info.getSubscriberClass(), info);
}
#Override
public SubscriberInfo getSubscriberInfo(Class<?> subscriberClass) {
SubscriberInfo info = SUBSCRIBER_INDEX.get(subscriberClass);
if (info != null) {
return info;
} else {
return null;
}
}
}
Hope it's help

Firebase is firing a database leak

I added firebase inside my app to get some special events like when users open and close their app.
The problem is that every time I launch the app, it crashes right away. It started to happen when I added firebase and when I comment my Firebase code, it's working again, so now I'm pretty sure it's a problem with firebase.
The problem seems to be happening when the onForeground() is called. I tried to put it on a new Thread or call it in a Handler but it keeps crashing...
Here is the stack:
10-28 16:46:26.106 27724-27732/com.package.custom E/System: Uncaught exception thrown by finalizer
10-28 16:46:26.107 27724-27732/com.package.custom E/System: java.lang.IllegalStateException: The database '/data/user/0/com.package.custom/databases/google_app_measurement_local.db' is not open.
at android.database.sqlite.SQLiteDatabase.throwIfNotOpenLocked(SQLiteDatabase.java:2169)
at android.database.sqlite.SQLiteDatabase.createSession(SQLiteDatabase.java:365)
at android.database.sqlite.SQLiteDatabase$1.initialValue(SQLiteDatabase.java:84)
at android.database.sqlite.SQLiteDatabase$1.initialValue(SQLiteDatabase.java:83)
at java.lang.ThreadLocal$Values.getAfterMiss(ThreadLocal.java:430)
at java.lang.ThreadLocal.get(ThreadLocal.java:65)
at android.database.sqlite.SQLiteDatabase.getThreadSession(SQLiteDatabase.java:359)
at android.database.sqlite.SQLiteProgram.getSession(SQLiteProgram.java:101)
at android.database.sqlite.SQLiteQuery.setLastStmt(SQLiteQuery.java:96)
at android.database.sqlite.SQLiteQuery.close(SQLiteQuery.java:111)
at android.database.sqlite.SQLiteCursor.close(SQLiteCursor.java:300)
at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:366)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:202)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185)
at java.lang.Thread.run(Thread.java:818)
Here is a part of my AnalyticsHelper class:
public class AnalyticsHelper
{
//...
/**
* Hook called when the app switch to foreground mode
*/
public static void onForeground()
{
Log.d(TAG, "FOREGROUND");
Bundle bundle = new Bundle();
bundle.putString(KEY_TYPE, AnalyticsCategories.CATEGORY_LIFECYCLE_ACTION_FOREGROUND);
CustomApplication.getAnalytics().logEvent(AnalyticsCategories.CATEGORY_LIFECYCLE, bundle);
}
//...
}
Here is the call of the AnalyticsHelper in the activity:
public class MainActivity extends AppCompatActivity
{
#Override
protected void onResume()
{
super.onResume();
//...
AnalyticsHelper.onForeground();
}
}
And here is the part of the custom Application class:
public class CustomApplication extends Application
{
private static final String TAG = "CustomApplication";
private static CustomApplication sApplication;
public static CustomApplication get()
{
return sApplication;
}
public static FirebaseAnalytics getAnalytics()
{
return get().getFirebaseAnalytics();
}
#Override
public void onCreate()
{
super.onCreate();
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
sApplication = this;
}
/**
* Gets the default {#link Tracker} for this {#link Application}.
*
* #return tracker
*/
public FirebaseAnalytics getFirebaseAnalytics()
{
if (mFirebaseAnalytics == null)
{
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
}
return mFirebaseAnalytics;
}
}
I searched all the afternoon and nothing came out, please help..
Edit #1 (build.gradle):
apply plugin: 'com.android.application'
android {
signingConfigs {
release {
keyAlias '##########'
keyPassword '##########'
storeFile file('##########')
storePassword '##########'
}
}
compileSdkVersion 25
buildToolsVersion '24.0.2'
defaultConfig {
applicationId "com.custom.app"
minSdkVersion 18
targetSdkVersion 25
android.applicationVariants.all { variant ->
def versionPropsFile = file('src/main/res/raw/version.properties')
if (versionPropsFile.canRead())
{
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def code = versionProps['code'].toInteger() + 1
versionProps['code'] = code.toString()
def version = versionProps['version']
versionProps.store(versionPropsFile.newWriter(), null)
versionCode code
versionName version
}
else
{
throw new GradleScriptException('Cant access version.properties');
}
}
signingConfig signingConfigs.release
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "EXPORT_EXTERNAL_STORAGE", "true"
}
debug {
debuggable true
buildConfigField "boolean", "EXPORT_EXTERNAL_STORAGE", "true"
}
}
productFlavors {
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/commons-net-3.3.jar')
//Debug
compile files('libs/commons-lang3-3.5.jar')
compile files('libs/joda-time-2.9.5.jar')
compile project(':android-ble-module')
debugCompile project(path: ':android-log-module', configuration: 'debug')
releaseCompile project(path: ':android-log-module', configuration: 'release')
compile project(':android-location-module')
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:preference-v14:25.0.0'
compile 'com.google.android.gms:play-services-gcm:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.android.gms:play-services-identity:9.8.0'
compile 'com.google.firebase:firebase-analytics:9.8.0'
}
apply plugin: 'com.google.gms.google-services'
Please move to latest version of firebase SDK. Firebase solved this memory leak issue in their updated sdk. In this case replace this line
compile 'com.google.firebase:firebase-analytics:9.8.0'
with below line.
compile 'com.google.firebase:firebase-analytics:11.0.1'

Dagger2 do not generate Dagger* classes

Dagger2 does not create classes Dagger*. I created the interface IDaggerTestModule, but the class DaggerIDaggerTestModule not created! All libraries have. Maybe "apt" is not triggered???
my test project: https://github.com/gc986/Dagger2Test
MyConfig:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta2'
classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.netelement.gc986.mpos_android"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_8
}*/
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.0'
testCompile 'junit:junit:4.12'
compile 'io.reactivex:rxjava:1.1.9'
// Retrofit
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
// Dagger
compile 'com.google.dagger:dagger:2.0'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
// Butterknife
compile 'com.jakewharton:butterknife:8.3.0'
apt 'com.jakewharton:butterknife-compiler:8.3.0'
}
User.java
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
DaggerUser.java
#Module
public class DaggerUser {
#Provides
public User provideUser(){
User user = new User();
user.setFirstName("name1");
user.setLastName("name2");
return user;
}
}
IDaggerFactory.java
#Singleton
#Component (
modules = {DaggerUser.class}
)
public interface IDaggerFactory {
void inject();
User user();
}
This not create...
public class DaggerApplication extends Application {
IDaggerFactory component;
public static IDaggerFactory component(Context context){
return ((DaggerApplication) context.getApplicationContext()).component;
}
#Override
public void onCreate(){
super.onCreate();
component = -->DaggerIDaggerFactory<--
.builder()
.daggerUser(new DaggerUser())
.build();
}
}
That's because this method in your component interface doesn't actually do anything. Remove it.
void inject();
EDIT:
Okay, just got home from vacation. So first thing, removing void inject() fixes the following error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.lang.IllegalArgumentException: not a valid component method: inject()
After that, it says "Cannot find symbol" in DaggerApplication because it hasn't been imported yet, so I added the import
import com.gc986.dagger2test.di.DaggerIDaggerFactory;
And then it compiled successfully
So in reality, you forgot to import the newly generated DaggerIDaggerFactory class in your Java file

Groovy in Android - how to run Hello world

I'm having trouble referencing a groovy class i've created. Here are the steps:
my build.gradle file has all required dependencies:
apply plugin: 'com.android.application'
apply plugin: 'groovyx.grooid.groovy-android'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
packagingOptions {
// workaround for http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/groovy-release-info.properties'
}
defaultConfig {
applicationId "com.example.uen.myrxjavaandroidproject"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.netflix.rxjava:rxjava-android:0.20.7'
compile 'com.squareup:otto:1.3.5'
compile 'org.codehaus.groovy:groovy:2.4.3:grooid'
}
And gradle is synched successfully.
then i created a folder under main called 'groovy' such that my project structure looks like the following:
notice i have a groovy class called "Hello", it looks like this:
public class Hello {
String name;
public void sayHello() {
System.out.println("Hello "+getName()+"!");
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
now in my MainActivity.java class i try to instantiate Hello class but its not being recognized. I am doing this:
Hello myHello = new Hello();
what am i doing wrong ?
If you want to use a Groovy class from your Java sources, then your Java file must be found in the "groovy" directory. It's done this way to enforce joint compilation (Java classes consuming Groovy classes or the other way).
And independently of this, for the sake of Grooviness, your Hello Groovy class can be reduced to:
class Hello {
String name
void sayHello() {
println "Hello $name!"
}
}

Categories

Resources