Gradle 构建问题:在最新的 Android SDK23 上升级 Quickblox 和 httpclient

Posted

技术标签:

【中文标题】Gradle 构建问题:在最新的 Android SDK23 上升级 Quickblox 和 httpclient【英文标题】:Gradle build issue: upgrading Quickblox and httpclient on latest Android SDK23 【发布时间】:2016-05-19 00:17:44 【问题描述】:

我正在尝试将 android 应用程序(使用 Quickblox 和 httpclient 进行服务器通信)升级到最新的 SDK 23。 我遇到了一些问题。我知道 SDK23 不支持 httpclient。您可以检查以下错误:

Process: com.a.test, PID: 26761
 java.lang.NoClassDefFoundError: Failed resolution of: Lde/measite/minidns/Client;
 at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.<init>(MiniDnsResolver.java:50)
 at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.<clinit>(MiniDnsResolver.java:45)
 at java.lang.Class.classForName(Native Method)
 at java.lang.Class.forName(Class.java:324)
 at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:213)
 at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:193)
 at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:163)
 at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148)
 at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116)
 at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96)
 at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration.java:38)
 at com.quickblox.chat.QBChatService.<clinit>(QBChatService.java:77)
 at com.a.test.services.ServiceCheckAppRunning.getDialogs(ServiceCheckAppRunning.java:170)
 at com.a.test.services.ServiceCheckAppRunning.checkInternet(ServiceCheckAppRunning.java:158)
 at com.a.test.services.ServiceCheckAppRunning.access$000(ServiceCheckAppRunning.java:49)

Caused by: java.lang.ClassNotFoundException: Didn't find class "de.measite.minidns.Client" on path: DexPathList[[zip file "/data/app/com.a.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.a.test-1/lib/arm, /vendor/lib, /system/lib]]
 at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
 at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.<init>(MiniDnsResolver.java:50) 
 at org.jivesoftware.smack.util.dns.minidns.MiniDnsResolver.<clinit>(MiniDnsResolver.java:45) 
 at java.lang.Class.classForName(Native Method) 
 at java.lang.Class.forName(Class.java:324) 
 at org.jivesoftware.smack.SmackInitialization.loadSmackClass(SmackInitialization.java:213) 
 at org.jivesoftware.smack.SmackInitialization.parseClassesToLoad(SmackInitialization.java:193) 
 at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:163) 
 at org.jivesoftware.smack.SmackInitialization.processConfigFile(SmackInitialization.java:148) 
 at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:116) 
 at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96) 
 at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration.java:38) 
 at com.quickblox.chat.QBChatService.<clinit>(QBChatService.java:77) 
 at com.a.test.services.ServiceCheckAppRunning.getDialogs(ServiceCheckAppRunning.java:170) 
 at com.a.test.services.ServiceCheckAppRunning.checkInternet(ServiceCheckAppRunning.java:158) 
 at com.a.test.services.ServiceCheckAppRunning.access$000(ServiceCheckAppRunning.java:49) 
 at com.a.test.services.ServiceCheckAppRunning$TimeDisplayTimerTask$1.run(ServiceCheckAppRunning.java:114) 
 at android.os.Handler.handleCallback(Handler.java:739) 
 at android.os.Handler.dispatchMessage(Handler.java:95) 
 at android.os.Looper.loop(Looper.java:148) 
 at android.app.ActivityThread.main(ActivityThread.java:5417) 
 at java.lang.reflect.Method.invoke(Native Method) 
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: de.measite.minidns.Client
 at java.lang.Class.classForName(Native Method)
 at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
 at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
   ... 24 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

有人知道解决办法吗?我可以分享任何需要的代码。

【问题讨论】:

您找到解决问题的方法了吗?我目前遇到了同样的异常。 有人找到解决办法了吗? 【参考方案1】:

我能够通过在 build.gradle 中添加以下依赖项来解决此问题

compile 'com.google.code.gson:gson:2.6.2'
compile group: 'de.measite.minidns', name: 'minidns', version: '0.1.7'
compile group: 'org.jxmpp', name: 'jxmpp-util-cache', version: '0.5.0'
compile group: 'org.jxmpp', name: 'jxmpp-core', version: '0.5.0'

【讨论】:

以上是关于Gradle 构建问题:在最新的 Android SDK23 上升级 Quickblox 和 httpclient的主要内容,如果未能解决你的问题,请参考以下文章

Android gradle 插件与最新 Gradle 版本的兼容性

很长的 gradle 构建时间 - Android

Android插件的Gradle基础

Android Studio gradle插件版本和gradle版本对应

build.gradle-构建

build.gradle-构建