Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

thingworx android error


thingworx android error

i am trying to run the sample code provided in the thingworx android sdk

I have a problem in every sample project

it says cant resolve the constructor

thing = new VirtualThing(thingName, "A basic virtual thing", client);

because the client is not initiialized


client.isConnected()  is also showing error

i dont know what 'client' is  because the variable is also not declared anywhere.

kindly tell the solution

Tags (2)

Accepted Solutions

Re: thingworx android error

Hi Dibya, it seems to me that your project is not correctly setup in studio, here's the blog you could use to correct it Exploring ThingWorx Android SDK together with web based Revision Control System and secured connecti...


Re: thingworx android error

Hi Dibya, it seems to me that your project is not correctly setup in studio, here's the blog you could use to correct it Exploring ThingWorx Android SDK together with web based Revision Control System and secured connecti...

Re: thingworx android error

Hi dibya ranjan mishra​,

Have you added the ThingWorx Android SDK jars to your project?

Re: thingworx android error

yes i have added. I just had to import the sample project in the android studio

Could you just run the exampleconnection project and check if it is working or not

Re: thingworx android error

From where have you downloaded this project? Could you share the link?

Re: thingworx android error

BTW are you executing this project on Win 10?

Re: thingworx android error

i got the android sdk from here and then trying to run the ExampleConnection project present in the samples folder of android sdk

Re: thingworx android error


actually i corrected that error

it was importing some AndroidConnectedThingClient

but I guess thingworx has changed it to ConnectedThingClient

because i extracted all the 2 jar files I could not find AndroidConnectedThingClient.class

Its better if you could see the sample codes and change it to ConncetedThingClient

Re: thingworx android error



import android.content.BroadcastReceiver;

import android.content.Context;

import android.content.Intent;

import android.content.IntentFilter;

import android.os.Bundle;

import android.os.Handler;

import android.os.HandlerThread;

import android.os.IBinder;

import android.os.Looper;

import android.os.Message;

import android.os.Process;


import android.util.Log;

<---------this is the error I am saying about-------------------------------->

import com.thingworx.communications.client.AndroidConnectedThingClient;


import com.thingworx.communications.client.things.VirtualThing;

public class ThingworxProcessService extends Service {

    public final String TAG = ThingworxProcessService.class.getName();

    private Looper mServiceLooper;

    private ServiceHandler serviceHandler;

    private AndroidConnectedThingClient client;

    private IntentServiceReceiver serviceReceiver;


    public void onCreate() {

        serviceReceiver = new IntentServiceReceiver();

        HandlerThread thread = new HandlerThread("ThingworxProcessService", Process.THREAD_PRIORITY_BACKGROUND);


        // Get the HandlerThread's Looper and use it for our Handler

        mServiceLooper = thread.getLooper();

        serviceHandler = new ServiceHandler(mServiceLooper);



    public int onStartCommand(Intent intent, int flags, int startId) {

        // For each start request, send a message to start a job and deliver the

        // start ID so we know which request we're stopping when we finish the job

        Message msg = serviceHandler.obtainMessage();


        msg.arg1 = startId;


        return START_STICKY;




    public IBinder onBind(Intent intent) {

        return null;



    public void onDestroy() {




    // Handler that receives messages from the thread

    private final class ServiceHandler extends Handler {

        public ServiceHandler(Looper looper) {




        public void handleMessage(Message msg) {

            Log.i(TAG, "handleMessage Start");

            try {

                IntentFilter intentFilter = new IntentFilter();


                registerReceiver(serviceReceiver, intentFilter);

                Bundle bundle = msg.getData();

                long pollingRate = bundle.getLong(Constants.POLLING_RATE_EXTRA, 1000l);

                boolean lastConnectionState = bundle.getBoolean(Constants.LAST_CONNECT_STATE_EXTRA);

                String stateObserver = bundle.getString(Constants.CONNECTION_OBSERVER);

                client = ThingworxService.client;

                boolean isConnected;

                while (client == null || !client.isShutdown()) {

                    if (client != null && client.isConnected()) {

                        isConnected = true;

                        for (VirtualThing thing : client.getThings().values()) {

                            try {


                                Log.v(TAG, "Scanning device");


                            } catch (Exception eProcessing) {

                                Log.e(TAG, "Error Processing Scan Request for [" + thing.getName() + "] : " + eProcessing.getMessage());



                        Intent scanned = new Intent();



                    } else {

                        isConnected = false;



                    if(isConnected != lastConnectionState){

                        if(stateObserver != null) {

                            Intent stateChange = new Intent();


                            stateChange.putExtra(Constants.CONNECTION_OBSERVER, stateObserver);


                            lastConnectionState = isConnected;





            } catch (InterruptedException e) {

                Log.e(TAG, "Polling thread exiting." + e.getMessage());


            // Stop the service using the startId, so that we don't stop

            // the service in the middle of handling another job


            Log.i(TAG, "handleMessage End");



    public class IntentServiceReceiver extends BroadcastReceiver {


        public void onReceive(Context context, Intent intent) {

            String action = intent.getAction();


                if(client != null && client.isConnected())

                    try {


                    } catch (Exception e) {

                        Log.e(TAG, "Error Shutting Down Client", e);







Re: thingworx android error

I apologize for my mistake

it was showing error in the beginning

but the real error was in gradle dependancies

then this thing works fine

I am extremely pleased with the way you have responded to my problem

Thank you so much.

Hope to get this support though out