Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

I runned my app with 0 errors and the emulator keeps displaying app keeps stopping?

i did all my code but the "app keeps stopping" is the message i get.

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Vamshi;

We'll need a bit more information to try to help. Do you have your code somewhere that you can share for folks to take a look?

Ken

Yes, i'm posting my code here so that you can know whats the problem with it

import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.LinkedList;
import java.util.List;
import java.lang.*;

public class Flames extends AppCompatActivity {
    private TextView name;
    private Button next;
    private TextView love;
    private TextView result;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flames);

        name=findViewById(R.id.name);
        love=findViewById(R.id.love);
        next=findViewById(R.id.next);
        View.OnClickListener listener = new View.OnClickListener(){
            @Override
            public void onClick(View v){

                int rem;
                char fl[]={'f','l','a','m','e','s'};
                int count=0;
                //Scanner s=new Scanner(System.in);
                List l=new LinkedList();
                List a=new LinkedList();
                List f=new LinkedList();
                String b,c;
                //System.out.println("enter your name");
                b= (String) name.getText();
                //System.out.println("enter your love's name");
                c= (String) love.getText();
                char d[]=b.toCharArray();
                char e[]=c.toCharArray();
                for(int i=0;i<fl.length;i++)
                {
                    l.add(fl[i]);
                }
                for(int i=0;i<d.length;i++)
                {
                    a.add(d[i]);
                }
                for(int i=0;i<e.length;i++)
                {
                    f.add(e[i]);
                }
                //   System.out.println(a);
                //   System.out.println(f);

                for(int i=0;i<e.length;i++)
                {
                    for(int j=0;j<d.length;j++)
                        if(d[j]==e[i])
                        {
                            count++;
                            count++;
                        }
                }
                //System.out.println("total letters are:"+"  "+(d.length+e.length));
                //System.out.println("matching letters are:"+"  "+count);
                if((d.length+e.length)>count)
                {
                    rem=(d.length+e.length)-count;
                }
                else
                {
                    rem=count-(d.length+e.length);
                }
                //System.out.println("remaining love letters are:"+"  "+rem);
                l.remove((rem%6));
                // System.out.println(l);
                l.remove((rem%5));
                // System.out.println(l);
                l.remove((rem%4));
                // System.out.println(l);
                l.remove((rem%3));
                // System.out.println(l);
                l.remove((rem%2));

                List fact=l;
                result.setText((CharSequence) l);


            }
        };
        next.setOnClickListener(listener);
    }
}
Ken Alger
Ken Alger
Treehouse Teacher

Do you have your entire project posted somewhere (Github for example)? Just having this one class doesn't provide all the necessary information about what might be the issue.