Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Using OPC UA Java SDK for Android
June 14, 2017
20:30, EEST
Avatar
EduardoULPGC
New Member
Members
Forum Posts: 1
Member Since:
June 14, 2017
sp_UserOfflineSmall Offline

Hello!

I am currently using the Prosys OPC Ua Java SDK to develop an Android App as part of a study about industrial communications for my bachelor thesis.
I am having some troubles while trying to implement in Android using Android Studio.
For this test I used the Java code “SimpleClient” provided in the “sample” folder from the OPC UA Java SDK. I didn’t do much more than copy-pasting the code in this Android project while so little changes. Apparently the problem lays in the App identity creation process:
-If I use the: “identity.setApplicationDescription(appDescription)” method in the same way the code from the “SimpleClient” does, I get an exception that makes my code crash.
-If I do not use this method (I create the identity, but leave it empty) I got a crash whit an unknown exception.
This is my code:

protected void sendMessage(View view)throws Exception{

BasicConfigurator.configure(); //I had to add it if not, It crashes

UaClient client;
//Just some text to see something in the phone
EditText edit_message = (EditText) findViewById(R.id.edit_message);
edit_message.setText(“Creado cliente”);

client = new UaClient(“opc.tcp://192.168.43.214:51210/OPCUA/SampleServer”);

edit_message.setText(“Se añade IP”);

client.setSecurityMode(SecurityMode.NONE);

initialize(client);

//Here is when it crashes
try {
client.connect();
}
catch (ServerConnectionException a){
edit_message.setText(“ServerConnectionException”);
}
catch (ServiceException b){
edit_message.setText(“ServiceException”);

}
catch (Exception c){
String a;
edit_message.setText(c.getMessage());

}
// String valorString = valor.toString();
// EditText edit_message = (EditText) findViewById(R.id.edit_message);
//edit_message.setText(valorString);
// cliente.disconnect();
}

protected static void initialize(UaClient cliente)
throws SecureIdentityException,IOException,UnknownHostException{
ApplicationDescription appDescription = new ApplicationDescription();
appDescription.setApplicationName(new LocalizedText(“myfirstapp”, Locale.ENGLISH));
// ‘localhost’ (all lower case) in the URI is converted to the actual
// host name of the computer in which the application is run
appDescription.setApplicationUri(“urn:localhost:UA:myfirstapp”);
appDescription.setProductUri(“urn:prosysopc.com:UA:myfirstapp”);
appDescription.setApplicationType(ApplicationType.Client);

final ApplicationIdentity identity;
identity=new ApplicationIdentity();

//identity.setApplicationDescription(appDescription);
cliente.setApplicationIdentity(identity);

}

June 15, 2017
14:02, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Please, check the original blog post, which explains the basic settings for Android projects. Although the article is a bit outdated, the basic setups should still be valid.

If you still experience problems, it helps, if you can explain the problem a bit in more detail, except that it just “crashes”. For example, you could print out the exceptions that you get to help identifying what exactly goes wrong.

July 17, 2017
12:57, EEST
Avatar
enzo.oestanto
Member
Members
Forum Posts: 3
Member Since:
July 17, 2017
sp_UserOfflineSmall Offline

Hello,
I also have the same problem here, i also tried the “SimpleClient” with some modifications to make it run in android studio. for me, the problem starts at “client = new UaClient(“opc.tcp://192.168.43.214:51210/OPCUA/SampleServer”);” it crashes when this line of code is executed.

This is what i got in my android monitor.

07-17 11:54:20.593 4092-4100/? W/SQLiteConnectionPool: A SQLiteConnection object for database ‘/data/user/0/com.google.android.gms/databases/metrics.db.16’ was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
07-17 11:54:20.594 4092-4100/? W/SQLiteConnectionPool: A SQLiteConnection object for database ‘/data/user/0/com.google.android.gms/databases/help_responses.db.18’ was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
07-17 11:54:20.594 4092-4100/? W/SQLiteConnectionPool: A SQLiteConnection object for database ‘/data/user/0/com.google.android.gms/databases/auto_complete_suggestions.db’ was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
07-17 11:55:38.380 24450-28216/? I/LIA_SmartCare_ConnectionProxyHandler: open() : SmartCare opened.
07-17 11:55:38.380 24450-28216/? I/LIA_SmartCare_ConnectionProxyHandler: tryConnecting…
07-17 11:55:38.385 24450-28216/? I/LIA_SmartCare_ConnectionProxy: startService(com.lge.ia.task.smartcare) : Success
07-17 11:55:38.394 24450-28216/? I/LIA_SmartCare_ConnectionProxy: bindService(com.lge.ia.task.smartcare) : Success
07-17 11:55:38.409 24450-24450/? D/LIA_SmartCare_ConnectionProxy: onServiceConnected() : com.lge.ia.task.smartcare
07-17 11:55:38.409 24450-24450/? I/LIA_SmartCare_ConnectionProxy: Checking activation option of SmartCare
07-17 11:55:38.409 24450-24450/? I/LIA_SmartCare_ConnectionProxy: Task Property : SmartCare, true
07-17 11:55:38.409 24450-24450/? I/LIA_SmartCare_ConnectionProxy: Task activation property : SmartCare, true
07-17 11:55:38.409 24450-24450/? I/LIA_SmartCare_ConnectionProxyHandler: ConnectionProxyListener – onConnected :
07-17 11:55:38.409 24450-24450/? V/LIA_SmartCare_ConnectionProxyHandler: SmartCare Task Property: Activation:true, AutoExecution:false
07-17 11:55:38.409 24450-24450/? D/LIA_SmartCare_ConnectionProxy: getTaskConnector(SmartCare / com.lge.ia.task.smartcare) : Thread(1)
07-17 11:55:38.415 24450-24450/? I/LIA_SmartCare_ConnectionProxyHandler: setTaskConnectorIntoTask – Success
07-17 11:55:38.415 24450-24450/? I/LIA_SmartCare_ConnectionProxyHandler: stopTimeoutTimer
07-17 11:55:38.449 24450-24450/? D/LIA_SmartCare_ConnectionProxy: tryUnbindService(com.lge.ia.task.smartcare) – Thread(1)
07-17 11:55:38.450 24450-24450/? I/LIA_SmartCare_ConnectionProxyHandler: isContainAutoExecutionTask() : false, don’t contain AutoExecution and Activation
07-17 11:55:38.450 24450-24450/? D/LIA_SmartCare_ConnectionProxyHandler: close() : no AutoExecution and Activation task in remote service. Try to stop the service.
07-17 11:55:38.452 24450-24450/? D/LIA_SmartCare_ConnectionProxy: tryStopService(com.lge.ia.task.smartcare) : Fail – Thread(1)
07-17 11:55:38.452 24450-24450/? I/LIA_SmartCare_ConnectionProxyHandler: close() : SmartCare closed.

July 17, 2017
17:49, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Thanks for the report. As mentioned, we don’t unfortunately have an example for Android Studio available at the moment, but we will try to provide one in near future.

I guess the main issue with current Android development is to avoid any communication in the main UI thread and separate asynchronous tasks for that. Also, you will need to ensure that the application has access to the network, as mentioned in the original blog post (see above). These are basic Android development concepts that need to be taken care of according to the Android development guide lines. Nevertheless, we will be working on a new example and will let you know when that is available.

July 17, 2017
18:34, EEST
Avatar
enzo.oestanto
Member
Members
Forum Posts: 3
Member Since:
July 17, 2017
sp_UserOfflineSmall Offline

thank you for the reply

I downloaded the example in the blog and tried it in eclipse, and there are some errors.

these are the errors:
Description Resource Path Location Type
Project ‘OpcUaSampleAppForAndroid’ is missing required Java project: ‘com.prosysopc.ua’ OpcUaSampleAppForAndroid Build path Build Path Problem
Project ‘OpcUaSampleAppForAndroid’ is missing required Java project: ‘org.opcfoundation.ua’ OpcUaSampleAppForAndroid Build path Build Path Problem
The project cannot be built until build path errors are resolved OpcUaSampleAppForAndroid Unknown Java Problem

how to solve this problem? thank you

July 17, 2017
18:43, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Check the build path; remove the source references and add references to the respective libraries (SDK and Stack) that are found from the SDK/lib folder.

Also, make sure that you add all libraries to the Order&Export section as mentioned at the end of the article.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
23 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 685

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule, rashadbrownrigg, christi10l, ahamad1, Flores Frederick, ellenmoss

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1