我想在android studio中使用Paho-MQTT.我提到了this link
我应该将以下内容添加到gradle文件中
链接要求添加以下内容:
repositories {
maven {
url "/"
}
}
dependencies {
compile(lipse.lipse.paho.android.service:1.0.2') {
exclude module: 'support-v4'
}
}
文本没有指定我使用哪个gradle文件使用“gradle-proj或gradle-app”,所以我尝试了两种,在任何一种情况下我收到的错误如
Error:(14, 0) Could not find method compile() for arguments [lipse.lipse.paho.android.service:1.0.2, build_9fu4g5nmegp97bvhjazm7s8o8$_run_closure1$_closure3$_closure5@6dff2815] on object of adle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
请告诉我哪个gradle文件我应该使用“proj或app”?以及如何正确地将以前的代码添加到gradle?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId st_pahomqtt_1"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "st.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.st.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.straint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//compile lipse.lipse.paho.client.mqttv3:1.0.2'
//compile lipse.lipse.paho.android.service:1.0.2'
//provided le.android.things:androidthings:0.2-devpreview'
//provided le.android.things:androidthings:0.1-devpreview'
//compile(lipse.lipse.paho.android.service:1.0.2') { exclude module: 'support-v4' }
compile files('lipse.paho.android.service-1.0.2.jar')
compile files('lipse.paho.client.mqttv3-1.0.2.jar')
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url "/" }
maven { url "/" }
}
dependencies {
classpath 'ls.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual adle files
}
}
allprojects {
repositories {
jcenter()
maven { url "/" }
maven { url "/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当前错误
解决方法:
在您的应用中,您应该添加:
dependencies {
. . .
compile lipse.lipse.paho.client.mqttv3:1.1.0'
compile lipse.lipse.paho.android.service:1.1.1'
}
在你的项目中:
buildscript {
repositories {
. . .
maven {
url "/"
}
}
}
不要忘记在应用程序标记下向您的清单添加服务:
android:name=lipse.paho.android.service.MqttService"
android:exported="false" />
那两行
compile files('lipse.paho.android.service-1.0.2.jar')
compile files('lipse.paho.client.mqttv3-1.0.2.jar')
在libs文件夹不包含此jar之前将无法工作.如果你想坚持这种方法(复制罐子),你可以在这里找到它们:
标签:android,mqtt,paho,iot,hivemq
来源: .html
本文发布于:2024-01-29 18:38:29,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170652471217463.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |