How to merge an Android application with a library - android

My question is: How can I merge an Android app with a library? I have only one application left which refers to this library so I want to combine them and get rid of that library.
Are there any "tools" which I could use? Or is possible to merge them "manually" anyway?
The Android Developers Site and Google couldn't help me and my various attempts to fix it by hand failed as well so I'm thankful for any advice or hint.

Create a jar of this library and put it inside the libs/ folder of your application

see if u want create library right click that project->properties->android and tick is library and click apply button. then in your main android app right click project=>properties->android->add and select that library project and goto java build path goto projects and add library project->ok. Now library project is merged with your project.

Right click on project.Select properties->Android.In that go to "Library" section and click on "Add".It will show you the list of libraries available.Select the one you want to merge.

Related

Add as an library to main project

Basically I want to add one of my project as an library to my main project.
Because my main project refer some classes of other project.
But as normal way I can't able to do that. So I am giving here details regarding that.
My motto is to use classes of other project. That's it.
Here in image, BaseGameUtils is my library project and Smove-android is my main game project.
But when I try to add it into actual project, I can't able to see in library section.
Now please give me some suggestion in this. I want to use classes of library project.
EDIT : Library project build.gradle file.
right click the library you want to add->properties->
under "Android" section check "Is Library" checkbox.
apply and save.
then follow how you normally add a library project to your app.

why my App has two manifest files

I opened android project in android studio and I found that that project contains two manifest files as shown below in the image.
the first manifest contains the activities in the projects while the other manifest contains the permissions!!
please let me know how that is possible and why??
Note: I used to work with eclipse and I have not seen that feature before
image-,
If you look at the directory structure you see two projects: your app and a library project. So one Manifest-file is for your App and the other is for your the Library-project.
The screenshot you have attached shows that you have been created a project and then added a library file for support. Remove the library if you don't need of that.
Right click on project->Build Path->Configure Build Path->Library
Select that library and remove. Now check your project.

Issue with support library setup as per android developer guide using Eclipse

I've been through all of the subjects and all over Internet to try solving this problem, but can't seem to find any solution.
Basically I've followed every step here Support Library Setup - Adding libraries with resources, but can't figure out the last one.
Add the library to your application project:
In the Project Explorer, right-click your project and select Properties.
In the Library pane, click Add.
Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
In the properties window, click OK.
Now the problem is in library pane I see multiple add options (Add JARs, Add External JARs, Add Variable, Add Library Add Class Folder and Add External Class Folder)
Can anyone give me a bit more detailed explanation what I actually need to add?
The only place I see only Add option is "Projects" pane.
Cheers,
DP
This is to add a library that u got to your android application. So you can publish your app with the library to use it.
Like Actionbar sherlock, angEngine, admob or any other library.
To let your application support it, you should add it to it's project first.
And best way is to choose Add External JARS, or anything you would like.
First import the library into your workspace (where your androi project is). Import the library to eclipse. It is found under /sdk/extras/android/support/v7/appcompact.
Right click on your android project. Goto properties. Choose android. Click Add browse and add reference the same in your android project
Click add browse and add the library project
When you add it looks like below
Do it the easy way : right click your project folder in the Package Explorer or Navigator, then look for Android Tools > Add Support Library. A dialog with open to ask you to accept the license. Accept, click Install, and you're good to go ;-)

Can’t link Android projects in Eclipse

I can’t link Android projects in Eclipse.
I get a VerifyError, and some can’t find class warnings, which I assume means that it’s not getting the library.
I’m using project properties > Java Build Path > Projects.
I can get it to work by referencing the other projects jar. Then setting the source attach so that I can step through the code, but this is a much uglier way of setting the projects up because linking to source and linking to the jar doesn’t allow the use of path variables. So the next person to pick up this project is going to be really confused when the project doesn’t work for them.
Is it possible to directly link projects?
Is it possible to use path variables to reference jars and source
attachments?
It’s so easy to do in Flash Builder…
Also, when I change anything in properties > Android then hit okay, when I open properties > Android the changes have been reverted, what's that about?
If you are asking if an android project can reference a "library" project, the answer is yes; open the properties for the main android project and select Android menu and then at the bottom half of the screen, you can Add your library project to your main project. Note that the "library" project should be set as a library project (same UI allows you to set a project as library)
HTH,
Ali.
assuming you're talking about a library project that you have in your eclipse workspace.
go to properties -> Android
on the bottom half of the screen you should see a "Library" pane.
click add and point it to your library that's in your workspace that you want to add.
click apply afterwards.
i'd remove what you added in that library pane that you're talking about. that's for jar libraries that you've added to your project's libs folder.

Adding a library/JAR to an Eclipse Android project

This is a two-part question about adding a third-party library (JAR) to an Android project in Eclipse.
The first part of the question is, when I try to add a third-party JAR (library) to my Android project I first get the problem of
Error parsing XML: unbound prefix
because I'm trying to use a class from that JAR (and need the prefix somehow defined). What's going on?
Second, (after fixing that--the answer is given below), my application doesn't work on Android and I discover via the debugger (LogCat) that the class I'm attempting to consume doesn't exist.
Caused by:
java.lang.ClassNotFoundException:
com.github.droidfu.widgets.WebImageView...
Why, when I get no compilation or linker error in Eclipse, does it have this problem on the emulator?
These two questions are rhetorical for I'm going to answer them myself below. Other posts in this forum creep up to the problem and elsewhere there is discussion, but I feel that I can be more explicitly helpful for the next guy to come along.
Now for the missing class problem.
I'm an Eclipse Java EE developer and have been in the habit for many years of adding third-party libraries via the "User Library" mechanism in Build Path. Of course, there are at least 3 ways to add a third-party library, the one I use is the most elegant, in my humble opinion.
This will not work, however, for Android, whose Dalvik "JVM" cannot handle an ordinary Java-compiled class, but must have it converted to a special format. This does not happen when you add a library in the way I'm wont to do it.
Instead, follow the (widely available) instructions for importing the third-party library, then adding it using Build Path (which makes it known to Eclipse for compilation purposes). Here is the step-by-step:
Download the library to your host
development system.
Create a new folder, libs, in
your Eclipse/Android project.
Right-click libs and choose
Import -> General -> File System,
then Next, Browse in the filesystem
to find the library's parent
directory (i.e.: where you
downloaded it to).
Click OK, then click the
directory name (not the checkbox) in
the left pane, then check the
relevant JAR in the right pane. This
puts the library into your project
(physically).
Right-click on your project,
choose Build Path -> Configure Build
Path, then click the Libraries tab,
then Add JARs..., navigate to your
new JAR in the libs directory and
add it. (This, incidentally, is the moment at which your new JAR is converted for use on Android.)
NOTE
Step 5 may not be needed, if the lib is already included in your build path. Just ensure that its existence first before adding it.
What you've done here accomplishes two things:
Includes a Dalvik-converted JAR
in your Android project.
Makes Java definitions available
to Eclipse in order to find the
third-party classes when developing (that is, compiling)
your project's source code.
Ensure that your 3rd party jars are in your projects "libs" folder and they will be put in the .apk when you package your application. You may see runtime errors on the device if something in the jar is not supported, but other than that I have had great success with this.
Setting up a Library Project
A library project is a standard Android project, so you can create a new one in the same way as you would a new application project.
When you are creating the library project, you can select any application name, package, and set other fields as needed, as shown in figure 1.
Next, set the project's properties to indicate that it is a library project:
In the Package Explorer, right-click the library project and select Properties.
In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
Select the "is Library" checkbox and click Apply.
Click OK to close the Properties window.
The new project is now marked as a library project. You can begin moving source code and resources into it, as described in the sections below.
If you are using the ADT version 22, you need to check the android dependencies and android private libraries in the order&Export tab in the project build path
First, the problem of the missing prefix.
If you consume something in your layout file that comes from a third party, you may need to consume its prefix as well, something like "droidfu:" which occurs in several places in the XML construct below:
<com.github.droidfu.widgets.WebImageView android:id="#+id/webimage"
android:layout_width="75dip"
android:layout_height="75dip"
android:background="#CCC"
droidfu:autoLoad="true"
droidfu:imageUrl="http://www.android.com/images/opensourceprojec.gif"
droidfu:progressDrawable="..."
/>
This comes out of the JAR, but you'll also need to add the new "xmlns:droidfu"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:droidfu="http://github.com/droidfu/schema"
...>
or you get the unbound prefix error. For me, this was a failure to copy and paste all of the supplied example from the third-party library's pages.
Error parsing XML: unbound prefix
Resource '/playteddy/res' does not exist.
I got the above two errors and finally I solved it.
Right click your project -> properties -> java build path -> googleadmobadsdk (select and put it top), then you run and problem solved. It is solved my runtime error.
Put the source in a folder outside yourt workspace.
Rightclick in the project-explorer, and select "Import..."
Import the project in your workspace as an Android project.
Try to build it, and make sure it is marked as a library project.
Also make sure it is build with Google API support, if not you will get compile errors.
Then, in right click on your main project in the project explorer.
Select properties, then select Android on the left.
In the library section below, click "Add"..
The mapview-balloons library should now be available to add to your project..
Go to build path in eclipse, then click order and export, then check the library/jar, and then click the up button to move it to the top of the list to compile it first.

Categories

Resources