0

Sorry for my ignorance as I am very new to Java and Android app design. I am using Android Studio along with an imported library of functions (RobotRaconteur) to design an application to connect and send a message / data to a Tcp service running on my PC -- all local connections.

The trouble is I cannot get Android Studio to recognize any of my "mathq" scripts (another set of scripts I created) or any of their functions within.

**************I believe the error lies within improperly importing or directory placement of these files... **************************

These mathq functions allow the android app to call a function as if it was built into the app -- even thought the function and processing, or in this case the adding of two numbers sent from the application, is done on the actual service on my PC.

PICTURE OF COMPILATION ERROR AND PROJECT DIRECTORY: http://tinypic.com/r/2k4i1e/8

Thanks in advance :)

package com.example.michael.smartbutton;

import com.robotraconteur.*;
import com.example.michael.smartbutton.mathq.*;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;       //view is any type of widget
import android.widget.Button;
import android.widget.TextView;
//import com.example.michael.smartbutton.example.math.*;
//import com.example.michael.example.math.*;



public class MainActivity extends ActionBarActivity {

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

        Button mikesButton = (Button)findViewById(R.id.mikesButton); //typecast to Button -- we called them the same thing as the ID in XML

        mikesButton.setOnClickListener(         //Beginning of CLick event listener
                new Button.OnClickListener() {      //Interface for our Callback method
                    public void onClick(View v){    //callback method
                        TextView mikesText = (TextView)findViewById(R.id.mikesText);
                        mikesText.setText("Short click sent");

                        //////BEGGINING OF ROBOT RACONTEUR

                        //Create and register a TcpTransport
                        TcpTransport t=new TcpTransport();          //from java sample
                        RobotRaconteurNode.s().registerTransport(t);    //from java sample

                        //Register the Create_interface service type
                        RobotRaconteurNode.s().registerServiceType(new mathqFactory());



                        MathSolver m = (MathSolver)RobotRaconteurNode.s().connectService("tcp://199.172.0.129:1234/example.math/MathSolver",null,null,null,"example.math.MathSolver");

                        m.add(10,11);

                        //Connect to the service
                        // Create c=(Create)RobotRaconteurNode.s().connectService("tcp://localhost:2354/{0}/Create",null,null,null,"experimental.create.Create");                            



                        //FROM JAVA DOC
                        //Shutdown the node.  This must be called or the program won't exit.
                        RobotRaconteurNode.s().shutdown();
                    }
                }

        );

        mikesButton.setOnLongClickListener(
                new Button.OnLongClickListener(){
                    public boolean onLongClick(View v){
                        TextView mikesText = (TextView)findViewById(R.id.mikesText);
                        mikesText.setText("that was a long one!");
                        return true; //you need to tell android you handled this click. then onClick listener can go to sleep for now
                    }
                }
        );       //Finger is on button for > a second
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
  • [Note you must click the "zoom" button at the image link or disable adblock and refresh to view image :) – MonsterVette Jul 01 '15 at 03:23
  • I don't see a package declaration on top of your java program? can you share your manifest file for cross verification? – Dickens A S Jul 01 '15 at 03:31
  • If you have compiled your mathq as JAR files and you want to import those to your android app then please refer http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio and http://stackoverflow.com/questions/24149690/add-local-library-project-as-a-dependency-to-multiple-projects-in-android-studio – Dickens A S Jul 01 '15 at 03:33
  • Thank you for the help Zigma!! I actually just solved it working with another programmer at my desk. The issue was that the automatically generated files had a package statement of package filename; For this to be correct these files needed to be in the Java folder above the directories with MainActivity. Fixed all of the mentioned errors! (Directory issue) – MonsterVette Jul 01 '15 at 04:49

0 Answers0