Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 20 of 20

Thread: Robot Game; Few errors (help)

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Robot Game; Few errors (help)

    Hey there!

    I've been following a tutorial on making a game on Kilobolt, but the place is quite dead.
    So I've searched for a more active forum.
    I hope you guys can save me out of this one

    This is my first app ever, so I'm not very familiar with coding.

    I've been following this tutorial:
    (I want to post the link but the forum won't let me.) -> Kilobolt.com -> Tutorials > Game Development Tutorials > Unit 4 > Day 7 - Creating an Android Game (From Start to Finish)

    But I end up getting these errors: Help.jpg

    I've changed all the statements from com.kilobolt.robotgame to my own, com.MertensMobile.AndroidSoldier

    Which fixed the errors I got when adding the classes (Animation.java, Assets,java etc.)

    This is what I get now.

    What am I missing?



    Ty all very much!


  2. #2
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)


  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Robot Game; Few errors (help)

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    Copy and paste errors directly into a post, if possible; post code in code tags as described in the above link. The picture you posted is next to impossible to read.

    Good luck!

    Update: The linked picture is much better, though I'm not sure what useful info it provides.

  4. #4
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    (I fixed the Map1.text - error.)


    Sorry.

    Thank you for informing me

    The code from the SampleGame.java which gives an error:
    package com.MertensMobile.AndroidSoldier;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
     
    import MertensMobile.R;
    import android.util.Log;
     
    import com.kilobolt.framework.Screen;
    import com.kilobolt.framework.implementation.AndroidGame;
    import com.MertensMobile.AndroidSoldier.R;
     
     
    public class SampleGame extends AndroidGame {
     
        public static String map;
        boolean firstTimeCreate = true;
     
        @Override
        public Screen getInitScreen() {
     
            if (firstTimeCreate) {
                Assets.load(this);
                firstTimeCreate = false;
            }
     
            InputStream is = getResources().openRawResource(R.raw.map1);
            map = convertStreamToString(is);
     
            return new SplashLoadingScreen(this);
     
        }
     
        @Override
        public void onBackPressed() {
            getCurrentScreen().backButton();
        }
     
        private static String convertStreamToString(InputStream is) {
     
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            StringBuilder sb = new StringBuilder();
     
            String line = null;
            try {
                while ((line = reader.readLine()) != null) {
                    sb.append((line + "\n"));
                }
            } catch (IOException e) {
                Log.w("LOG", e.getMessage());
            } finally {
                try {
                    is.close();
                } catch (IOException e) {
                    Log.w("LOG", e.getMessage());
                }
            }
            return sb.toString();
        }
     
        @Override
        public void onResume() {
            super.onResume();
     
            Assets.theme.play();
     
        }
     
        @Override
        public void onPause() {
            super.onPause();
            Assets.theme.pause();
     
        }
    }

    The other error I'm getting is from the AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.MertensMobile.AndroidSoldier"
       android:versionCode="1"
       android:versionName="1.0" >
     
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.VIBRATE" />
     
        <uses-sdk
           android:minSdkVersion="8"
           android:targetSdkVersion="17" />
     
        <application
           android:icon="@drawable/icon"
           android:label="RobotGame" >
            <activity
               android:name=".SampleGame"
               android:configChanges="keyboard|keyboardHidden|orientation"
               android:label="RobotGame"
               android:screenOrientation="landscape" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
     
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
     
    </manifest>

    The error here is "@drawable/icon"

    --- Update ---

    If you need more information, let me know and I'll post it.

  5. #5
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Robot Game; Few errors (help)

    I recommend reading up on Android resources. @drawable/icon is trying to reference an image called 'icon.png' in the drawables directory which probably doesn't exist. map1.txt should be formatted as xml in strings.xml (which lives in the values directory). When you reference R.id.something you are trying to access an id of a layout or UI component specified in the res directory.

  6. #6
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    I've checked it, and I do have an Icon.png in the map Android Soldier\res\drawable-hdpi, like mentioned in the tutorial.

    The map1.txt is fixed (how do I format it in strings.xml?)

  7. #7
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Robot Game; Few errors (help)

    Quote Originally Posted by Snake-KoRn View Post
    I've checked it, and I do have an Icon.png in the map Android Soldier\res\drawable-hdpi, like mentioned in the tutorial.
    Icon.png or icon.png... It's case sensitive. Your IDE should be able to autocomplete this for you.


    Quote Originally Posted by Snake-KoRn View Post
    The map1.txt is fixed (how do I format it in strings.xml?)
    <string name="map1">
        All your strings belong to us..
    </string>

    Then access that string with

    String map = getResources().getString(R.string.map1);

    No need to mess around with that InputStream

  8. #8
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    First of all, ty for your help.

    Unfortunatly:

    1. The "icon.png", which I saved in the map: "Project Android\Android-Soldier\res\raw" has the same cases as the one in AndroidManifest.xml

    ==

    I think the best way to find the best help would be if I just upload my whole file, it'll be much faster to find what I'm doing wrong

    (Sorry for being so annoying )
    Last edited by Snake-KoRn; July 17th, 2014 at 10:56 AM.

  9. #9
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Robot Game; Few errors (help)

    Why is it in /res/raw? Images live in /res/drawable. Also, I'd recommend sticking to the conventions in the android docs with naming resources. I stick to "ic_launcher" for the applications icon.


    You'll notice a couple of different drawable directories (hdpi, xhdpi, etc). These relate to the different screen resolutions. If you plan on supporting multiple devices you need an icon for each directory. There is a breakdown of the sizes here. There are also online tools to automatically scale things for you. You can ignore these and just stick it in drawable for now.

  10. #10
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    I just got that from the tutorial, where it said "icon.png"

    (I changed all the 3 maps with an "icon.png"-file, but no improvement so far.

    Could you please re-upload the correct version, cuzz I'm not following it

  11. #11
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Robot Game; Few errors (help)

    Quote Originally Posted by Snake-KoRn View Post
    I just got that from the tutorial, where it said "icon.png"

    (I changed all the 3 maps with an "icon.png"-file, but no improvement so far.
    Tutorials are okay I suppose but the Android docs have the final say. Stick with ic_launcher.

    Quote Originally Posted by Snake-KoRn View Post
    Could you please re-upload the correct version, cuzz I'm not following it
    Nope. I'm here to help and guide, not solve your problems for you. Doing so would deprive you of the experience of solving your own problems. Additionally, I don't download .exe files from suspicious file hosts (even if I was running a windows machine).

  12. #12
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    Alright, you're right.

    I tried that, I changed all icons back to "ic_launcher" and now it's fixed ! Ty !

    Last error I get is in the SampleGame.java, the import "com.kilobolt.robotgame.r"

    even though I named the other names in the other classes "com.MertensMobile.AndroidSoldier", which didn't give me an error,
    this class has two Imports to com.kilobolt.framework ...
    but the .r-file don't get linked.

    Is this regarding a map or a file which I need to adjust ?

    PS: I do have some files with a smaal /!\ icon, is that a problem, or will it just be fine?
    Last edited by Snake-KoRn; July 17th, 2014 at 10:41 AM.

  13. #13
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    As of now, I fixed the problems, I get no errors (except for the yellow /!\, doest that matter?

  14. #14
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Robot Game; Few errors (help)

    These are warnings. Hover your mouse over the icon to see what the warning is about. Usually it makes sense to fix the problems that generate warnings because the warnings are there for a reason.

  15. #15
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    Hmmm, I got a few warningsigns showing up. (yellow ones)

    I got it on my device, named "RobotGame" while I want it with MY name of the game and MY icon...
    When I want to open the app, an error comes "Unfortunatly, RobotGame has been closed." or something like that.

    This is what the Logcat gives me
    E 07-17 21:29:0... 4332 4332 com.MertensMobile.AndroidSoldier Trace error opening trace file: No such file or directory (2)
    W (same as above) 4332 4332 (same as above) dalvikvm Refusing to reopen boot DEX '/system/framework/hwframework.jar'
    W (same as above) 4332 4332 (same as above) (same as above) threadid=1: thread exiting with uncaught exception (group=0x40e0143 []
    8)
    I see that the errors are from Arraylist. I will recheck on the tutorial, see if I can fix this.

    (Note that I try to fix myself as much as possible)

    --- Update ---

    Yah I can't find a solution for those Arrays
    Last edited by Snake-KoRn; July 17th, 2014 at 03:08 PM.

  16. #16
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    I'm drivin nutz here

  17. #17
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Robot Game; Few errors (help)

    The warnings from the ArrayList are because they aren't using generics. This is the correct way of defining an ArrayList with type safety ensuring it will only accept objects of a certain type (for example this will only accept String objects).

    List<String> tileArray = new ArrayList<String>();

    As for that error. It looks like there is a missing permission. Try adding this to the manifest

    <uses-permission android:name="android.permission. ACCESS_NETWORK_STATE" />

  18. #18
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    I give up, I can't get it working.

    Ty anyway.

  19. #19
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Robot Game; Few errors (help)

    Quote Originally Posted by Snake-KoRn View Post
    I give up, I can't get it working.

    Ty anyway.
    I've had a look at the tutorial you've been following. It's not a tutorial, rather a set of copy and paste instructions. Understand that creating a game for Android is a complex undertaking, requiring a solid grasp of Java concepts and the problem solving skills that only come with experience.

    I'd advise you to start small and work up. Have you written a "Hello, World" app? A box that bounces around a canvas? A non-trivial app that serves a purpose? If not then you are not ready to make a game.

  20. The Following User Says Thank You to ChristopherLowe For This Useful Post:

    GregBrannon (July 18th, 2014)

  21. #20
    Junior Member
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Robot Game; Few errors (help)

    You're right.

    I followed your advice on it.

    I just made my first "Hello World"-app, at least this one works!

    So I guess, the next step is the bouncing box

Similar Threads

  1. Replies: 7
    Last Post: May 8th, 2014, 12:51 PM
  2. java game errors
    By New2Programming in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 9th, 2014, 06:20 PM
  3. Replies: 3
    Last Post: April 27th, 2013, 07:19 AM
  4. Couple compile errors for dice game
    By smithmar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 8th, 2012, 01:16 PM
  5. Random Errors Occurring When Running Game in Eclipse
    By WhenThCome4Me in forum Java IDEs
    Replies: 22
    Last Post: September 1st, 2011, 06:29 AM