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
Related
The title is a little misleading but I honestly don't know how to word it in any other way. This is my project structure:
I want to use the highlighted (fasteranimationscontainer-master) in my current app that I'm working on. I imported it by putting the jar file in my library folder then adding it to my library through Android Studio. But I try to create an object of that imported library, it doesn't show up/import.
I'm still learning how to use android studio so any help would be much appreciated!
1. Library with only the Source Code
To include a library with only the source code (like FasterAnimationsContainer) to your project, you only need to import it as a module from File -> New-> Import Module in Android Studio:
There should be a dialog for the project folder, enter the path where your library reside.
Then you need to add the module to your app build.gradle as a dependency:
android {
...
dependencies {
...
compile project(':fasteranimationscontainer')
...
}
}
Now you can use it in your project.
2. Library from Maven or JCenter
To add dependencies to your project where the library has uploaded to maven or jcenter, you need to modify your app build.gradle file and add extra lines configuring the packages you require. For example, for certain Google or Android, dependencies look like:
android {
...
dependencies {
// Google Play Services
compile 'com.google.android.gms:play-services:6.5.+'
// Support Libraries
compile 'com.android.support:support-v4:22.2.1'
}
}
Try to always read the library README first.
Suggestion:
If you still learning using Android Studio, you can read Using Android Studio. Then read Getting Started with Gradle, because Android Studio is tightly related with Gradle.
On Eclipse I have one application as lib.
Then I have 10 more applications that import this lib.
When I'm programming, I do this on the lib project, so I run the application that import this lib. In the application project I just do especific developments.
The code is shared by all aplications.
How can I do this in Android Studio? Because I need to have just one code for all projects.
I've already imported my lib to Android Studio but I don't know how to link it to my application, having in mind that all changes in the lib needed to reflect the other projects (when I open it and compile again).
Thank you all!
---Edit:
My lib settings:
include ':actionbar'
include ':myMainLib'
My myMainLib Gradle:
dependencies {
compile project(':actionbar')
}
My Application settings:
include ':myApp'
include ':myLibProject:myMainLib'
project(':myLibProject:myMainLib').projectDir = new File(settingsDir, '../myLibProject/myMainLib')
My Application gradle:
dependencies {
compile project(':myLibProject:myMainLib')
compile 'com.android.support:support-v4:18.0.0'
}
Error message:
Error:(22, 0) Project with path ':myLibProject:actionbar' could not be
found in project ':myApplication'.
When I clicked to check the error, it's open the lib Gradle.
The actionbar source is in the lib's root dir.
As you have the lib and your apps on your hard drive, you can configure Gradle to resolve the dependency from the local file system.
You have to add these lines to your settings.gradle file, to have the library project available:
include 'yourlib:lib'
project(':yourlib:lib').projectDir = new File(settingsDir, '../yourlib/lib')
This code assumes that both project folders are in the same folder. You can adjust the relative reference or change it to an absolute reference if that fits better for you.
Then you can add the dependency to your app's build.gradle file:
compile project(':yourlib:lib')
I want to add external library "
github.com/AnderWeb/discreteSeekBar
" to my Android application.
I've tried to do it with Gradle sync, and I also tried with this examples.
enter image description here
enter image description here
Any other way to import this lib for layout?
Can be a problem if i have a proxy connection?
I use android studio 2.1.2.
if just add to external library in your project then follow these steps:
Copy the external library and paste into the libs folder which is in app folder.
if you can not see libs folder then change your drop down which is top left corner android to project. then you can see libs folder.
Goto to app gradle and add dependencies for your external library like this.
compile files('libs/your_external_library')
gradle your project.
its work for me .
Add this
dependencies {
compile 'org.adw.library:discrete-seekbar:1.0.1'
}
in your build.gradle file. it is mentioned in the Readme section on github repo. of library. It is always helpfull to take a look at the documentation provided with the stuff, just my two cent.
also check if you have added
repositories {
jcenter()
}
in YourProject->build.gradle
I recently downloaded the ViewPagerIndicator library and imported it into android studio. After adding it to my project I get a rendering error "The following classes could not be found:" and points to com.viewpagerindicator.IconPageIndicator.
The steps I took were Files->Import Module->'library name', Project Structure -> Dependencies -> + the imported module. Then to my layout xml file I added the <com.viewpagerindicator.IconPageIndicator />, after that I got the missing class problem.
It compiles just fine and I went through all of the build.gradle and settings.gradle files and compared them to what they should be online.
MyApp->build.gradle has compile project(':library') under dependencies
settings.gradle has include ':library' with no build errors.
First of all, you must import your library project by following that path:
File --> New --> Import Module
After you have imported the library project successfully, you must check your build.gradle file inside your project's folder if the following line is present at the "dependencies" section:
implementation project(':NameOfTheLibProject')
Then your project must be built successfully.
I found that my issue was the Android Plugin Version under Project Structure --> Project was different to the version my plugins all used. Once I aligned them to the same version, I could see all my classes from my imported module.
Took me hours :(
I had the same problem. I just did: Invalidate / Restart ..
I too had trouble importing module as it was not appearing in list of modules. And way it worked for me is manually entering it in settings.gradle this way:
include ':app', 'module_name'
And in build.gradle
compile project(':module_name')
In my case, I did add in app gradle:
// Nearly deprecated.
compile project(':NameOfTheLibProject')
// Or
implementation project(':NameOfTheLibProject')
but it only works when I change
compileSdkVersion
minSdkVersion
targetSdkVersion
in app and the other modules are the same.
The following solution worked for me,just two steps.
Go to your project structure on android studio, select project from left side.Change Android plugin version to Gradle version press ok.
If error occurs after synchronization again go to project structure and select project.undo the android plugin version like before.Gradle will align the library and make the class visible to XML files.
The issue in my case was different compile and target SDK version,
mentioned in my main app module and your added lib module.
Once I matched both of them it worked perfectly.
So just open build.gradle file of app-level and lib module-level check for the SDK version.
settings.gradle
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(':wheel') // "Wheel" - you're project path name
}
In case you just changed the name of your project in the pubspec.yaml File, make sure to change the import names as well, because they will stay the same and therefore wont find the new named directory.
Ex. change this to :
import 'package:previousName/backend/connector/userConnector.dart';
to this:
import 'package:newName/backend/connector/userConnector.dart';
As far as i know, there is no terminal command for that, only find-in-files-replace :(
I have to create an application that makes extensive use of charts.
Reading the web I chose achartengine that seems to have everything I need.
I downloaded the jar file, I plugged in the libs folder, I selected "add to library" and I lunch the gradlew clean.
Result in the sources where I do the import of org.achartengine.xxxx I always returned the error that fails to resolve symbols .
Do you have suggestions?
Thank you
Andrea
I am able to use this library in my Android Studio project, this topic explains how to add AChartEngine repo to your project.
What I did:
Added following to project-wide build.gradle (one from the project root):
allprojects {
repositories {
...
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
}
For every module that uses the library, add this to its build.gradle (you may put this to the top-level build.gradle if it should be included in all modules):
dependencies {
...
compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'
}
Now I can use the library in the project, I see the classes in code assist popups and build runs as succeeds.
It seems like the new version (1.2.0) is not available for download anymore in the http://www.achartengine.org/ site. and that's why the gradle/maven method doesn't work (or the snapshot file was removed).
I succeeded using and adding it to my project by downloading the jar file from here:
https://github.com/ddanny/achartengine/files/460139/achartengine-1.2.0.zip