Importing and using a library in android studio - android

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.

Related

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.

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.

Import library project to Android Studio how to steps

currently I'm trying to implement and apply a pull to refresh list view for my sample app. Now I found out about chrisbanes pull to refresh here. Yes I know it's no longer maintaned but I can't find any alternatives. Anyway I tried to read a lot of questions about importing a project and I think I'm always lost about it especially with the gradle structure.
What I tried so far is to import the project in eclipse then gradle export and copy paste it on a directory named libraries following the steps in this link. I get an error saying Cannot create class-file.
As for the other test I've done I always get a gradle error. I forgot the exact error message but most of it are because of gradle.build.
Now can anyone tell me on the steps on how I can import this project library for my Android Studio project on a step by step basis? My apologies for asking too much.

ERROR: "._android-support-v4.jar" in project FacebookSDK

Help needed!!!! Stuck for 2 weeks on this and help needed.
I've recently imported the facebook sdk for android and its projects into my workspace. It shows up errors and the problems:
Archive for required library: '/home/Documents/facebook-android-sdk-3.0.2.b/facebook/libs/._android-support-v4.jar' in project 'FacebookSDK' cannot be read or is not a valid ZIP file
And the samples get errors along the line of:
The container 'Android Dependencies' references non existing library '/home/Documents/facebook-android-sdk-3.0.2.b/facebook/bin/facebooksdk.jar'
The things I have done following the other discussions without any success are
cleaned project
set the Facebook SDK as library
looked at the build path section and added external jar consisting of facebook/libs
imported fb sdk like 20 times and into different folders.
made sure my java compiler was 1.6
HELP would be very greatly appreciated!!!!
Take the lastest version of android-support-v4.jar (in your sdk environement : sdk/extras/android/support/v4/android-support-v4.jar) and replace in your project and library project do not create conflict.
The steps to importing a library are:
Download the library
Place the library in the libs folder of the project.
Build the project
Do Not attempt to import the library using some import wizard.
I suspect either your download was corrupted, and you need to do it again, or you put the file into the wrong directly.
I think your problem is that the android.support.v4 versions are different, take the one from your project and replace the one in the Facebook sdk lib folder, it should dismiss the clash.
As per your question, I think you are not able to compile once you add the SDK to your project. Do you get an error saying unable to run as library?
If so that means you have included this as library and create your project as a library to be used further. It is a common mistake that I have seen many people do when they try to import a library to use and tick mark the checkbox is Library. This actually means you want this project to be treated as a library for future use. Just try to add the SDK and do not tick mark the checkbox and this project will run fine.
Many forums will just tell you to tick that checkbox and you will be stuck on this error for long time.
For any .jar file related issues you have to make the .jars files compatible as there hashing a problem and the two jars are not compatible with each other (a version issue).

xmlvm - import errors compat libs in xcode

Does anyone know where the android compat libary is
located in xmlvm so I could copy it by myself to the project folder because this is
what I guess is missing, also would be provided by target=android-on-iphone but as mentioned below this target isn't available in the current build.
I had absolutely no problem installing xmlvm and getting in touch with the
demo/samples also all the demos worked perfectly for me.
But now im stuck at the last 4 errors in xcode, i migrated my android project via --
skeleton=android:migrate then cross-compiled it via --target=iphone and opened
up the project in Xcode. after few project setup changes the errors went down from
72 to 4 errors ;)
however the errors are importing file not found errors of compat libs, so this
should somehow get to be solved i think...
is it because --target=android-on-iphone wasnt used by me because this option
will copy the android compat libary to the project folder.. well i tried to use this
target mentioned in 2 documentations of xmlvm but in the actual build of xmlvm
this target however does not exist..
How to solve these errors?
Screenshots:
http://img526.imageshack.us/img526/8957/bildschirmfoto20120620u.png
http://imageshack.us/f/138/bildschirmfoto20120620u.png/
From what I can see, it looks like you are using part of the Android API which is not yet implemented.
Unfortunately it seems that you either need to rewrite your application or implement the API yourself.

Categories

Resources