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?
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"
}
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. :)
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
Related
So I'd like to import the "apache commons ftp" libraries for use in my project. I got as far as the importing the modules, and am including a pic just to show that they're in there.
But when I try to use the import statements
(i.e.) import org.apache.commons.net.ftp.FTP;
they fail.
So am curious if I am missing a step, or am missing something.
Please add below dependency in your gradle:
// https://mvnrepository.com/artifact/commons-net/commons-net
compile group: 'commons-net', name: 'commons-net', version: '3.5'
For any dependency to import in Android Studio through gradle use below reference:
https://mvnrepository.com/
This will save your time from importing module and solving gradle errors :)
Thank You
I would recommand AndiGeeky's answer if you don't modify so you have a custom library.
Meanwhile if you really want to use the library as a module, you can add this line in your build.gradle in your module app
compile project(':NAME_OF_YOUR_MODULE') << should be commons-net-3.5
Hope that will help you :)
I've migrated an Eclipse example to Androidstudio gradle type project.
I've added twitter4j libraries to module build.gradle:
dependencies {
compile 'org.twitter4j:twitter4j:4.0.3'
compile 'org.twitter4j:twitter4j-core:4.0.3'
compile 'com.twitter:hbc-twitter4j-v3:1.4.2'
compile 'org.twitter4j:twitter4j-http2-support:4.0.3'
}
It's importing twitter4j classes, but not these ones:
import twitter4j.http.AccessToken;
import twitter4j.http.RequestToken;
It says cannot resolve symbol http
I've tried importing the twitter4j.http but nothing I just can't make it work.
I'm using:
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
Anybody can shed some light on this?
I've looked for hours but no solution yet :(
Thanks in advance!
AccessToken is in the twitter4j.auth package. I assume there is a similar problem with your other classes. It appears that the package structure has been rearranged from earlier versions. I suggest you bookmark the twitter4j JavaDocs and refer to them regularly.
I'm facing a little problem with one of my libraries in Android Studio. This one is imported with a Gradle file, like this :
dependencies {
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
}
It has a known issue from its GitHub repository but I can only fix it by editing one line of code in a file of this library... The problem is that I can't find its code in Android Studio.
From another Stackoverflow post, I've found this :
apply plugin: 'idea'
idea{
module {
downloadJavadoc = true
downloadSources = true
}
}
But after applying it and reloading my Gradle configuration, I still can't find the code.
Can you help?
Thanks!
You can also extend that class and override that method. After overriding just update the code according to your need and solve that bug and use your new class :-)
I know there are already similar question but I still could not find a way to do this:
I want to import and use the following GitHub project in my own Android Studio project:
https://github.com/shamanland/floating-action-button
The owner say in another topic to just add a dependecy:
dependencies {
compile 'com.shamanland:fab:0.0.5'
}
I already tried:
repositories {
mavenCentral()
}
But it did not help. Could someone please explain how to add such GitHub projects the easiest way?
There are two gradle files..You should add dependancy in inner build.gradle file. In outter build.gradle file you should add repositories...
I've been trying to do get the gamebaseutil into my project.. I switched from eclipse to android studios 'cause it seemed impossible to import it in Eclipse.. Now I don't understand the importing of android studios very well so I'm still trying to import and use it..I have really no idea what i do wrong or what i have to do... I'm pretty sure I imported GameBaseUtil into android studios but now I want to make use of it in my project.. I have added " include '(:libraries):BaseGameUtils', ':Name' " to my settings.gradle.. and when I run it, there are no gradle build errors but still I can't instantiate "GameHelper mHelper;" for example. Or "extends GameBaseActivity"
Please tell me what to do. I'm really desperate 'cause I have been reading and trying the whole day...
Including the lib in gradle.settings is the first step.
The next step is to add the lib as a dependency of your main project (in the build.gradle):
If you have the sources of the library :
dependencies {
compile project(':GameBaseUtil')
...
}
If your library is in a maven repository :
dependencies {
compile '<groupid>:<artifactid>:<version>'
...
}
there other ways to define a dependency : here