I am an Android developer. In my project (app) I use third party software (ex: Glide image loader library) to save some time and improve my app performance. Now I read this and I was able to understand how to give credits to the library, something like this:

Rules to license a third party library used in my app

I should have a license link in my settings page, that takes you to see each used library and the license for each one.

This seems straight forward and easy to understand.


Some times instead of including the whole library in my app, I may want to use a portion of the open source library code (ex: 3 or 4 functions of code). Keeping in mind that the license is Apache 2.0, I want to know how to license some parts of code that are included in my app (but not written by me).

Some questions said that I must comment beside the code pieces that are not written by me (from where I took them, modifications that I did to them).

My question about the problem

Why should we comment beside the code (I mean who would read them), and lets say I did comment and stated changes, and then before releasing my app to the store I use (pro guard) to protect my code. ((But wait, as pro guard removes all comments then what is the purpose of adding comments)).


Let's say this is my file where I use my code and some code from and apache 2.0 licensed library:

   // 1: Licensed under EXAMPLE........

   private void MyCode1(){



    private void MyCode2(){



     //2: this was used from this link (....), and I modified the first line. . .... 

     private void CopiedCode1(){


     //3: this was used from this link (...), and I modified the third and second line to .........

     private void CopiedCode2(){ 


1: comment stands for file header.

2: comment stands for some copied method from an open source code.

3: comment stands for some another copied method from an open source code.

Let's say methods are copied from this.

Is this the way to license? If yes, is it efficient? If no, then how?

  • 1
    "I may want to use a portion of the open source library code (ex: 3 or 4 functions of code)." - The copyright words for this are "derivative work." If you look in the section "Redistribution" of apache.org/licenses/LICENSE-2.0 it tells you exactly what you have to do. Basically, you retain the original copyright notice and state what you changed (i.e. you just use the functions you want and state this fact; that is your derivative work). For convenience, you may want to put it in a separate file, but that is not required.
    – Brandin
    Feb 16 '18 at 8:09
  • @Brandin Which one is a derivative work (using methods of code as is) or (modifying some parts of the methods to something else)? And where should I state where I took the code from (comment) or (somewhere else)? Feb 16 '18 at 8:36
  • @Brandin how do I state from where I took the code (comment or something else). Feb 16 '18 at 9:09
  • Using 3 or 4 functions is equivalent to copying the file, and then deleting everything except for the 3 or 4 functions you want. The resulting shorter file is a derivative work. According to the Apache license, you need only retain the copyright notice, which already says where it is from. You could add a comment such as "Modified to remove unneeded functions."
    – Brandin
    Feb 16 '18 at 9:15
  • @Brandin "you need only retain the copyright notice" what is the copyright ? where do I add it? Sometimes to protect our code we use pro guard which deletes all comments in all files, then how to comment the pieces used in my code? And I am curious to know who reads the files and who check the comments (If I am releasing a free commercial app to play store). Feb 16 '18 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.