89 Replies to “Memory Game – Android Application”

    • Are you sure?
      I have just download the source code and saw it.
      Please check again.
      If there is still a problem, leave me your email and I will send it to you.

      • Hi,

        I tried to download a source code and build the game but it gives
        the same error. Can you please email me zipped folder ?



      • Hi, i downloaded this source code but it is showing some errors in Manager.java file,
        I am a fresher to android gaming apps.

        please send me the executable source code of this application, It will help me a lot.

  1. Hi, Thanks for posting this game code. This was really helpful. I was trying to add some more functionality to this code like show all cards by clicking a button, so I was wondering if you could help me with that.

    I am very new to programming so your help will be highly appreciated.

    Thanks in advance!

  2. Hi…I’m new to JAVA for Android…
    For my sch project, i decided to do a memory game.
    i have decided to use ur source code..however, there is no error but when i run it in sdk-android, the game force close..
    plz help !!!

  3. hi i was looking at this code, pretty good , really really good, ive been peeking and poking it , and was wondering how would one make the pictures have certain space on the phone, what i mean is , having them cover all the screen of the phone in land and port mode, having them separated by certain amount of space

  4. There was an error on ArrayAdapter statement and import java.util.regex.Pattern;

    Could you help me please? Thx! 🙂

    • Hi rizky,
      java.util.regex.Pattern is a standard import, there shouldn’t be a problem with it- try cleaning your project.

      Send me the error message of the ArrayAdapter .

      • The error message: ArrayAdapter is a raw type. References to generic type ArrayAdapter should be parameterized

        What should i do?

  5. Thank you !! it’s very usefull !!

    However i have one question about your “Manager.java” :
    In which part of the code, do you duplicate the different image ??

    thx again

    • I am not sure I understood the question but i’ll try to help.

      in loadCards() I create a list of sorted numbers according to the number of the cards.
      Than I pull them one by one in random order and order them in a matrix according to the cards on the table
      but first I divide the number by 2 so that each 2 cards on the table will hold the number.

      Now look at the function turnCard() – when a user click on a card I take the image
      according to the number it holds. This is how 2 cards on the table hold the same image.

      Does that answer your question?

        • I have an other question, 🙂
          If i want to change this line : if(cards[seconedCard.x][seconedCard.y] == cards[firstCard.x][firstCard.y]){ …
          by on other which chek if, for example, an apple and a banana are found on the same turn, and then those cards become invisible … How should i do ?
          Maybe : if(cards[seconedCard.x][seconedCard.y] == R.drawable.card1 && cards[firstCard.x][firstCard.y] == R.drawable.card2) { …
          or something like that ??

          I hope that it’s rather understandable !


  6. Great sample! I am modifying this to have some pics my son likes, but I noticed an issue with large resolution screens. In Droid phones it works great, but on my 2.2 pad if you empty a row of cards via matching, the layout shrinks and new cards you turn over are resized…basically, smashed. I can rework the code to use fixed sized containers for each card/cell, but I’d rather not if you already saw it and resolved it. Again, thanks for this code, it is a great way to start customizing my own similar game.

  7. There are some errors:
    1. The method onClick(View) of type Manager.ButtonListener must override a superclass method
    2. The method onItemSelected(AdapterView, View, int, long) of type new AdapterView.OnItemSelectedListener(){} must override a superclass method
    3. The method onNothingSelected(AdapterView) of type new AdapterView.OnItemSelectedListener(){} must override a superclass method

    • Hi lones,
      I have just downloaded the project and imported it into my eclipse.
      It compiles and run as it should.
      Here’s a suggestion, try cleaning your project in eclipse, see if that’s help.
      Also, make sure you havent got any environment related problems.
      Do you have problems with some of the imports?

  8. Hi

    Thanks for your source code, but I have a problem when I next started eclipse..

    I have a problem with arrayAdapter, eclipse give me two option
    1. Create field “array” in R tipe
    2. Create constant “array” in R tipe

    What I have todo…?

    Thanks again..

    • Ignore the suggestions from eclipse, they are not good.

      Make sure you have added all the files from my project (including all the files under the ‘res’ folder).
      Try cleaning the project in eclipse.
      Is that helps?

  9. Hey. Thanks for the code! 🙂 It works perfectly fine. But can you explain me why do you use “log” in your program? I don’t understand what it is used for. Also suggest me links where I can find material to read about it.

  10. Log is a tool for developers to print messages and parameters values while the program is running.
    Let’s say for example you would like to see the value of parameter X in diffrent times of the program, than you can use the Log to print it’s value in diffrent times.
    The log is also used to print errors.
    All the messages are displayed in the log cat console.


  11. Don’t know why I can’t compile it back to the apk file. At first blush exerything seems to be ok but is not. File has been compiled but is not working on my HTC… Could you please help me?

  12. Hi,
    You have done excellent job. Very nice. Though I tried to build it but it did not build.
    Could you please give the working source code

  13. I tried this app..tis app is really cool….but when i run the game ,the spinner option is appearing even i selected the 4×4.i ignored it i selected the first set of cards the i selected second set of cards,the first set of cards and the spinner option is displaying again..wht do i need to do…could u plz help me out?

  14. I just downloaded this code and tried to run in eclipse. But the manager.java file has many errors which state that “cannot be resolved to the type” could you please suggest how to debug this error.

      • i have managed to debug the errors but the table rows and columns are not fitting in the emulator screen. how do i change the size could you please explain. i have changed the image sizes to 50dip but still the rows and columns are not shrinking.

  15. hmm can i ask?
    what if i when the game is finish a dialog message will appear showing the game is finish and it will also show the tries/turn he commit where do u think in the code can i insert it

  16. i have just downloaded the source code..i’ll just ask if there were any graphical layout in main.xml for the 3rd screen shot above? or it will appear automatically once the game is set,.

      • I have downloaded the source code .Its nice game.You have given a spinner that shows a dropdown and on selecting the item in the dropdown view it shows the game.But I want to the game to be shown when I click on a button such as play button.I dont want the spinner and dropdown box.What should be done?

  17. hello sir. sorry to interrupt you. can you make some explanation from the source code and the flowchart for this game? i really really need it for my homework. please send me the explanation and flowchart to my email.

    i appreciate your kindness for sharing your great work. thank you very much

  18. bana bunu kodlarını rarlayıp yollarmısın dogru bir şekilde proje ödevim için lazım da

  19. Hi,
    I really like your game it helps me understand the code within android. Just wanted to know if there is a way of making a high score table at the end of each game with information about previous top 5 high scores and if you are in the top 5 you can add your name in

  20. Can you please send me an e-mail attached with source codes of this game? The one provided by the link is not working :S

  21. Hi, how can I customize layout? I need more space between pictures. Can you help me. Thanks! 🙂

  22. I have successfully customized design. But now I have problem. I have 24 images and game bord 3×4, I need generate allways different images, but it generate allways same first 6 images. Thanks for help and sorry for bad English

  23. hi.!
    i am a beginner in eclipse and i want to create a game with 3 matching tiles of pictures like the game of bejeweled and call of atlantis in a tablet. can you send me some codes that will help me in creating that game..?
    please send it to my e-mail..thank you ..

  24. Love this code thank you! Works perfectly. Although I am trying to change the back image of the card of the image. It automatically is using my icon.png. How do I change the back of the card. I been looking for an hour now. I saw “backImage” in the main.java file. But won’t let me redirect to the drawable folder. Thanks again!

  25. firstCard = new Card(buttons,x,y); <—- this code hv error.

    No enclosing instance of type MainActivity is accessible. Must qualify the allocation with an enclosing instance of type MainActivity (e.g. x.new A() where x is an instance of MainActivity).
    this the comment that eclipse give. What shud i do?

  26. Hi! Thanks for the game!

    I just import the project and I find a lot of errors in Manager archive. How can I solve it?

    Thank you!

  27. Hi! I need your help. I am looking to build functions to continue the game, you can give me suggestions?

  28. Hi,I am a fresher to android gaming apps.
    I downloaded this source code but it is showing some errors in Manager.java file,

    please send me the source code of this application which is executable, It will help me a lot.

  29. Thanks for your source code, im using eclipse and already import it to my workspace but still showing error in manager.java (src folder) please help

  30. Hi im beginner in android apps… i just downloaded this game, but i wanna a simple configuration, that the object listener in this game is Spinner, but i try some modification with button widget, so there will be :

    Button bu = ((Button)findViewById(R.id.bt1));
    bu.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {

    but there is an error in runtime… in syntax there is no error… the error show in LogCat:
    1. java.Lang.NullPointerException
    2. android.view.View.
    3. android os handler
    4. android.os looper
    5.android app Activity.thread.main

    what should i do? can you give me a suggestions?

    thanks a lot 🙂

  31. hi u!
    i have downloaded the project and open it on eclipse.
    i tried to compile and there have some errors!
    pls help me to fix these errors,

    errors are like this:
    – The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project.
    – The type.java.lang.Object cannot be resolved.It is indirectly referenced from required .class files.

    • Hi,
      In the eclipse project properties, go to build properties.
      Fix all the errors in there.
      Make sure you JDK is defined properly in your eclipse.
      Then, clean the project.

  32. thanks a lot.
    but i still have some problems.
    i can not fix those building errors,
    i m a beginer for android, i want to learn more through this game source.
    so please help me!

    pls first tell me to create android project with your open source,
    then the ways to build project and run.
    thanks. Avi !!!

  33. Hi!
    I want a congratulation text or picture to appear after you beat the game.
    How do you do that?


Leave a Reply

Your email address will not be published.