Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hello,
Recently, I had a Java app made with the PTC Java SDK (JAVA-SDK-6-2-0-220). I used the SimpleClient provided by PTC, and I successed to interract with the server.
Later I move this code to an Android App, with the same PTC Java SDK, and I can't connect. Here are the versions i tried :
Version Android : API 30: Android 11
Version Java JDK (from Android Studio) : 11.0.8
Version SDK PTC Thingworx : JAVA-SDK-6-2-0-220
result : failure
Version d'Android : API 29: Android 10
Version Java JDK (from Android Studio) : 11.0.8
Version SDK PTC Thingworx : JAVA-SDK-6-2-0-220
result : failure
The exact same code is working well on Java with Eclipse (still same ptc java sdk)
Here are the authorization i requierd. I don't prompt the user to accept it, as i think the 3 first doesn't require user aprobation. The 2 I'm not even sure I need them.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
// To fix EACCES error (this had not fixed the issue)
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Here is my code (simplified)
The trace is in the file attached.
public class SimpleClient extends ConnectedThingClient {
private static final Logger LOG = LoggerFactory.getLogger(SimpleClient.class);
private static String ThingName = "AndroidTestThing";
public SimpleClient(ClientConfigurator config) throws Exception {
super(config);
}
public static void notifyServer() {
ClientConfigurator config = new ClientConfigurator();
config.setUri("wss://xxxxxxxxxxxxxxxx:443/Thingworx/WS");
config.setAppKey("xxxxxxxxxxxxxxxxxxxxxxxxxx");
config.ignoreSSLErrors(true);
try {
SimpleClient client = new SimpleClient(config);
client.start();
// Wait for the client to connect.
if (client.waitForConnection(30000)) {
LOG.info("The client is now connected.");
} else {
LOG.warn("Client did not connect within 30 seconds. Exiting");
}
client.shutdown();
} catch (Exception e) {
LOG.error("An exception occurred while initializing the client", e);
} finally {
LOG.info("SimpleClient is done. Exiting");
}
}
}
Edit : I tried with this settings, and the setAppKey method is not referenced.
Version d'Android : API 29: Android 10
Version Java JDK (from Android Studio) : 11.0.8
Version SDK PTC Thingworx : JAVA-SDK-7-0-0-1485 (from https://developer.thingworx.com/en/sdks)
**Résultat : methode .setAppKey unknown**
Hi @NB_9778056.
For troubleshooting:
Also, did you check the Android examples provided with the JAVA-SDK-7-0-0-1485 version that you last downloaded?
Regards.
--Sharon