mirror of
https://github.com/eclipse/paho.mqtt.android.git
synced 2025-05-09 02:41:15 +08:00
Fixing Android Build situation. (#70)
Enabling Automatic Reconnect for Android client Also Adding Example code for a very basic pub sub app that uses Automatic Reconnect and offline buffering as well as a good example. Fixed Build on Hudson Added Build config for travis-ci Fixed SSL tests to work with new iot.eclipse.org Certificate Signed-off-by: James Sutton <james.sutton@uk.ibm.com>
This commit is contained in:
parent
bb810eae53
commit
77d6956ac1
17
.travis.yml
Normal file
17
.travis.yml
Normal file
@ -0,0 +1,17 @@
|
||||
language: android
|
||||
jdk: oraclejdk7
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- build-tools-23.0.2
|
||||
- android-23
|
||||
- extra-android-support
|
||||
- extra
|
||||
|
||||
before_script:
|
||||
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
|
||||
- emulator -avd test -no-audio -no-window &
|
||||
- android-wait-for-emulator
|
||||
- adb shell input keyevent 82 &
|
||||
|
||||
script: ./gradlew clean assemble connectedCheck
|
@ -1,5 +1,7 @@
|
||||
# Eclipse Paho Android Service
|
||||
|
||||
[](https://travis-ci.org/jpwsutton/paho.mqtt.android)
|
||||
|
||||
The Paho Android Service is an MQTT client library written in Java for developing applications on Android.
|
||||
|
||||
To get started, download [Android Studio](http://developer.android.com/tools/studio/index.html). You will also need to download the [Android SDK](https://developer.android.com/sdk/installing/adding-packages.html). Currently you will need the SDK for 19,21 and 22, This will hopefully be simplified soon.
|
||||
|
11
build.gradle
11
build.gradle
@ -4,10 +4,15 @@ buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
||||
//classpath 'com.android.tools.build:gradle:2.0.0'
|
||||
classpath 'com.android.tools.build:gradle:2.0.0'
|
||||
//classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
|
||||
// Work around to fix build
|
||||
//classpath 'com.github.JakeWharton:sdk-manager-plugin:1d29782dd6'
|
||||
classpath 'com.github.sschuberth:sdk-manager-plugin:master-SNAPSHOT'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
@ -30,7 +35,7 @@ ext{
|
||||
|
||||
mavenUrl = "https://repo.eclipse.org/content/repositories/paho-snapshots/"
|
||||
|
||||
supportLibVersion = '23.1.1'
|
||||
supportLibVersion = '23.3.0'
|
||||
|
||||
}
|
||||
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Wed Oct 21 11:34:03 PDT 2015
|
||||
#Mon Apr 11 13:12:12 BST 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
|
||||
|
@ -27,12 +27,13 @@ repositories {
|
||||
maven { url rootProject.ext.mavenUrl }
|
||||
}
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
|
||||
compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
|
||||
compile (project(':org.eclipse.paho.android.service')){
|
||||
exclude module: "org.eclipse.paho.client.mqttv3"
|
||||
}
|
||||
compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}"
|
||||
compile project(':org.eclipse.paho.android.service')
|
||||
}
|
||||
|
||||
task publishAPK(type: Copy) {
|
||||
|
@ -12,10 +12,7 @@
|
||||
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
|
||||
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
|
||||
<afterSyncTasks>
|
||||
<task>generateDebugAndroidTestSources</task>
|
||||
<task>generateDebugSources</task>
|
||||
</afterSyncTasks>
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
@ -28,7 +25,7 @@
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
@ -50,6 +47,13 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||
@ -57,6 +61,13 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
@ -66,17 +77,23 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
|
||||
@ -85,6 +102,7 @@
|
||||
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="org.eclipse.paho.client.mqttv3-1.0.3-SNAPSHOT" level="project" />
|
||||
<orderEntry type="module" module-name="org.eclipse.paho.android.service" exported="" />
|
||||
</component>
|
||||
</module>
|
@ -9,6 +9,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 22
|
||||
testApplicationId "org.eclipse.paho.android.service.test"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
@ -29,6 +30,11 @@ android {
|
||||
repositories {
|
||||
maven { url rootProject.ext.mavenUrl }
|
||||
}
|
||||
|
||||
configurations {
|
||||
//androidTestCompile.exclude module: 'org.eclipse.paho.client.mqttv3'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}"
|
||||
compile "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
|
||||
@ -115,3 +121,7 @@ repositories {
|
||||
assemble.dependsOn copyLibs
|
||||
publish.dependsOn renameReleaseAAR
|
||||
|
||||
clean.doFirst {
|
||||
delete 'libs'
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application>
|
||||
<!-- Mqtt Service -->
|
||||
<service android:name="org.eclipse.paho.android.service.MqttService" >
|
||||
|
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
# How to Add certificates to the BKS keystore
|
||||
|
||||
## Getting the certificates
|
||||
|
||||
```openssl s_client -connect iot.eclipse.org:8883 -showcerts```
|
||||
|
||||
Notes: you need all certificates in chain (Copy each to a .crt file)
|
||||
|
||||
## Adding to keystore
|
||||
|
||||
```keytool -importcert -v -trustcacerts -file "iot.eclipse.org.crt" -alias iot.eclipse.org -keystore "test.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "/home/james/Downloads/bcprov-jdk15on-154.jar" -storetype BKS -storepass mqtttest```
|
@ -19,15 +19,17 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url rootProject.ext.mavenUrl }
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
||||
compile 'com.android.support:design:23.2.1'
|
||||
compile 'com.android.support:recyclerview-v7:23.1.1'
|
||||
compile (project(':org.eclipse.paho.android.service')){
|
||||
exclude module: "org.eclipse.paho.client.mqttv3"
|
||||
}
|
||||
|
||||
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
|
||||
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
|
||||
compile "com.android.support:recyclerview-v7:${rootProject.ext.supportLibVersion}"
|
||||
compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}"
|
||||
compile project(':org.eclipse.paho.android.service')
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import org.eclipse.paho.android.service.MqttAndroidClient;
|
||||
import org.eclipse.paho.client.mqttv3.DisconnectedBufferOptions;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
|
||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
||||
@ -183,6 +184,16 @@ public class PahoExampleActivity extends AppCompatActivity{
|
||||
addToHistory("Failed to subscribe");
|
||||
}
|
||||
});
|
||||
|
||||
// THIS DOES NOT WORK!
|
||||
mqttAndroidClient.subscribe(subscriptionTopic, 0, new IMqttMessageListener() {
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
// message Arrived!
|
||||
System.out.println("Message: " + topic + " : " + new String(message.getPayload()));
|
||||
}
|
||||
});
|
||||
|
||||
} catch (MqttException ex){
|
||||
System.err.println("Exception whilst subscribing");
|
||||
ex.printStackTrace();
|
||||
|
@ -1,2 +1,3 @@
|
||||
include ':org.eclipse.paho.android.service', ':org.eclipse.paho.android.sample', ':paho.mqtt.android.example'
|
||||
include ':org.eclipse.paho.android.sample', ':org.eclipse.paho.android.service',':paho.mqtt.android.example'
|
||||
project(':paho.mqtt.android.example').projectDir = new File('paho.mqtt.android.example')
|
||||
project(':org.eclipse.paho.android.sample').projectDir = new File('org.eclipse.paho.android.sample')
|
Loading…
x
Reference in New Issue
Block a user