• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Kain5056

Hello World App won't run in emulator

7 posts in this topic

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. :-)

0

Share this post


Link to post
Share on other sites

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
2

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

I'm not an Android user, but I'd recommend Googling the message in the root exception: [url="https://encrypted.google.com/search?q=You+cannot+combine+swipe+dismissal+and+the+action+bar"]You cannot combine swipe dismissal and the action bar[/url]

2

Share this post


Link to post
Share on other sites

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... :-/

2

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0