I have an android project that consist of .jar file's library and some library project's that have not any gradle file's, when i import this project in Android studio i faced to some error's that tell me this librarie's are not applied how can solve this problem?
To add a Jar Dependency in Android Studio. put that jar file in Your project-->app-->libs folder. and then follow these steps
Go to File --> Project Structure
On the left hand side you will see app module. click on that and then on the right hand side select Dependencies tab
Now click (+) button on the right
Select file dependency
A dialog will appear that let you choose your jar file
select the jar you want to add and click ok. DONE
You need to make sure all your modules that have the support library as dependency also have the compile SDK set to 21 . So go to Project Structure and check all the modules on the left hand side.
Related
i have found this sdk: is24-restapi-java
and i want to import it into my android studio project for further use.
But i can't find a way to include it.
I did some searching through the github project i cannot find a simple jar or dependency that i can include into my project and all advances to generate a jar or something failed.
Can anyone give me a guid or something to include this sdk into my project or am i using the wrong approach?
Goto File -> New -> Import Module.
Source Directory -> Browse the project path
Specify the Module Name – it is used for internal project reference.
Let Android Studio build the project.
Open build.gradle (Module:app) file.
Add the following line with your module name in place of “projectName” in the dependencies block:
compile project(':projectName')
After this Android Studio would start saying “gradle files have changed since last project sync”, press the “sync now” link to start a sync.
To resolve my previous question (How to create a floating action button (FAB) in android, using AppCompat v21? ), i found a nice library here: http://android-arsenal.com/details/1/824 , and i downloaded a .zip file.
The web site contains some instructions about the use of the library, but not how to add it to the project with Android Studio (for example: where to copy the downloaded files, and what files i need to copy)
It is the first time that i use a library, and i don't know what i to do.
How do I put it to my project?
Well this was a problem I faced few days back.
Follow the steps and it will definitely work.
STEP 1:
Extract the JAR File from the library and keep it in the Desktop.
STEP 2:
In Android Studio, on the left side,There is a Directory View. There is a dropdown menu on top, which has three choices. Project, Packages and Android - choices. Select the 'Project' section.
Now under that, you will find two Folders - 'Your Application' and 'External Libraries'.
Click on ur Application name and under that, click on the 'app' folder.
Now under that there is a folder called 'libs'. This is the folder where you will paste the JAR file you extracted.
Step 3:
Paste the JAR file inside the 'libs' folder.
After that there is one more important step.
Step 4:
Right-click on the file that you pasted on the 'libs' folder and select the option 'Add As Library'.
Then a popup will appear asking to create the library.
Under 'Add to Module', select 'App'.
Then press ok.
Wait for a while for the Gradle to build it.
After that , Enjoy.
Your new Library is available in your 'imports'.
It's is very simple: Follow the instruction below
copy the line below and navigate to build.gradle file on your project & the open it.
compile 'com.melnykov:floatingactionbutton:1.2.0'
Paste the copied text here:
dependencies {
............................
compile 'com.melnykov:floatingactionbutton:1.2.0'
............................
}
Click the sync gradle file icon on the toolbar.
Enjoy !
If I remember correctly you just drag and drop the library to the AS project. you have to unzip first to have a .jar file.
If you want to use Maven you have to add the dependencies to the gradle.
I have a library beside my main project in an android project.
How can I set compiler to it always compile library first and then compiles my main code?
Currently I have to compile two times on every build.
To Add Library project to Your Project
1.If you have a jar file then place the jar file in the libs folder in your project.
then right click on it and Build Path-->Add to Build Path
2.If you have a library as a project then right click on your Main project
Properties-->Android-->Add then select your library project(make sure here library projects with librariesonly appear)
3.if your library project is not appearing in this list then rigth click on your library project Properties-->Android tick isLibrary option there)
you can cjheck out the image like..
if you want to change the priority of your Library
Right Click on your Project Build path--> Configure Build path --> Order and Export
there you will see your library select your library click on top at the right side
the image is like below.
I want to create a GridView like GooglePlay.
I found this library on Github. I don't exactly know how to include it to my project. I tried to add it in "Build Path", but it doesn't work.
Is it possible to export it as a jar file?
You will have to import library directory as a project in your Eclipse just like #ssantos said in the answer. However you have to do one extra thing to make it work.
All the code is in a sub folder called "java". You have to right click on it and make it as source folder.
For more information you can look at the official guidlines https://github.com/gabrielemariotti/cardslib/blob/master/doc/BUILD.md
It seems you can find the library project here.-
https://github.com/gabrielemariotti/cardslib/tree/master/library/src/main
I'd try importing that as a project in your workspace (and mark it as Android library), and then including it in your project Android libraries (Project properties => Android => Library section)
If you're using Android Studio, just add the following to your build.gradle file.
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.3.0'
}
In my project, I need to use external library. That library consists of .class files. I have added folder with this library to my project using properties -> Java Build Path -> Libraries -> Add class folder. I can compile project without any problem, but when I run it, I get failed resolving xy and debugger stops on line where I create instance of class from imported files.
I guess the external library I use isnt linked to my .apk file. How can I fix this? I have tried to check this library on "Order and Export" tab assuming that, it will export the library with my application. But it didnt work.
How can I link this library to my project .apk? Do I need to somehow install this library on device first? Do I need to copy this library in application folder?
PS: I'm using Eclipse Juno, android SDK target 10.
Thank you
UPDATE
I have this library copied in libs folder. External library path is:
my_project/libs/sk/aicit/leg/libraries*.class
I have added ./libs folder in Libraries settings of project.
I do not have .jar version of this library, only .class files.
I have also souce code of this library, but I didnt want to include its classes in my project, it has its own dependencies, I wanted to just "link" it like library. Its an external library I havent written.
UPDATE 2
I have copied all the source files from library to my projects "src/" dir. I have removed Library from Java build path. I can stil compile my project, but when I run it Iget
FATAL EXCEPTION:main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{
com.example/myvideorecord/com.example.myvideorecord.Robot}: java.langNullPointerException
...
What can I do, how to debug this error? :(
steps
Copy the library file into libs folder
select jar file -> right click -> Build Path -> Add to Build Path
clean the project Project-> Clean -> select your project -> ok
Android Studio
For importing a Android library into Android Studio, use the following steps:
1) (Optional) I like having my main Android project contain everything it needs to compile correctly, so I move external libraries into the libs/ directory. Generally, you only need to keep the following directories:
res
src
AndroidManifest.xml
*.iml (This will typically be the name of the library you're importing.)
2) Go to your Project Properties.
3) Go to Modules.
4) Import a New Module (Command + N and then Import Module).
5) Navigate to the library directory you want to import.
6) Create module from existing sources.
7) Click Next three times to add the necessary files.
8) Click Finish to complete the module additional.
9) Click on your project in the module list and go to the Dependencies tab.
10) Click the + button at the bottom and click Module Dependency....
11) Make sure your library you're importing is selected and click OK.
12) Click OK in the Project Properties window.
And you should be good to go.
Copy that library file into libs folder
if u have the source code of the library you can import it in eclipse .
Right click on your project -> properties->android -> reference-> add
and add the library project which u have imported. This will include only .class files of the library in ur project