MQTT: Android Simple Connect

From OnnoWiki
Jump to navigation Jump to search

setting.gradle

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
        maven {
              url "https://repo.eclipse.org/content/repositories/paho-releases/"
        }
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven {
                url "https://repo.eclipse.org/content/repositories/paho-releases/"
        }
    }
}


build.gradle app

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


AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="itts.onno.hms.ittsmqttsimpleconnect">

    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
       ..............
       <service android:name="org.eclipse.paho.android.service.MqttService" >
       </service>
    </application>

</manifest>


Referensi