Open source License in Android App - android

We have an android application and are using some third party licenses. What is the best place to include these licenses in the app? In iOS we include it in the setting bundle, but I am not sure the best place to do so in android.
Thanks for you help

For my apps I generally place the license .txt file in the assets directory. Read the Github (I generally use library from github) page thoroughly about licencing. Notify the original creator about the use of his library. Then, if the product is of a client I will ask if to include the creator with link in the about section(if there is one). In my own apps I will include the link and author in the about section somewhere in my app.

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.
This is also explained at adding-a-library-jar-to-an-eclipse-android-project.

Related

How to include external libs in Android source controlled project?

How should external libraries be included into Android projects?
I see this documentation from Google:
http://developer.android.com/tools/support-library/setup.html#libs-with-res
...which says they should be kept outside the source tree for the project, and referenced as dependencies.
The guide for Facebook libraries says the same thing:
https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/
What about when the project is going into source control, and will be worked on by multiple developers? Is it possible to be sure other developers will have the correct versions of libraries if they're not included in source control?
It seems as though it might be better to check in the whole tree of these external libraries under say an "external" folder in the project and then reference them as libraries from there? The above links don't say this is wrong, but is there any reason not to do that?
I could not find anything against this approach, but maybe my search skills are off.
Thanks!
You have basically tree options (referring to git):
Putting the source or binaries into your git repository.
You can create/clone extra repositories and link these as submodule into your main repository.
Use gradle/android-studio to maintain remote binary dependencies.
In my opinion, option 3. is the best. It speeds up build time and reduces the date saved in your internal repository. Referencing most open source projects, googles libraries and even the Facebook API is just a one liner in your build.gradle file.
For internal libraries or anything not uploaded to some maven repository, you can create a local maven repository and link that.
And in the end, you have the option 2. to create a library submodule within git and gradle to handle it efficiently.
If you want to stick to eclipse + ant, try 2. first.
At least ant will work out of the box for building all things.
Setting up eclipse is a bit more difficult but can be done.
Option 1. is easy to implement, but It might get messy at some point.
Copy jar file in android project libs forlder and right click on jar file and click on bulid path-> add to build path.
If you want to add jar file then copy your jar file and put in to libs folder, and if you want to add external library then import your library project go to project properties and select android tab and add external library with add button.

Creating jar Library of Android project?

I have a project that uses some resources.I want to create a library from it and publish it.I create a jar file with export option of eclipse,but it did not work.Then I search the we b and it seems that way works if and only if project does not use resources.But I saw this post.Here CommonsWare saya there is a way to create a jar file from a project that uses resources.But that answer has two link that do not open any page on the web and I could not test CommonsWare's answer.So my question is:
Is there any way to create jar library file from project that uses resources?
Note:
I read docs that say:
If you have source code and resources that are common to multiple
Android projects, you can move them to a library project so that it is
easier to maintain across applications and versions.
But as I said before,I want to publish my jar and docs say we can not create jar file from library project.And so I can not publish it.
Here CommonsWare saya there is a way to create a jar file from a project that uses resources.
Not in that answer. You can tell that by actually reading the answer.
But that answer has two link that do not open any page on the web
Sorry, Google reorganized their site and broke the original links. The answer has been updated with current links.
Is there any way to create jar library file from project that uses resources?
No.
You can create an Android library project that includes a JAR instead of Java source code. AFAIK, this recipe still works:
Create an Android library project, with your source code, resources, and such, and get it working
Compile the Java source (e.g., via Ant) and turn it into a JAR file
Create a copy of your original Android library project to serve as a distribution Android library project
Place the compiled JAR from step #2 and put it in libs/ of the distribution library project from step #3.
Delete everything in src/ of the distribution library project (but leave the now-empty src/ directory there)
Distribute the distribution library project (e.g., ZIP it up)
And the new Gradle-based build system supports the AAR package for distributing libraries and such, though I have not played with this yet.

R cannot be resolved into a variable when integrating two packages

i try to integrate Twitter project to Facebook project by copying and paste all the relevant files and clean the integration project. However, in the GEN file(R.java and BuildConfig.java) the twitter packages is deleted. it seems like the GEN file can only be generated for one packages in SRC.
Correct, there is just one R file. You have several options though. You probably could leave the Twitter and Facebook in their individual projects (instead of copying them into your project), and add them via the Android Library system. Or, you would need to copy all the class files, plus all the resource files and any other required files. (I expect that the resource files weren't copied, and thus not included in the project R file).
Personally, I'd recommend the first method. Just add each project (Twitter and Facebook) to Eclipse. Then right-click and select Properties. Choose the Android section, and in the lower half of the panel, check "Is Library". In your project, right-click on it and select Properties, then Android. In the lower half, (same location as the "Is Library") select Add and add your Twitter and Facebook projects. That should include them in the build for your project, including any R files they might have!
Update (Activities in Library projects):
Check the "Declaring library components in the manifest file" section of the Library section. Essentially, you'll need to declare all the Activities, etc, in YOUR project's manifest. You'd still link the libraries as described. (There's also a more detailed explanation of how to configure the libraries at that link as well!)

How to include library projects

I have a working app and now wish to include an advertising system by mopub. Looking at their getting started guide it says I should fist extract a "library project" (I'm not even sure what that is) using git. After having done that I now see that I have a directory called mopub-android-sdk inside this directory are a tree of further files and subdirectories.
The guide then states "Make sure the Android SDK files are in the same parent folder as your project"... this is where I'm confused. I have all my source files, androidmanifest etc in a directory c:\android\mygame am I now supposed to put mopub-android-sdk and all its sub-tree inside c:\android? or inside c:\android\mygame? (or somewhere else?)
EDIT: Some answers/comments have discussed the idea of converting the library project into a .jar file and then putting that in my libs directory... I have no objection to this so long as someone tells me there are no disadvantages to this compared to not making a jar - thinking about it more, wouldn't the jar have to include every single function, whereas if I left it as a library project, the compiler may be able to omit unused code?
EDIT: Now I am getting more sceptical about the make-jar-then-put-in-libs approach. I found mopub-android-sdk.jar in the bin\res directory and copied it to my projects libs directory. The ad system seemed to work fine, except in the location on screen where I expect to see a specific icon (to dismiss the full screen ad) there is a junk image. I noticed that amongst the tree of files beneath mopub-android-sdk there is a res directory containing png files. I suspect that these images are not in the jar file.
If you're simply including a *.jar library, put it in the libs/ folder of your project.
If you're trying to include an entire project...
Right click the project you want it to be included into and go to properties. On the left side where there are tabs, select "Android". In the area that says "Library" press the "Add..." button and then select the project you want to include. Do a clean build of your project.
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.)

how to define jar files and libraries in eclipse indigo?

I am trying to compile a java project which makes uses of android libraries. The project I am using is checked out from a svn repository.
In order to take a use of that project I am required to define some jar files and libraries for that project.
Here are the files that I need to make sure they are defined:
•"lib/apache-mime4j-0.4.jar" : Jar
•"lib/httpmime-4.0-beta1.jar" : Jar
•"lib/slf4j-android-1.5.8.jar" : Jar
•"JUnit 4.libraryclasspath" : Library
•"ANDROID_SDK_PLATFORM/android.jar" : var
•"Java JRE System Library" : Library
Does anyone have any idea about what should I do to define these files? I am a noob here.I do not know which selection should I choose When I clicked "project -> properties -> java build path -> libraries"
For example if I want to define the first jar file, there are a "add external jar" and a "add libraries" selections.
However you can see a "lib" here in front of the "apache-mime4j0.4.jar file" in this list above..
So I don't understand if it is asking me to add a jar file or the librabry.. I am getting very confused about this.
And also How can I do anything with "JUnit 4.libraryclasspath" file? I think it is a classpath file so I cannot either choose "add jar files" or "add libraries" to define it..
Hope someone has any knowledge about this and I will be very appreciated!
I think You are unable to include the files due to SVN path but will discuss it later.At first we look how to add jar files
Right click on your project in which you want to add the jars
1.select build path and then "configure build path"
2.click on "Libraries" tab
3.Now click on Add external jars (as your all jars files would be placed in some directory outside the project folder or anywhere else)
4.Select these jars and now do OK ... Now these jars are in your class path and you can use these files.
Now another thing, As You told that you are using svn , It means many of other developers are also using the same project then it is compulsory that all of you have same path of jars in your systems for instance in Dev1 PC the jar if the jar file is placed in d:/lib/jars folder then all other DEV2 , DEV3 ... DEVn must have d:/lib/jars folder and their jars must be placed there and you have to add these jars from d:/libs/jars
Last thing , If you are still unable to understand the solution and remove the bugs then simply do this.
Copy all jar files manually (ctrl+c) and copy to lib folder in your project as i have seen that in your project the person who commits the code place them there.
after then , right click on your project and click refresh(as it is bad practice to put jar files in project by creating folder like lib etc unless it is a web project)
Let me know if anything is unclear about this

Categories

Resources