Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » problems Android Studio with Paho.(problems in compile client mqtt with Paho. )
icon8.gif  problems Android Studio with Paho. [message #1748170] Sun, 20 November 2016 02:18 Go to next message
Sojue IsRem is currently offline Sojue IsRemFriend
Messages: 1
Registered: November 2016
Junior Member
I used the following repositories to use Paid in Android Studio:

repositories {
maven {
url "https://repo.eclipse.org/content/repositories/paho-releases/"
}
}


dependencies {
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude module: 'support-v4'
}
}


The sample code I used


String content = "Message from MqttPublishSample";
int qos = 2;
String broker = "tcp://iot.eclipse.org:1883";
String clientId = "JavaSample";
MemoryPersistence persistence = new MemoryPersistence();


try {
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
System.out.println("Connecting to broker: " + broker);
sampleClient.connect(connOpts);
System.out.println("Connected");
System.out.println("Publishing message: " + content);
MqttMessage message = new MqttMessage(content.getBytes());
message.setQos(qos);
sampleClient.publish(topic, message);
System.out.println("Message published");
sampleClient.disconnect();
System.out.println("Disconnected");
System.exit(0);
} catch (MqttException me) {
me.printStackTrace();
}


I do not know why I get errors when compiling?. HELP MY
  • Attachment: busque.png
    (Size: 70.93KB, Downloaded 172 times)
icon9.gif  Re: problems Android Studio with Paho. [message #1755005 is a reply to message #1748170] Sat, 25 February 2017 22:33 Go to previous message
Adrian Meier is currently offline Adrian MeierFriend
Messages: 1
Registered: February 2017
Junior Member
Interesting, this post is from November and no answer.

I also have those issue. But I think, when Build is successfully then this is no problem.

But I have next problem in AndroidStudio: After I inserted dependencies as description at https://eclipse.org/paho/clients/android/ my application crashed. ==> "java.lang.VerifyError: Verifier rejected class ch.mead.iotandroid.MainActivity due to bad method java.lang.Object"
 
  at java.lang.Class.newInstance(Native Method)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1090)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
  at android.app.ActivityThread.-wrap11(ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:5443)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)


It occurs on real device (android 4.1, android 6.0) and also in emulator. Do try invalidate and clean don't help.
repositories {
    maven {
        url "https://repo.eclipse.org/content/repositories/paho-snapshots/"
    }
}

dependencies {
    compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
    compile 'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
}


Its a simple application with small implementation.
package ch.mead.iotandroid;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
Previous Topic:Retrieve topic name from subscribe message
Next Topic:Thread-safe Paho C messageArrived callback
Goto Forum:
  


Current Time: Fri Apr 26 10:28:34 GMT 2024

Powered by FUDForum. Page generated in 0.02887 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top