无法在 android 上使用 igniterealtime smack 无法解析 xpp3:xpp3:1.1.4c
Posted
技术标签:
【中文标题】无法在 android 上使用 igniterealtime smack 无法解析 xpp3:xpp3:1.1.4c【英文标题】:can't use igniterealtime smack on android Could not resolve xpp3:xpp3:1.1.4c 【发布时间】:2018-11-10 09:14:07 【问题描述】:我未能在安卓上使用smack jabber。 app.gradle
实现“org.igniterealtime.smack:smack-android:4.3.1” 实现“org.igniterealtime.smack:smack-tcp:4.3.1”
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve org.minidns:minidns-client:0.3.3.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve xpp3:xpp3:1.1.4c.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve org.jxmpp:jxmpp-core:0.6.3.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve org.jxmpp:jxmpp-jid:0.6.3.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve org.minidns:minidns-core:0.3.3.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve org.minidns:minidns-hla:0.3.3.
Gradle 构建失败。
这些是我的 gradle 文件
app.gradle
apply plugin: 'com.android.application'
android
compileSdkVersion 26
defaultConfig
applicationId "ug.situla.passengermvp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
dependencies
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation "org.igniterealtime.smack:smack-java7:4.3.1"
implementation "org.igniterealtime.smack:smack-android:4.3.1"
implementation "org.igniterealtime.smack:smack-tcp:4.3.1"
//implementation "org.igniterealtime.smack:smack-android:4.2.0"
//implementation "org.igniterealtime.smack:smack-tcp:4.2.0"
//implementation "org.igniterealtime.smack:smack-im:4.2.0"
//implementation "org.igniterealtime.smack:smack-extensions:4.2.0"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
configurations
all*.exclude group: 'xpp3', module: 'xpp3'
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
repositories
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
allprojects
repositories
//maven url 'http://localhost:8081/repository/google/'
//maven url 'http://localhost:8081/repository/jcenter/'
google()
jcenter()
maven
url 'https://oss.sonatype.org/content/repositories/snapshots'
mavenCentral()
//google()
//jcenter()
task clean(type: Delete)
delete rootProject.buildDir
【问题讨论】:
你缺少implementation "org.igniterealtime.smack:smack-java7:4.3.1"
依赖
添加没有效果。错误依然存在
在下面查看我的答案
谢谢,我已经发布了完整的 gradle 文件以获取完整的上下文。仍然显示错误
你试过关闭并重新打开android studio吗?类路径在这里应该不是问题...如果您评论 3 行 smack 实现一切正常吗?
【参考方案1】:
确保在您的项目build.gradle
中您拥有:
buildscript
repositories
google()
jcenter()
maven
url 'https://oss.sonatype.org/content/repositories/snapshots'
mavenCentral()
dependencies
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
allprojects
repositories
google()
jcenter()
maven
url 'https://oss.sonatype.org/content/repositories/snapshots'
mavenCentral()
在你的应用程序 build.gradle
的依赖块中:
dependencies
implementation "org.igniterealtime.smack:smack-java7:4.3.0"
implementation "org.igniterealtime.smack:smack-android:4.3.0"
implementation "org.igniterealtime.smack:smack-tcp:4.3.0"
configurations
all*.exclude group: 'xpp3', module: 'xpp3'
文档参考:https://github.com/igniterealtime/Smack/wiki/Smack-4.3-Readme-and-Upgrade-Guide
【讨论】:
谢谢,我不知道为什么,但它现在正在编译。奇怪 有时 Android Studio 仍然卡住并有奇怪的行为,当这种情况发生时,首先要做的就是重新启动它,看看是否能解决问题:) 这行似乎也是必需的。我把它漏掉了configurations all*.exclude group: 'xpp3', module: 'xpp3'
是的,正如文档所说,这行可能是必需的,我已经更新了完整的答案
smack 版本 4.3.1 也会触发错误。其他版本没有问题以上是关于无法在 android 上使用 igniterealtime smack 无法解析 xpp3:xpp3:1.1.4c的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Android 上使用 asmack 登录 Facebook
无法在 Android 7 上使用 Monaca 条码扫描器插件
无法在 Android 上使用 AlarmManager 安排通知(使用 Qt)