aspose file tools*
The moose likes Android and the fly likes File path to FileList.txt and xml files not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "File path to FileList.txt and xml files not working" Watch "File path to FileList.txt and xml files not working" New topic
Author

File path to FileList.txt and xml files not working

Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
I'm trying to get my emulator to load the list of xml file names so that I can get the book info off the xml files located locally in the project. I'm not sure if my file class information is correct or if I have to do something with permissions in the manifest? When I start the application it says Unfortunately Http2Demo has failed to launch. Any thoughts on why it may not be able to load the names of the xml files from FileList.txt? I think the problem may lie in the class paths.













Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Are there any exceptions in the logcat output?


Ping & DNS - updated with new look and Ping home screen widget
Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
Below is the LogCat output I have gotten so far:

12-04 21:29:50.635: E/AndroidRuntime(711): FATAL EXCEPTION: main
12-04 21:29:50.635: E/AndroidRuntime(711): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dwhudson.http2demo/com.dwhudson.http2demo.Http2DemoActivity}: java.lang.RuntimeException: Binary XML file line #67: You must supply a layout_width attribute.
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.os.Looper.loop(Looper.java:137)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-04 21:29:50.635: E/AndroidRuntime(711): at java.lang.reflect.Method.invokeNative(Native Method)
12-04 21:29:50.635: E/AndroidRuntime(711): at java.lang.reflect.Method.invoke(Method.java:511)
12-04 21:29:50.635: E/AndroidRuntime(711): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-04 21:29:50.635: E/AndroidRuntime(711): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-04 21:29:50.635: E/AndroidRuntime(711): at dalvik.system.NativeStart.main(Native Method)
12-04 21:29:50.635: E/AndroidRuntime(711): Caused by: java.lang.RuntimeException: Binary XML file line #67: You must supply a layout_width attribute.
12-04 21:29:50.635: E/AndroidRuntime(711): at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5458)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5594)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.widget.RelativeLayout$LayoutParams.<init>(RelativeLayout.java:1099)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:956)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:70)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.view.LayoutInflater.rInflate(LayoutInflater.java:748)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-04 21:29:50.635: E/AndroidRuntime(711): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.Activity.setContentView(Activity.java:1867)
12-04 21:29:50.635: E/AndroidRuntime(711): at com.dwhudson.http2demo.Http2DemoActivity.onCreate(Http2DemoActivity.java:76)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.Activity.performCreate(Activity.java:5008)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-04 21:29:50.635: E/AndroidRuntime(711): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-04 21:29:50.635: E/AndroidRuntime(711): ... 11 more
12-04 21:30:33.376: I/Process(711): Sending signal. PID: 711 SIG: 9
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Have you tried supplying a layout_width attribute in whatever layout is causing the problem, like the error message says?
Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
Good point, added the width & height attributes, so that's not a problem. It's still failing though pasted below is the new LogCat output: Is my path incorrect, it is supposed to be relative since I can't make the path to D: drive? Trying to get the .xml files that I need to import from the local raw folder.







12-05 20:40:32.927: D/myDebug(725): Request failed: Illegal character in path at index 0: \res\raw\filelist
12-05 20:40:32.927: D/AndroidRuntime(725): Shutting down VM
12-05 20:40:32.936: W/dalvikvm(725): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
12-05 20:40:32.946: E/AndroidRuntime(725): FATAL EXCEPTION: main
12-05 20:40:32.946: E/AndroidRuntime(725): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dwhudson.http2demo/com.dwhudson.http2demo.Http2DemoActivity}: java.lang.NullPointerException
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.os.Handler.dispatchMessage(Handler.java:99)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.os.Looper.loop(Looper.java:137)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.ActivityThread.main(ActivityThread.java:4745)
12-05 20:40:32.946: E/AndroidRuntime(725): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 20:40:32.946: E/AndroidRuntime(725): at java.lang.reflect.Method.invoke(Method.java:511)
12-05 20:40:32.946: E/AndroidRuntime(725): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-05 20:40:32.946: E/AndroidRuntime(725): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-05 20:40:32.946: E/AndroidRuntime(725): at dalvik.system.NativeStart.main(Native Method)
12-05 20:40:32.946: E/AndroidRuntime(725): Caused by: java.lang.NullPointerException
12-05 20:40:32.946: E/AndroidRuntime(725): at java.io.StringReader.<init>(StringReader.java:47)
12-05 20:40:32.946: E/AndroidRuntime(725): at com.dwhudson.http2demo.Http2DemoActivity.getLines(Http2DemoActivity.java:180)
12-05 20:40:32.946: E/AndroidRuntime(725): at com.dwhudson.http2demo.Http2DemoActivity.onCreate(Http2DemoActivity.java:89)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.Activity.performCreate(Activity.java:5008)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-05 20:40:32.946: E/AndroidRuntime(725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-05 20:40:32.946: E/AndroidRuntime(725): ... 11 more
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
The file path you're supplying is most likely not recognized by Android - which is not surprising, since it looks like a Windows path ("d:\\...").
Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
I've been trying to find useful information for writing proper relative paths in Android but haven't found much. Do I want to do something like one of the following? Anyone know of a useful online path resource?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
I don't think relative paths are possible on Android. I assume you've read through http://developer.android.com/guide/topics/data/data-storage.html about the various possibilities of storing files... ?
Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
Ok I have that problem solved now it says there is an illegal character in the path.

12-09 15:20:35.462: D/gralloc_goldfish(671): Emulator without GPU emulation detected.
12-09 15:20:35.672: D/myDebug(671): Request failed: Illegal character in path at index 49: http://www.despoiler.net/docs/AmazonFiles/Failure to read from server!
12-09 15:20:35.732: D/myDebug(671): XML Parsing failed: null



I'm wondering what illegal characters are in the path?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File path to FileList.txt and xml files not working
 
Similar Threads
Not letting me create and add user defined object to ArrayList
ArrayList object not passing to String[]
Programmatically set typeface and textsize of Spinner / ComboBox
how to change the array into an file
ArrayList says false in emulator