j2emanue
j2emanue

Reputation: 62519

groovy error - cannot find matching method - how to solve

I have a simple activity in android but it could be any class. anyway it looks like this:

package com.example.groovy
import android.os.Bundle
import android.support.v7.app.ActionBarActivity
import com.example.R
import groovy.transform.CompileStatic

@CompileStatic
public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    myMethod();
    }




    public void myMethod(){

        Data data1=new Data();


        data1.setAddress("37 IBM blvd.");
        data1.setPostalCode("mc42L8")
        data1.setDate("feb 19");

        Data data2=new Data();
        data2.setAddress("38 Oriole");
        data2.setPostalCode("mc72l9")
        data2.setDate("feb 12");

        Data data3=new Data();
        data3.setAddress("37 skyway");
        data3.setPostalCode("mt82l9");
        data3.setDate("feb 13");
}

The Data class looks like this:

package com.example.groovy

public class Data{
    def String address
    def String postalCode
    def String Date
}

if you need to know the directory structure it looks like this:

enter image description here here is the error i get when i try to run the program:

    /Users/frost/Documents/myandroidstudio/myrxJavaAndroidProject2/app/src/main/groovy/com/example/groovy/MainActivity.groovy: 32: [Static type checking] - 
Cannot find matching method com.example.groovy.Data#setDate(java.lang.String). 

Please check if the declared type is right and if the method exists.

this error repeats for all the synthesized methods im trying to access from the data pojo.

Upvotes: 1

Views: 10060

Answers (1)

tim_yates
tim_yates

Reputation: 171054

Have you tried with sensible capitalisation, and without unnecessary defs?

public class Data{
    String address
    String postalCode
    String date
}

Upvotes: 3

Related Questions