Make a Sudoku Solver App! | How to make a Sudoku solver in Android Studio | Part 1

Поділитися
Вставка
  • Опубліковано 27 жов 2020
  • In this video, you will learn how to create an app that is capable of solving Sudoku puzzles in Android Studio using Java. This Sudoku puzzle solver will be able to solve any puzzle you put into it quickly. We will be utilizing backtracking as the core of our puzzle-solving logic.
    We will be covering some of the core functions and techniques used for app development in Android Studio. This tutorial is designed for beginners trying to get started in app development with Android devices being the primary target.
    Android Studio is a great platform for creating apps that can be deployed on the google play store. If you're new to the series I'd go and check out the Android Studio Playlist. There you will be able to see how to create basic apps so you can become a developer.
    Join the Discord Server!!!
    / discord
    Check out the Android development playlist for more videos like this!
    • Android App Developmen...
    #androidstudio #appdevelopment #PracticalCoding
  • Навчання та стиль

КОМЕНТАРІ • 74

  • @scyye-gaming
    @scyye-gaming Рік тому

    Learning the android API for fun. Just finished your calculator video, now im doing this; once i finish im moving onto the updated scientific calculator tutorial.
    ive only watched that old tutorial, and ive already learned so much. cant wait to see what these next few are going to teach!
    keep up the amazing work.
    ~~Scyye

  • @sudeyuksek8379
    @sudeyuksek8379 3 роки тому +1

    Thanks it's worth watching.You are doing pretty nice with explaining all this stuff

  • @samuelefendipurba6314
    @samuelefendipurba6314 3 роки тому +2

    Thanks man!

  • @StudyHelpBuddy
    @StudyHelpBuddy 3 роки тому

    Waiting for next part..pls upload soon

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      I'll be posting the second video sometime soon. Either Tuesday or Wednesday

  • @ahmetyildiz4646
    @ahmetyildiz4646 3 роки тому +2

    Nice person nice video. Thx.

  • @tungdinhhoang5404
    @tungdinhhoang5404 3 роки тому

    I want to highlight cell with red background when invalid entry added to the board. What should I do? Thank you so much.

  • @simongatuz
    @simongatuz 2 роки тому

    Hi my Sudoku Board is present with all the features, however it's not centered compared to yours.
    Is there a way to fix that?

  • @rajjbeast7351
    @rajjbeast7351 3 роки тому +1

    EDIT: Now my issue is, I can't get the sudoku square at 12:55 to be centered, the edges are going straight to the borders, and cleaning/rebuilding is not helping, how can this be fixed?
    When you started this project did you select "empty activity"? I don't have any compile errors when I rebuild, but nothing shows up for me at the 12:55 mark :( Also, what's supposed to go in MainActivity.java? I set mine to be empty... (sorry for so many questions this is my first time making an app)

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      Yeah when I created the activity it was an "empty activity". If you're having issues with centering the Sudoku board you should be able to drag it around on the screen just by clicking and dragging it to where you want it. I would also make sure that the 4 constraints that were added in are set equal to parent and not something else.
      I think we add some code in there later in the series but I'm not 100% sure. It's been a while since I made this app.
      Let me know if you have any other questions

  • @shounokguha2433
    @shounokguha2433 2 роки тому

    onMeaure() method is not working, the view is not a square if I do this program in kotlin

  • @adityajangra9647
    @adityajangra9647 2 роки тому

    Hey I did the code and it is showing no errors but when i run it nothing is visible on my screen
    hope you can help me with it

  • @mugdhapendse6141
    @mugdhapendse6141 3 роки тому +2

    When I write all this code in the class that we've created, a grey box appears saying "com.example....Sudoku board" and I can't see/ write the code further once this box appears, it's a great tutorial and there's more code to be written , but I'm stuck here, any solution for this?

    • @PracticalCoding
      @PracticalCoding  3 роки тому +1

      Wait so you can't write any more code in the class?? Can you send me a picture of what you're seeing on Instagram? I have my account linked on this channels homepage

  • @ashokg5878
    @ashokg5878 2 роки тому +1

    Hi, thank you for your coding videos.
    I'm trying to add some functions to the code but couldn't succeed. Could you please help me in this regard.
    I made auto fill some cells to the board to solve remaining empty cells. I'm trying to add some functions to the game as below:
    1) How to erase entered cell number in empty box(unlocked) - I tried to write code but when I click erase button the already filled(locked) cells also erasing on cell selection.
    2) How to implement Undo and Redo on button clicks - I tried using Arraylist but I couldn't succeed.
    3) How to implement Hints for empty cells.
    Please help me and try to make a video on this that would be very helpful. I have been trying to get them for last few days and finally I decided to get help from you. Looking forward for help..
    Once again your explanation and videos are excellent and thank you for your support.

    • @PracticalCoding
      @PracticalCoding  2 роки тому

      Hey sorry for the late reply I had finals and just got back from vacation. If I remember correctly, you should already be able to erase cells with values in them. If you click the same number twice, it removes the number from the board. You could copy that same approach.
      With the undo and redo, you'll need to save previous states somewhere in the code. I would maybe consider making an ArrayList that stores 2D arrays of each gameboard after the user types in a new value. you need to go back, you can pull the previous state from the ArrayList.
      And I'm not sure about the hints. It kind of depends on what you're looking for. You could have the program solve the board and give the user a value for a random cell

    • @ashokg5878
      @ashokg5878 Рік тому

      Hi @Practical Coding hope you are doing well and thank you for your response. I've implemented all points and looking for notes part(like pencil marks) to enter in a cell. My request, could you please make a video on the notes or give me some suggestion, it helps me a lot as I'm unable to do and have been trying it for last few days to implement notes in a selected cell but no luck. I had posted about it on stackoverflow and you can search it for more information - How to enter Sudoku game notes in a 9x9 cell - Android studio

  • @user-ww2zq2np2o
    @user-ww2zq2np2o 9 місяців тому +1

    This presentation is terrific. My exact copy of its program code fails. I would like to complete this course. As usual some hidden IDE complexity might be the problem. The XML Design feature did not work. It disregarded the “custom” entry and added XML for screen coordinate. Entering the XML code provided forced the Sudoku matrix to appear on the Split panel. The SudokuBoard class path is marked red as an error with a message of: “NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts. does not set the required layout_width attribute: Set to wrap_content, Set to match_parent”

    • @user-ww2zq2np2o
      @user-ww2zq2np2o 9 місяців тому

      The answer was simple. Finding it to took time. Just adding the following statements to the XML cleared the error. The program worked!
      android:layout_width="match_parent"
      android:layout_height="match_parent"

  • @vinyldragon
    @vinyldragon 3 роки тому +4

    Hi everyone I had a really annoying time with this so just in case anyone is having the same issue: I'm not sure if something has changed since this video was posted but I had no preview/display of the class. just a com.example.... and a wrench.
    in onMeasure, getWidth() and getHeight() cannot resolve until render, which is after this method is called so what you actually need there is Resources.getSystem().getDisplayMetrics().widthPixels; and heightPixels.

  • @ranindu3885
    @ranindu3885 2 роки тому +1

    Bro, I'm not getting a square for like @13:10 . Android studio is asking me to put height and width attributes to my View in the xml file.(asking to hard code them). I tried the clean & rebuild trick but still the same results.

    • @bekjanomirzak224
      @bekjanomirzak224 2 роки тому

      Did you solve this problem?

    • @bekjanomirzak224
      @bekjanomirzak224 2 роки тому +1

      I solved it by removing this from this.width this.height

    • @ranindu3885
      @ranindu3885 2 роки тому

      @@bekjanomirzak224 yeah, I solved it the same way

    • @ptb1243
      @ptb1243 Рік тому +3

      had to add
      android:layout_width="0dp"
      android:layout_height="0dp"
      custom:layout_constraintDimensionRatio="1:1"
      prior to his code to get a square

    • @sam1286
      @sam1286 Рік тому

      @@ptb1243 bro you are a life saver thank you

  • @hiddlestontom3837
    @hiddlestontom3837 2 роки тому

    The video is awesome but i'm just starting to learn and am having a bit of trouble, is there somewhere we can get the source code for this exercise? Thank you

  • @yashiprasad2906
    @yashiprasad2906 3 роки тому

    I am not able to get the row and column grid, what is the solution?

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      I'm gonna need a little more than that. I think it'd be helpful if you joined this channel's Discord server and asked your question there. Then you can send pictures and videos of the issue
      Here's the link
      discord.gg/H2P89STbaS

  • @tallerfrodo1262
    @tallerfrodo1262 3 роки тому

    1:07
    I have only one folder named com.example.sudokusolver in the Java folder... how important is it for the rest of this tutorial?

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      The name of those folders doesn't matter as long as you have the main activity java file. I just have my files named differently by default. When I add in the new class, you'll just right click on the folder you have named "sudokusolver"

    • @tallerfrodo1262
      @tallerfrodo1262 3 роки тому

      Thank you..
      But I also have a problem creating the board. Instead of creating a square it doesn't do anything and it sticks to the left

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      @@tallerfrodo1262 Have you tried cleaning and rebuilding your project? Sometimes Android Studio won't update the lines we draw in the preview without doing that.

    • @tallerfrodo1262
      @tallerfrodo1262 3 роки тому

      yes...

    • @tallerfrodo1262
      @tallerfrodo1262 3 роки тому

      but then I found in the comments someone called Parv Gakhar and his solution solved my problem...so thank you Jason for the quick answers and thanks to Parv for his solution

  • @ahmetyildiz4646
    @ahmetyildiz4646 3 роки тому

    Hello my friend, How can I change the board color with the menu in the emulator. I created the setter method of the board color. I am doing gameboard.setColor (R.color.accent) inside the menu item in mainActivity but it does not work. I need to make a change in the SudokuBoard class, but I can't. Please help. thank you so much
    Hava a nice days.

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      Since we created a custom view, you're going to have to run the onDraw method for the Sudoku board when you want to change the color. When are you trying to change the color of the board?

    • @ahmetyildiz4646
      @ahmetyildiz4646 3 роки тому

      @@PracticalCoding actually i wrote the essays i made in the first message. When I run the application on the emulator, I want to change the board color to other colors via a button or a menu. I created a setter method called Sudoku Board class public void setBoardColor (int boardColor) {this.boardColor = boardColor;}. Then I added a menu to the activity_main.xml file. I inflated this menu to MainActivity. switch (item.getItemId ()) ( case R.id.actions_first: gameboard.setBoardColor (R.color.accent); returun true; case R.id.actions_second: gameboard.setBoardColor (R.color. # FFFF67); return true; default: false } I did but it doesn't work. Where should I define different colors? what i do is either i am doing something missing or it is not right. precious human thanks

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      @@ahmetyildiz4646 When you click the button in your menu, are you running the invalidate() method on our sudoku board view? It would be something like this gameBoard.invalidate();

    • @ahmetyildiz4646
      @ahmetyildiz4646 3 роки тому

      @@PracticalCoding thanks for help bro

  • @GenericNametag
    @GenericNametag 3 роки тому

    I'm not getting that sqaure, even after rebuild/clean

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      Okay lets see if we can get this fixed for you. There are a few things that we can check. To start off can you pate in the code you're using in the onMeasure method so I can see what you have there?

    • @saarthakkhandelwal4256
      @saarthakkhandelwal4256 2 роки тому

      @@PracticalCoding protected void onMeasure(int width,int height)

  • @psycovenom9116
    @psycovenom9116 3 роки тому +1

    i followed everything but i cant get the square all i am getting is a small dot on the center left of my screen.

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      Did you clean and rebuild your project when you created the sudoku board view?

    • @psycovenom9116
      @psycovenom9116 3 роки тому

      @@PracticalCoding yes i did, i later had exams so i didnt revisit the project. I will be starting again today hope it doesnt repeat

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      @@psycovenom9116 Sounds good! let me know how it goes

    • @psycovenom9116
      @psycovenom9116 3 роки тому

      @@PracticalCoding I made the board. Everything seems to go smoothly. Thank you for making these videos so we can learn :D

    • @HimanshuSingh-ys8rg
      @HimanshuSingh-ys8rg 2 роки тому

      @@PracticalCoding after following this part my app crashes in the avd of android studio. But the board preview is ok and the also gets compiled successfully. But app wont start.

  • @user-bo6mh4fe2f
    @user-bo6mh4fe2f Рік тому

    Java or Kotlin??

  • @mertbuyuk2770
    @mertbuyuk2770 3 роки тому

    Bro firstly thanks for tutorial. But something wrong or not working ı think. Its not drawing anything or not showing i didnt get. And i didnt get whats the problem

    • @PracticalCoding
      @PracticalCoding  3 роки тому +1

      There's a few things we can do to try and fix this. The first and most common error is forgetting to rebuild your project. To do that, go to the top tool bar and look for the button that says build. Click that and a dropdown menu should appear. You're looking for the button towards the bottom. If I remember correctly, it says "Rebuild Project". If you click that and it still doesn't appear, I would try to clean and then rebuild the project. The clean project button is in the same dropdown and should be about 2 buttons up from the rebuild project button. Click the clean project button first, then rebuild.
      Let me know if both of those don't work. There's still a few more things we can check

    • @Instantcrypt
      @Instantcrypt 3 роки тому

      @@PracticalCoding but don't work..

    • @PracticalCoding
      @PracticalCoding  3 роки тому

      @@Instantcrypt Are you having trouble getting the board to show up too?

    • @saarthakkhandelwal4256
      @saarthakkhandelwal4256 2 роки тому

      @@PracticalCoding I am just getting a small dot in the left center
      with layout_width=0dp and layout_height=0dp automatically

    • @PracticalCoding
      @PracticalCoding  2 роки тому

      @@saarthakkhandelwal4256 Did you get it fixed by using protected? I saw your other comment about it

  • @noashaw2787
    @noashaw2787 2 роки тому

    Hi, I am following your video tutorial and I have a problem with creating a square.When I move to the xml page these are the errors i got:
    Cannot resolve class com.example.sudokutry2.SudokuBorad*
    I cleaned and rebuilt the project but this did not solve the issue.
    Thanks in advance for your support!

    • @PracticalCoding
      @PracticalCoding  2 роки тому

      Could you join the Discord server? It's a lot easier to help solve these issues when I can see what you're looking at

  • @johnniegilkerson4724
    @johnniegilkerson4724 Рік тому

    getting error in activity_main.xml: layout_height' attribute should be defined
    'layout_width' attribute should be defined
    Element com.johnnie.sudokusolver.SudokuBoard doesn't have required attribute android:layout_height
    Element com.johnnie.sudokusolver.SudokuBoard doesn't have required attribute android:layout_width
    everything is the same

    • @kawtharabuesmail9374
      @kawtharabuesmail9374 Рік тому

      I have the same issue ..
      let me know if you solve it.. thanks

    • @betul9301
      @betul9301 Рік тому

      I had the same issue. If you couldn't solve it, let me tell you. First, i wrote these temporarily: android:layout_height="match_parent"
      android:layout_width="match_parent".
      After, i did everything same as him. Later, i noticed his code is like @20:02 :
      android:layout_height="wrap_content"
      android:layout_width="wrap_content".
      And i wrote these lines at the end. So it solved. I hope this will be useful for you.