Reputation: 20214
I use Eclipse before changing to AS,but something really puzzle me. I import the Smack4.1.4 into app/libs,and set the dependencies. Everything looks OK without one exception. Caused by:
java.lang.ClassNotFoundException: Didn't find class "javax.naming.directory.InitialDirContext"
I have searched about it, it seems that javax.naming
is not in android's whitelist.
So how could i use smack in AS? That's a big problem for me. Could someone help?
Upvotes: 1
Views: 299
Reputation: 11
After 1 day i finally resolve this issue in nativescript android. Dont add dnsjava.(version).jar , smack-java7-version.jar Add smack-resolver-dnsjava-4.2.1.jar
Upvotes: -1
Reputation: 54781
What you need to do is to stop importing jar files and start using gradle to resolve the dependencies, that's a major difference in how you import libraries in Android Studio vs Eclipse, only import jars if they are not available from a repository:
https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide
Example:
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
mavenCentral()
}
dependencies {
compile "org.igniterealtime.smack:smack-android-extensions:4.1.0"
compile "org.igniterealtime.smack:smack-tcp:4.1.0"
}
Upvotes: 2
Reputation: 20214
OK, now I solve this problem.
Actually, I also need to import the following jar:
dnsjava:dnsjava
org.jxmpp:jxmpp-core
org.jxmpp:jxmpp-jid
org.jxmpp:jxmpp-util-cache
Hope my answer will help some beginners like me. :)
Upvotes: 0