Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Hello World App won't run in emulator


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Kain5056   Members   -  Reputation: 456

Like
0Likes
Like

Posted 30 July 2014 - 02:29 PM

Hi, I'm trying to learn how to make my first "Hello World" application for Android, in Java with Eclipse. But when I try to run it in the Emulator, all I get is the "Unfortunately, Hello World has stopped" message.

 

Here is my code:

package com.example.testgame;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;


public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tv = new TextView(this);
        tv.setText("Yo Android World!");
        setContentView(tv);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

All I did was adding "import android.widget.TextView;", "TextView tv = new TextView(this);", "tv.setText("Yo Android World!");" and "setContentView(tv);" to the default New Project code, following THIS Tutorial.

 

Also, if you could point me to a more up-to-date Tutorial series for beginners, it would really help. :-)

 

Thank you in advance. :-)



Sponsor:

#2 DiegoSLTS   Members   -  Reputation: 1915

Like
2Likes
Like

Posted 30 July 2014 - 02:42 PM

The code works without those lines? It's working for me with and without them.

 

If the app crashed there should be some exception displayed in LogCat, what does it say? If you can't find the LogCat window go to window -> show view -> other and search for LogCat.


Edited by DiegoSLTS, 30 July 2014 - 02:43 PM.


#3 Kain5056   Members   -  Reputation: 456

Like
0Likes
Like

Posted 30 July 2014 - 03:00 PM

Okay, here is what the LogCat gives me:

07-30 20:56:19.420: E/AndroidRuntime(871): FATAL EXCEPTION: main
07-30 20:56:19.420: E/AndroidRuntime(871): Process: com.example.testgame, PID: 871
07-30 20:56:19.420: E/AndroidRuntime(871): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testgame/com.example.testgame.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.os.Handler.dispatchMessage(Handler.java:102)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.os.Looper.loop(Looper.java:136)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.ActivityThread.main(ActivityThread.java:5026)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at java.lang.reflect.Method.invoke(Method.java:515)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at dalvik.system.NativeStart.main(Native Method)
07-30 20:56:19.420: E/AndroidRuntime(871): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.Activity.setContentView(Activity.java:1930)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at com.example.testgame.MainActivity.onCreate(MainActivity.java:15)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.Activity.performCreate(Activity.java:5242)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-30 20:56:19.420: E/AndroidRuntime(871): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-30 20:56:19.420: E/AndroidRuntime(871): 	... 11 more


#4 rip-off   Moderators   -  Reputation: 8758

Like
2Likes
Like

Posted 30 July 2014 - 04:05 PM

I'm not an Android user, but I'd recommend Googling the message in the root exception: You cannot combine swipe dismissal and the action bar



#5 minibutmany   Members   -  Reputation: 1681

Like
2Likes
Like

Posted 30 July 2014 - 04:30 PM

Have you tested on an actual device? The android emulator sometimes has problems. 


Stay gold, Pony Boy.

#6 Navyman   Crossbones+   -  Reputation: 4053

Like
1Likes
Like

Posted 30 July 2014 - 05:20 PM

Making sure that your emulator is setup correctly can be an issue.


Developer with a bit of Kickstarter and business experience.

34410.png

#7 Kain5056   Members   -  Reputation: 456

Like
2Likes
Like

Posted 30 July 2014 - 05:30 PM

OK, I googled it (didn't know exactly what to google at the time) and found the solution.

I downgraded the API Level to 17 just to be sure (Android version 4.2.2) and it works like a charm, both in the emulator and on my physical phone. :-)

Thanks for the help. :-)

 

A question though: Do I even need the API Level 20 stuff? Or is it safe to just uninstall them and just work with Level 17? Because the whole thing takes a billion trillion (rough estimate) Gigabytes on my HDD and it's a bit annoying since it's almost full... :-/



#8 Navyman   Crossbones+   -  Reputation: 4053

Like
0Likes
Like

Posted 30 July 2014 - 05:33 PM

I use level 17, because it is a fairly tested base. Level 20 is more on the bleeding edge and I would say if you do not know the new features than it is better to use a base you are most familiar with.


Developer with a bit of Kickstarter and business experience.

34410.png




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS