Android:External Jar classes not found - android

I am trying to use an external library: Musicg Library.
It is an android compatible library as they claim.
Now I followed all the instructions in this post to import the jar into the android project but it doesn't recognize the classes defined the jar file.
Also I tried to follow various other posts but most of the posts are referring to keep the jar in libs folder which I have done already.
Moreover I have checked that the class inside the jar is public.
Can somebody help me in solving this problem?
Any help will be appreciated! :)
EDIT
I have already kept the .jar in the libs folder.And I couldn't resolve the problem.

You need to put the .jar file in a libs/ folder at the root of your Android project (at the same level as your AndroidManifest.xml.

Related

Android Studio import library from github where no jar file is provided

I want to use the API from Maps.Me. I've
downloaded the repository from github
extracted the files
copied the lib folder
created a libs folder as ...AndroidStudioProjects[MyApp]\app\libs
pasted the lib folder into the libs folder
The instructions on github say I should then "add the library project to [my] project". My problem is that all the advice I can find here and elsewhere online assumes that I will have a jar file which I will now see in Android Studio. I don't have a jar file and I can't see a libs folder anywhere in the Project tab on Android Studio.
(The libs folder that I have created contains the folders and files that I would expect to see in an Android Studio project folder, namely res and src folders and AndroidManifest.xml, build.gradle, build.xml and project.properties files)
What do I do next?
One thought is that I should import the downloaded library as a new project into Android Studio and then create a jar file from it. Would this work? Perhaps there is an easier way?
In case it helps anyone coming to this thread in future, I'll describe how I have worked around this issue.
As can be seen from the comments, I failed to import the library into my app in Android Studio, despite all the helpful guidance from CommonsWare. If I were more familiar with Android Studio, and Gradle specifically, I hope that I would have been able to succeed. However, I have followed a route which, for me with my limited experience of Android Studio, is more straightforward.
For each class in the downloaded repository I added a new Java class to my app with the same name.
I did not include one of the classes which included a dialog and relied on a layout and other resources, since I knew that I would not need this class
I copied all the code, except in each case for the package name, from each class in the depository and pasted it into the new classes.
I removed from the code that I did copy the one reference to the missing class
the result was code that worked exactly (so far as I know) as if I had imported the library.
Obviously, the result is inelegant, but for an app that is solely for my personal use it is good enough. It works.

Android studio create .jar file instead of .aar file

Hi I followed android documentation to create a library. But my problem is whenever I run the project means it is creating .aar file. I google it and found How to convert AAR to JAR
this. I'm using iZip Unarchiver. But it is not extracting the .aar file.
But they accepted that answer. Can any one know how to extract .jar from .aar. Thank you.
You can directly generate jar file using android studio. Here is a good tutorial for this.

How do I attach a local javadoc folder to a project without an absolute path

I am trying to attach the source for android-support-v4 and have followed the instructions from this question:
How to install javadoc for Android Compatibility Package?
This project is shared on a git repo, so I don't want to checkin a .classpath pointing to a local folder.
What is the best way to point to this javadoc on a shared project? I am open to having everyone else generate the javadoc, but I need a way to point to each person's Android SDK directory. A solution that can checked into the repository would be better though.
Is there a variable I can use in the file path pointing to the javadoc folder? I am hoping for something like this: file:/$ANDROID_SDK_DIR$/extras/android/compatibility/v4/docs/
EDIT:
I found a comment on the bug that pertains to an issue with javadocs and android libraries. I created the properties file and I can now see the javadocs in Eclipse, but I still have the same issue. The file contains an absolute path to my own Android SDK directory.
I have figured out that in the new versions of ADT, you have to include a .properties file along with your jar in the libs folder. The normal way of changing the .classpath to point to docs/sources does not work in Eclipse with ADT, but this will.
If you have GSON in a file gson-2.2.2.jar create gson-2.2.2.jar.properties in the same folder
gson-2.2.2.jar.properties:
src=docs\\gson-2.2.2-sources.jar
doc=docs\\gson-2.2.2-javadoc.jar
Then create a docs folder inside libs and move your sources and javadoc jars into it.
This solves the issue where anything in /libs is compiled into your project. Only files in the root are included, so creating a folder for your docs (/libs/docs) is a great way to handle this.
As seen in this solution, he has a third-party library in a SVN repository and he wants to associate source/javadoc with it locally in Eclipse.
I don't think there is a satisfying solution but you can try.
Check this solution,
hope it helps you.

Eclipse Import Custom Class from /src

Hey I'm having a pretty basic problem importing classes into my Eclipse based Android app. I have included the class directory into the /src directory where I figured the classes would be easily included, but Eclipse is saying it "cannot resolve the classes".
One thing I noticed is that the project folder that I included and the subfolders are just regular folder and not package folder icons. Is that a problem? If so, how do I change them to packages? This is an external git repo, so I'd rather not do anything beyond just including them in my project.
Here are some pics of how I set up the project to help:
The Activity where the error is:
Here is the package structure in the project, and the package called "android-utils" where the files I'm trying to import live:
Here is how I'm importing the files:
Btw, these classes are just some utils and I'll be improving and adding to them during the development process.
Let me know if you need any in more info to help me get these files imported the right way. Thanks!
Did you try dragging the .java files from Windows Explorer directly onto the package in Eclipse you want to put the new classes into? It should then ask to copy or link to files.
As your folder contains only java files Add them as Jar File in your Buildpath project, and your problem will be solved.
Also your jar file you can put it under the /libs folder
see this link to lean how you create jar file

How to include jar files in android library project

I am trying to use phonegap inside an android library project. The library project compiles just fine but when i try to start an activity that extends DroidGap, i get this error
01-02 10:12:17.575: W/dalvikvm(316): Unable to resolve superclass of Lcom/***/***.
I think this is because the phonegap.jar file is not included in the compiled jar file of the android library project. I have tried using ant to build but it doesn't seem to work.
Edit: I am building a android library that can be used in other android projects. I am using the standard android library project but activities in this lib project that extended DroidGap class in phonegap.jar are crashing with the above error.
I´m afraid that is not possible yet. The result jar file will contain all classes and resources defined in the android library project, but will not include external jar files added to the build path. You will have to add those to your final Android Projects using that library. You can also find similar questions in SO like this one
create one folder 'lib' in your project. put your .jar file in lib folder. select your .jar file right clicked on ,select buid path --->'add to build'. will add your .jar file. now you can use this .jar file classes.
I would suggest not making the 'lib' folder manually.
Instead:
Right click Project --> Properties --
Select Java Build Path
Make sure Libraries is the tab selected at the top
Click Add External JARs
Then find your JAR...
Basically, the same way you may have added the PhoneGap.jar
The ADT (Android Development Tool Eclipse plug-in) has built-in support for the creation and reference of library projects. See the example in section 5 of this tutorial.
Try changing the name of the folder to libs instead of lib.
have you added required permission in manifest file..
see the below links
http://docs.phonegap.com/en/1.4.0/guide_getting-started_android_index.md.html

Categories

Resources