Results 1 to 14 of 14
  1. #1
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Code Logic Works On Windows but not Android

    [Java] GAPT - Pastebin.com
    ^
    Code in pastebin for reference if needed.

    I'm making a mobile app, started out the code in a windows format because I understand better how to program in windows than in android, once I converted it to android I arranged all the syntactic errors and assumed that logical errors would follow the same pattern in Android as they do in Windows, but for some reason even though the program runs well on a Windows platform, I'm getting a "MainActivity stopped working" prompt when I try run it on Android.

    The program is basically just a set of if statements checking strings inside arrays and arraylists to create variables for another module being made by somebody else, is there a difference in the way any of those work between Windows and Android?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    "MainActivity stopped working"
    What error messages are shown in the Logcat console?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Re: Code Logic Works On Windows but not Android

    I dunno how to use logcat

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    How are you loading the apk file onto the Android device and testing it?
    Logcat is a console window available in Eclipse and via the adb command run from a batch file.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Re: Code Logic Works On Windows but not Android

    Is there any way I can run the console via netbeans or will I have to transfer my code to eclipse?

    I just export the source into an apk, load the apk into my android device, install it and run it

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    The adb command will copy and print the logcat in a console window. Here is the batch file I use:

    @rem Run adb

    D:\AndroidDevelopment\adt-bundle-windows-x86-20130522\sdk\platform-tools\adb.exe devices

    D:\AndroidDevelopment\adt-bundle-windows-x86-20130522\sdk\platform-tools\adb.exe logcat

    MORE
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Re: Code Logic Works On Windows but not Android

    -waiting for device-
    but it's not letting me type anything, what's wrong?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    it's not letting me type anything
    What is the "it's"?
    I have no idea what you are doing. Please explain in more detail.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Re: Code Logic Works On Windows but not Android

    I typed in the "C:\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe logcat" command to the prompt
    it returned:
    daemon not running. Starting it now on port 5037
    daemon started running
    -waiting for device-

    command prompt's been stuck like that for quarter of an hour now, can't even type anything into the prompt

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    Close the window and run it again. Make it a batch file vs typing it in.

    I often have to run the adb command 2 or more times before it connects.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Re: Code Logic Works On Windows but not Android

    Ok I downloaded Catlog onto my android phone and ran the apk there to get the logs
    What I got back was
    "Android Runtime Error: Caused by: java.lang.ClassNotFoundException: Didn't find class org.demo2.MainActivity on path /data/app/org/demo2-1.apk"

    That's the only error related to the text MainActivity

    All of the ones linked with lang are:

    java.lang.runtimeexception: Unable to instantiate activity ComponentInfo{org.demo2/org.demo2.MainActivity}:java.lang.ClassNotFoundExc eption: Didn't find classorg.demo2.MainActivity on path...
    java.lang.reflect.Method.invokeNative(Native Method)
    java.lang.reflect.Method.invoke(Method.java:511)
    java.lang.classLoader.loadClass(ClassLoader.java:5 01)
    java.lang.ClassLoad.loadClass(ClassLoader.java:461 )

    I'm guessing that means that it's not finding the main class?

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    Yes, I'd say that.

    I use eclipse to create the apk file and have never done it manually to know how its done.
    Last edited by Norm; 05-04-2014 at 09:53 PM.
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    EBamber is offline Member
    Join Date
    Apr 2014
    Posts
    30
    Rep Power
    0

    Default Re: Code Logic Works On Windows but not Android

    One last question
    If that exception shows on the logs, does that mean that it's hiding other exceptions in the rest of the code because the code can't be compiled, or would the other exceptions show regardless?

    Basically what I mean is, does this mean the rest of my code is fine apart from the Main Activity? I'm not actually gonna use the main activity I wrote in this module I was just using it so that I could test the code, another from my group wrote the main activity, the only code that's important for the whole program is the logic used in the KnowledgeBase.java and LanguageProcessor.java classes

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,577
    Rep Power
    25

    Default Re: Code Logic Works On Windows but not Android

    The logcat shows execution time errors. If the code hasn't executed there is no way to know if there are other errors in it.

    If there were compiler errors, the apk should not be created. I think you need a clean compile to create an apk.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Sounds not working on MAC, works on windows 7
    By natdizzle in forum Advanced Java
    Replies: 3
    Last Post: 12-16-2012, 03:06 AM
  2. Replies: 7
    Last Post: 03-05-2012, 05:26 PM
  3. Replies: 5
    Last Post: 04-02-2010, 03:33 PM
  4. Replies: 0
    Last Post: 04-02-2010, 05:54 AM
  5. Replies: 6
    Last Post: 10-22-2008, 05:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •