1. Download our Official Android App: Forums for Android!

Thread Status:
Not open for further replies.

Apps PLEASE READ ME BEFORE POSTING

Discussion in 'Android Development' started by LV426, Jan 8, 2016.

  1. LV426

    LV426 Illegitimi non carborundum
    Moderator Thread Starter
    Rank:
     #23
    Points:
    1,238
    Posts:
    5,292
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    5,292
    6,907
    1,238
    Male
    Software developer
    South West of England
    Welcome to the Android Application Development forum. This forum is designed to facilitate (and hopefully provide answers to) questions regarding the design and development of Android applications and games.

    NOTES FOR BEGINNERS..

    Do I need to write an app?

    This may seem like an odd thing to start with, but it's worth thinking about, if you require cross platform compatibility. If your system needs to work on both Android and iOS, then you need to think about how to do this. An Android app written in Java isn't directly portable to iOS. Cross platform frameworks do exist, but they're not perfect for all applications. You may like to consider implementing the system as a website. This means that cross platform compatibility is guaranteed, because users access your system using the device's local web browser.

    If you decide that you really need an app, then read on..

    Android programming requires you to be familiar with the Java programming language. If you're a beginner with Java then you would be advised to pick up a good book. There are many available. Alternatively there are many online resources to get you started with the language.

    In terms of Android programming, again there are many good books, and you can also find some excellent online tutorials. Here's a good place to start:

    http://developer.android.com/training/index.html

    To begin developing Android apps, you need the JDK (Java Development Kit). Your computer may already have this installed, but if not, it's free to download. Get the latest JDK from here -

    http://www.oracle.com/technetwork/java/javase/downloads/index.html

    You will also need Android Studio. This is a powerful IDE (Integrated Development Environment), which is essential for developing Android apps. Download it from here:

    http://developer.android.com/sdk/index.html

    It actually has a lot of sample applications that are useful to examine and learn how to do things, starting with a basic 'hello world' app.

    But really, the best and most effective way to learn is just to get in there and write some code. If you have any more specific questions, feel free to ask here and you can get some more advice.
    Good luck!

    Don't do cut/paste coding without engaging your brain

    Taking code from online sources is fine, many programmers do this and it can save a lot of time. However if you're a beginner, you should not simply copy blocks of code without taking the time to understand how it works. Reason for this, and it may sound obvious, is that when things go wrong, you'll have a very difficult time working out how to fix the problems. So next time you paste a section of code into your program, ask yourself if you really understand what it's doing.

    If you have a problem, there's a lot you can do to help yourself. Read on..

    There is no better way to understand and learn, than to work through a problem. Fortunately a modern IDE like Android Studio or Eclipse provides some very powerful features to help you..

    Debugging your app

    Many people seem to use Log statements in their code to try and diagnose problems. This is far from ideal, and there is a much better way to do it, by running your app in debug mode. This will allow you to set breakpoints, examine variable values, and step through the code execution, line by line. You can follow the logic, and spot problems. Learning how to use the debug facilities of the IDE is probably *the* most useful thing you can teach yourself.

    Debugging - What's a stack trace?

    Every time your code calls a method, the stack is used. This is an area of memory which tracks what method calls have been made. Think of it like one of those pop-up plate stackers in a restaurant. Methods call other methods, which then call others, and so entries get added recursively to the stack. It gets bigger.

    When an application crashes or stops unexpectedly, it's due to a run time error. The system reports it as an 'Exception'. If the exception happened in a method which was at a deep level in the stack, then the error report unwinds all the method calls, back to the place in your code which started the sequence of method calls leading to the exception.

    The stack trace is essential in tracking down problems, because it pinpoints the exact place in your code which caused the error. This is the vital piece of information you need to understand why your application is crashing. A typical stack trace is described here

    https://developer.android.com/studio/debug/stacktraces.html

    Here's a guide to debugging with Android Studio - http://developer.android.com/tools/debugging/debugging-studio.html

    To summarise, the following are the key things which will help you diagnose and fix your problem:-

    • Read the stack trace: The Logcat window shows all diagnostic output from your application. If your app crashed unexpectedly, a stack trace will be in the Logcat, which pinpoints the exact line in your code which caused the app to crash.
      See this page for a good explanation of how to read a stack trace and use it to diagnose problems in your code. http://stackoverflow.com/questions/...w-can-i-use-it-to-debug-my-application-errors

    • Breakpoints: Running your app in debug mode (see above link) will allow you to stop execution of your code at specific lines. You can then examine variables, step through the code, and figure out what's going on.

    How to ask a question in this forum

    You are more likely to get some help if you ask focussed questions on specific issues. With very broad or open ended questions it can be difficult to answer. Please note that you are very unlikely to get a comprehensive (or any) answer to the question 'write my code for me' or 'do my homework assignment'. We wouldn't be doing you any favours by spoon feeding code to you, because you'd learn very little, to nothing.
    Similar to other technical forums, members like to see some evidence that you've put at least some effort or thought into the problem.

    If you have a coding issue that you would like advice on, please enclose your code in [code][/code] tags. This will ensure that the code is nicely formatted, indented, and easy to read. You would be surprised how many people asking a programming related question here do not include their code, or include only a small isolated fragment of code. This makes it virtually impossible to answer the question. Include all relevant code parts to allow someone to understand the problem. This includes layout XML code.

    Here's an example of nice formatted code:

    Code (Text):
    1.  
    2. public class MainActivityextendsActivity{
    3.  
    4.    @Override
    5.    publicvoid onCreate(Bundle savedInstanceState){
    6.       super.onCreate(savedInstanceState);
    7.       setContentView(R.layout.activity_main);
    8.    }
    9.  
    10.    @Override
    11.    publicboolean onCreateOptionsMenu(Menu menu){
    12.       getMenuInflater().inflate(R.menu.activity_main, menu);
    13.       returntrue;
    14.    }
    15. }
    16.  

    Application crashes

    If your application crashes unexpectedly, your code will have thrown an exception.

    If you ask for advice on the forum about an application crash, be sure to include the stack trace from the Logcat output.

    Null pointer exceptions

    The null pointer exception (NPE) is by far the most common cause of application crashes. Looking at the stack trace and your code will quite often explain what's gone wrong, but if not, your next course of action could be to run the application in debug mode, and set a breakpoint at the relevant line, as described above.
    See here for more information http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it

    StackOverflow

    If you are a programmer, then StackOverflow is the most useful resource on the web to look for answers. It's so good that a lot of professional software developers don't know how they managed to do their job before it existed! It has thousands of questions, and most of them have good answers that will probably help you out. If you have a problem, chances are someone else already had the same problem, and it's been answered on StackOverflow. Check it out http://stackoverflow.com/

    Other resources

     

    Advertisement

    #1 LV426, Jan 8, 2016
    Last edited: Sep 27, 2017
  2. scary alien

    scary alien not really so scary
    Moderator
    Rank:
     #9
    Points:
    2,138
    Posts:
    22,242
    Joined:
    Mar 5, 2010

    Mar 5, 2010
    22,242
    23,428
    2,138
    Male
    space alien ;)
    Indy
  3. Engrz

    Engrz Lurker
    Rank:
    None
    Points:
    16
    Posts:
    4
    Joined:
    Feb 23, 2017

    Feb 23, 2017
    4
    2
    16
    very nice guidelines for beginners, im also interested to develop an app, this forum may help me in this regard.
     
    scary alien and LV426 like this.

Share This Page

Loading...