Android studio add libs - android

I use "add as library" in Android studio, and it sets "compile files('libs/XXX.jar')" in "build.gradle". But it doesn't work!!!
It cost lots of my time. At last, I modify to "compile files('XXX.jar')"
But my jar is in directory "libs" as picture shows: libs Picture
Please tell me why!
Here is the supplement picture of build.gradle

Try adding compile fileTree(dir: 'libs', include: ['*.jar']) to your Gradle file and tell me if it worked :)
edit
or does it work but you don't understand why it works like this? Then it automatically assumes that your libraries are placed in that directory so you don't need to specify the libs/xxx.jar because it knows it should look in that directory anyways, so then it would search for libs/libs/xxx.jar instead of libs/xxx.jar. Hope that makes sense

In Android Studio click on Project Structure button to the right of Run Button,then click on the green + icon in the top right,choose Android Import Exiting Project[if the lib is .jar of .AAR choose Import . JAR or .AAR]then choose the lib and click finish,wait for gradle sync,then add the compile.Wish this helps

Related

error :the package com.badlogic.gdx does not exist

I receive the "error :the package com.badlogic.gdx does not exist" when you try to start the project.
In my project there is a libGDX. Classes see it and objects from this libGDX are used. But when trying to compile an application, this error occurs.
At the same time, there are no errors in the classes on which this error is made.
"Sync Project with Gradle Files" and "Invalidate caches/restart" did not help.
Someone came across similar? How to fix this?
enter image description here
Go to libs folder, right-click on libraries you want then select: Add as library
The reason is, you should add the external libraries on Build.Gradle if the online source from maven-jcenter or etc is not available and you have to add them manually.
After doing this, try rebuild the project then you're good to go.
Or in code: (in not added cases by IDE)
implementation fileTree(dir: 'libs', include: ['*.jar'])
Replace the name instead of * in above code.
How to add a jar in External Libraries in android studio
And: How to add a jar in External Libraries in android studio

I cannot import ksoap2 at my class

I have Android Project in which I want to use ksoap2.
I paste the .jar (ksoap2) in my folder libs, then right click on and go ahead to "Add as Library".
enter image description here
After I sync my gradle, Android Studio update dependencies in file build.gradle, like this:
compile files('libs/ksoap2-android-assembly-3.6.1.jar')
Finally in my class MainActiviy.java I want to type import org.ksoap2.Envelope, the IDE doesn't recognize the class ksoap2.
What is wrong with mi procedure?
Best regards.
You just need to paste .jar in your libs and add this in your build.gradle(app)
compile fileTree(dir: 'libs', include: ['*.jar'])
Then Sync.
The problem was that I pasted the .jar file in libs directly in file browser/finder. The correct way is paste the .jar in libs through de Android Studio.
In file browser/finder where .jar file it's, right click and copy.
In Android Studio, Project tab select "Project" to see complete structure. Then you can see libs folder.
Right click on libs folder and go ahead "Paste As Library"
Android Studio creates the correct structure.

Cannot evaluate module libs:configuration with name 'default' not found

Good morning every body ,Please i have an error at my android application when i try to import file.jar .. I really tried a lot of solution but the error is the same.
Can u help me please to solve the problem ! thank you
Add your library folder in your root location of your project and copy all the library files there. For ex YourProject/yourlibrary then sync it and after that you need to mention that library in settings.gradle e.g include ':yourlibrary' one more thing you need to do is to add this line in build.gradle(Module app)
compile files('libs/yourlibrary')
here is the second way to do this just Go->File in android studio after that find project structure then click on Dependencies -> click on green "+" icon then click on File Dependencies select your required file from your libs or library folder and click ok.

Import parse.com library into Android studio 0.8.2

I'm trying to import the Parse-1.5.1.jar file into my project in Android studio following these steps:
- File -> Project structure
- Click on the plus button and click on Import .JAR or .AAR package
- Choose my jar file and then hit finish
But then any command from the parse library is recognized. For example : "Cannot resolve symbol ParseObject" and android studio doesn't propose me to import anything.
I can't find on stackoverflow any instruction for these version of Android studio and Parse.
Any suggestion ?
Today i too started with Parse. All you need to do is:
Copy the parse-1.5.1.Jar file (Ctrl+c) and paste it in app->libs folder
Ensure build.gradle inside the app folder contains this line: compile fileTree(dir: 'libs', include: ['*.jar'])
That's it. You just need to click on Sync Project with Gradle Files button on the top to rebuild your project. You'll now be ready to use the classes from the Parse Library.
Hope this helps. All the best
Take your Parse-1.8.4.jar file and copy and paste it into your libs folder.
Then make sure your manifest has all the correct permissions. Here is some, but there are more permissions than this:
Make sure you have the parse class that extends Application and calls Prase.initialize in onCreate().
Then go to File -> Project Structure. In the pop-up, select "app" -> "Dependencies" tab -> Click on the plus sign and select "File dependency". Then select your "Parse-1.8.4.jar" file.
Firstly open your project libs file. Download parse example project code from https://www.parse.com/tutorials#android . opy the libs file.Paste them to your project file/libs file.Click File in android studio and then click project structure tab or hit the F4 if its work. And click "app" left side of tab in opened window.Then Dependencies tab. Click "+" on right side. Click File Dependency and click libs and find the Parse.xxx.jar file and click OK and Apply . Tahts it. And you can also take look here https://www.parse.com/tutorials#android.

Android studio lock icon on files

Can any one help resolve this. Iv added a jar file to my android project
Right click of the jar and selected "Add as library"
But the classes in the jar show lock icons and I cant import them...
Any help would be appreciated!
Mine show lock icons and they have been imported correctly. Did you add this to your build.gradle file?
dependencies {
compile files('libs/twitter4j-stream-4.0.1.jar')
}
also once version 4.0.1 is in maven central (soon? https://twitter.com/t4j_news/status/445971905191759874) you can simply import it by adding compile 'org.twitter4j:twitter4j-stream:4.0.1' without including the jar file at all.

Categories

Resources