Many troubles importing a library into AndroidStudio - android

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 :)

Related

How to avoid migrating to AndroidX in react-native?

As Google APIs for Android introduced breaking changes as here I found my self un able to compile my react native android app, there are two things I need to know about:
How to avoid migrating to AndroidX and compile my project as I did before?
For example, when I have this error:
node_modules/react-native-firebase/android/src/main/java/io/invertase/firebase/ReactNativeFirebaseAppRegistrar.java:20: error: package android.support.annotation does not exist
import android.support.annotation.Keep;
how would include that missing package into build.gradle of that module?
I tried:
dependencies {
compile 'com.android.support:support-annotations:27.1.1'
}
but it did not help..
You can disable or avoid androidX with the following step
go to your android/gradle.properties file and paste or update the following
android.useAndroidX=false
android.enableJetifier=false
Although it does not update libraries we import or install, So all the libraries should be in AndroidX support otherwise project will not compile with this change I'm also having the same issue in my case project is fine but the problem is with the library called mapbox which have not support androidx I post the issue here you can check issue and comments.

How do you import a library in the most recent and up-to-date versions of Android Studio (2017, 2.3.1+)?

I'm wondering about this. I've been trying to import a library ("Time4J" Android version "Time4A") to a project in the Android Studio, and had to try a number of different things before getting it to "work". I finally managed to get it to import without errors, but now it crashes and doesn't want to work. Somehow I had managed to import it before and it worked without crashing, now I can't replicate that.
The problem seems to me that there's a lot of out-of-date information here about how to import libraries, and nothing for the most recent and up-to-date versions of the Android Studio system (so I was using like 2, 3, 4-year old stuff to try and make this work and this changes fast because there doesn't seem to be anything available from 2017.) and I suspect this is why it's not working. How do you correctly import a library in the newest 2017 versions (2.3.1 and up)?
The recommended way is to import libraries as Gradle dependencies. As described on the Time4A GitHub page:
dependencies {
compile group: 'net.time4j', name: 'time4j-android', version: '3.33-2017b'
}
Add this to your build.gradle and it will download and import the library.
First you'd better upgrade your build.gradle (Project) and add google() to buildscript and allprojects repositories.
Then you can add whatever dependency you want with new method called Implementation, as compile is deprecated.
dependencies {
implementation group: 'net.time4j', name: 'time4j-android', version: '3.33-2017b'
}

Twitter4j - import issue - AndroidStudio

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.

Import statement for dagger cannot be resolved

I am 'lucky' to have been charged with maintaining a program developed by someone else, and I come across the following problem with an import statement:
import com.fizzbuzz.android.dagger.InjectingDialogFragment;
which Android Studio cannot resolve. I am totally new to dagger...
I have the following in build.gradle dependencies:
compile 'com.fizz-buzz:fb-android-dagger:1.0.1'
compile 'com.fizz-buzz:fb-android-bluetooth:1.0.3'
InjectingDialogFragment is not available in the version you are currently using. Please use compile 'com.fizz-buzz:fb-android-dagger:1.0.3' instead.
For better understating on how Dagger works you can use this blog http://antonioleiva.com/dagger-android-part-2/

How to insert github source code to my project

I'm new at GitHub. I found a library that I want to use in my Android project (Glide), but I don't know how.
After downloading the source code I'm stuck with a zip folder that I don't know how to import it into my project. I'm working with Android Studio.
Any help?
Thanks.
Unzip the downloaded project. Open YOUR project in Android studio. Click File -> Import module. Add this module as a dependency to your project. You should be good to go.
[EDIT]
BUT, since Glide has gradle/maven support, I can just simply modify your project's build.gradle file and add the following lines to the dependencies group:
compile 'com.github.bumptech.glide:glide:3.3.+'
compile 'com.android.support:support-v4:19.0.0' // You might need to increase the version numbers if the libraries have never versions

Categories

Resources