HHow to add an external library to an Android Studio project? - android

How to add this library (https://github.com/swapnil1104/CurveGraphView) to Android Studio project? I've tried so many things and still can't figure it out...
I just started to learn, so if you can in more detail. I tried to import through the build.gradle file, well, I constantly see an error enter image description here

You are tru to use this gradle link to implementation in gradle file.
implementation 'com.github.swapnil1104:CurveGraphView:2.1'

Related

How to add an Android library to my project's build.gradle files (in Android Studio)?

I'm trying to work with Instagram in my Android app and am looking to use this: library to make things smoother; however, in trying to import the library I'm having problems. What I've done so far is to unzip the downloaded file and place its contents in my app's libs folder. The problem I'm facing is when trying to add it as a dependency in my build.gradle. So far I've tried
compile 'net.londatiga.android.instagram:AndroidInstagram:1.0'
and its various permutations (removing 'instagram', removing 'android' etc.) to no avail. Because the exact compile statement isn't listed on the github page I'm unsure as to how to import the library.
Any help appreciated!
I think this library should solve your problem :
https://github.com/gorbin/ASNE

How to Use Android PagerSlidingTabStrip library or any other gradle built library in Eclipse

I have a problem importing the PagerSlidingTabStrip library into Eclipse, I get multiple errors and I know this happens because the library was built using gradle.
I tried to follow this answer but I can't find use as source folder in the build path menu.
I've never used gradle previously and don't know how to go about this in Eclipse. Please guys, help most of us who have this problem out of our dilemma. Would be very grateful.
Okay in the end this was what i did:
I checked the build.gradle file of the library for target and min sdks. I then put what i found in the android manifest.xml which I know Eclipse uses.
I deleted the build.gradle and gradle.properties files.
Made sure the project was marked as a library. And it works!
I think the most crucial step was to check the build.gradle for the sdks and whatever else the project requires and replicating that the way it should be in the manifest file.

Adding libgdx extensions to IntelliJ

Everybody!
I'm a newb in game development. And I'm following the tutorial in "Learning Libgdx Game Development" to create cross-platform 2D games. However, I'm using IntelliJ instead of Eclipse because IntelliJ seems like to help me out with my coding style.
My problem is: When I import a libgdx project to IntelliJ (using "gdx-setup"), everything works fine. Until I need an extension of libgdx called TexturePacker in "extensions/gdx-tools". I think I can add this .jar file as a normal library but it does not work.
Here is the errors I have got:
Error:(5, 44) Gradle: error: package com.badlogic.gdx.tools.texturepacker does not exist
I will appreciate your help. Thanks!
Since your libgdx project is now built with gradle you will have to add the tools extension as a gradle dependency of your desktop project:
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
otherwise gradle won't compile (..and find) it.
This is explained in more detail at the libgdx project page
BTW: While setting up your project with the gdx-setup jar you can check the "tools" checkbox and it will generate a project that already has the tools dependency in the build.gradle file.
You have to add .jar file to all project files(android/desktop/html and source).Also try to use this one instead:
import com.badlogic.gdx.tools.texturepacker.TexturePacker;

Importing and using a library in android studio

I am using android studio to import this project called https://github.com/Pixate/pixate-freestyle-android. However when I import it into android studio the folder under samples, freestyleshowcase doesnt seem to build. The other 2 samples buld correctly. There is a red circle around the java file with a J (error) but there is no error in the file itself. COuld someone please help me out?
You are obviously missing some libraries but it is going to be hard for anyone to tell you which since we do not know the libraries the project needs.You can try Build-->Rebuild Project or Build-->Clean Peoject if it still doesn't work, close and open Android Studio.
If that doesn't work also then you have to go the hard way of identifying the libraries need by the project samples you imported and see if you have them.
When in doubt, you can try the Library Dependency option (using Maven) as demonstrated here:
https://www.youtube.com/watch?v=6BUcx9gGQ3o
That way, you won't have to manually edit the build.gradle file.

How do I import com.google.android.gms.* in Android Studio using a Gradle build?

I have followed the procedure as described here : Setup
I have clicked on the little 'Sync project with Gradle' button. Gradle and Android Studio seem to find everything but then I can't actually use the gms code. If I try to import, I will get autocomplete for com.google.android.gms but no further. I have updated all the packages with Android SDK Manager.
I'm running Android Studio 0.4.2.
My minSdk is set to 9
my build.gradle includes compile 'com.google.android.gms:play-services:4.0.30'
As far as the procedure is concerned I should be ready to code, but it just doesn't work. Any ideas?
[Edit, added info]
I can find the ComGoogleAndroiddGmsPlayServices3265.aar file in my exploded bundles directory. Inside of that file I also find the common directory and inside that I find the GooglePlayServicesUtil.class (which is what's not being found in my app)
I am lost.
[Edit 2]
The problem is not specific to Google Play Services OR Android Studio. I tried adding another library (HoloColorPicker) and had the same results. However, I was able to add the library's resources to my project! I was able to add them in my XML layouts and view them in my application. I was able to interact with them, they worked fine. The problem arose again when I tried to reference them in the code. Exactly like the case with gms, I had code completion when trying to import up to the point of the actual class, and I could not declare the class in the code.
I was able to use the library by cloning it and importing the project.
Also, this is not an Android Studio problem because the same thing happens on the command line with "./gradlew clean build"
This is a current bug in Android Studio: https://code.google.com/p/android/issues/detail?id=64508 to be fixed this week.
The workaround is to close the project, delete the .iml files and .idea project and re-import the project.
Keep Your compile 'com.google.android.gms:play-services:4.0.30' as very first line in build.gradle dependencies like
dependencies {
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:+'
}
`
Open File> Project Structure and do the following steps
Select your main module in which you want to add dependency and click on OK.
Now try to import.
I think the most important question is what you want to achieve. Not all code is under this package. Not even sure which one is.
As noted before, this is a bug with Android Studio. It just don't recognize the path for classes and shows you like if there is an error. If you try compiling you'll see that everything just work fine.
A googler recently said it'll be addressed in this week release, so, be patient and lets see whats coming.
The fact that AS is in Preview mode tell us this sort of things are going to happen :)
Android studio is crazy one, I think.
It's removed "Import module" function and you can do "New module" only.
If you are developed on Eclipse, you need export all your projects to Gradle before switch to Androids studio (WTF?)
I prefer "IntelliJ IDEA Community Edition", although It's similar Android studio but it's better than Android studio (at least until now). You just import your project as eclipse format, IntelliJ IDEA will detect dependences libraries automatic (May be you need import jar libraries by hand) and rebuild project. That Done.

Categories

Resources