URL::createInputStream returning 0


#1

URL::createInputStream returning 0 on Android 4.2.1 device.

[code]URL url (“http://www.google.com”);
ScopedPointer stream ((MemoryInputStream*) url.createInputStream (false));

if (stream != nullptr)
{
label->setText (stream->readEntireStreamAsString(), false);
}[/code]
logcat:

I/ActivityManager( 590): Start proc com.yourcompany.firstandroid for activity com.yourcompany.firstandroid/.FirstAndroid: pid=20779 uid=10102 gids={50102, 3003, 1028} I/dalvikvm(20779): Turning on JNI app bug workarounds for target SDK version 11... D/overlay ( 162): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED W/ActivityThread(20779): Application com.yourcompany.firstandroid can be debugged on port 8100... D/dalvikvm(20779): Trying to load lib /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so 0x41cbede8 D/dalvikvm(20779): Added shared lib /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so 0x41cbede8 I/JUCE (20779): JUCE v2.0.31 F/libc (20779): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 20779 (ny.firstandroid) I/DEBUG ( 160): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** I/DEBUG ( 160): Build fingerprint: 'google/occam/mako:4.2.1/JOP40D/533553:user/release-keys' I/DEBUG ( 160): Revision: '11' I/DEBUG ( 160): pid: 20779, tid: 20779, name: ny.firstandroid >>> com.yourcompany.firstandroid <<< I/DEBUG ( 160): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000 D/overlay ( 162): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_3_LAYER I/DEBUG ( 160): r0 00000000 r1 00000000 r2 00000000 r3 00000000 I/DEBUG ( 160): r4 7286f1e8 r5 7286f1e8 r6 00000000 r7 400d56f8 I/DEBUG ( 160): r8 be8af658 r9 400d56f0 sl 400b7020 fp be8af66c I/DEBUG ( 160): ip 00000000 sp be8af518 lr 73dffced pc 73dffcee cpsr 60000030 I/DEBUG ( 160): d0 000000004140b9f8 d1 6d0cf7f86d0cf7f8 I/DEBUG ( 160): d2 6d0cf1986d0cf10c d3 6d0cf8d86d0cf16d I/DEBUG ( 160): d4 6d0cf2786d0cf240 d5 6d0cf6386d0cf2b0 I/DEBUG ( 160): d6 6d0cf6a86d0cf670 d7 6d0cf7186d0cf6e0 I/DEBUG ( 160): d8 0000000000000000 d9 0000000000000000 I/DEBUG ( 160): d10 0000000000000000 d11 0000000000000000 I/DEBUG ( 160): d12 0000000000000000 d13 0000000000000000 I/DEBUG ( 160): d14 0000000000000000 d15 0000000000000000 I/DEBUG ( 160): d16 0000000000000000 d17 3ff6a09e667f3bcd I/DEBUG ( 160): d18 0000000000000000 d19 4000000000000000 I/DEBUG ( 160): d20 3ff0000000000000 d21 4000000000000000 I/DEBUG ( 160): d22 0707070703030303 d23 0000002f0000002e I/DEBUG ( 160): d24 0000000000000000 d25 0000000000000000 I/DEBUG ( 160): d26 0000002f0000002f d27 0000002f0000002f I/DEBUG ( 160): d28 0001000000010000 d29 0001000000010000 I/DEBUG ( 160): d30 0003000000030000 d31 0003000000030000 I/DEBUG ( 160): scr 20000090 I/DEBUG ( 160): I/DEBUG ( 160): backtrace: I/DEBUG ( 160): #00 pc 001e9cee /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so (MainContentComponent::MainContentComponent()+217) I/DEBUG ( 160): #01 pc 001e9ce9 /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so (MainContentComponent::MainContentComponent()+212) I/DEBUG ( 160): I/DEBUG ( 160): stack: I/DEBUG ( 160): be8af4d8 00000000 I/DEBUG ( 160): be8af4dc 00000000 I/DEBUG ( 160): be8af4e0 00000000 I/DEBUG ( 160): be8af4e4 00000000 I/DEBUG ( 160): be8af4e8 0097b41d I/DEBUG ( 160): be8af4ec be8af530 [stack] I/DEBUG ( 160): be8af4f0 740cf6d4 /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so I/DEBUG ( 160): be8af4f4 00000000 I/DEBUG ( 160): be8af4f8 00000000 I/DEBUG ( 160): be8af4fc be8af5ac [stack] I/DEBUG ( 160): be8af500 7297b408 I/DEBUG ( 160): be8af504 72734430 I/DEBUG ( 160): be8af508 7286f1e8 I/DEBUG ( 160): be8af50c 740cf6d4 /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so I/DEBUG ( 160): be8af510 df0027ad I/DEBUG ( 160): be8af514 00000000 I/DEBUG ( 160): #00 be8af518 740d1e08 /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so I/DEBUG ( 160): be8af51c 00000000 I/DEBUG ( 160): be8af520 00000000 I/DEBUG ( 160): be8af524 00000000 I/DEBUG ( 160): be8af528 400d56f8 I/DEBUG ( 160): be8af52c 7264f458 I/DEBUG ( 160): be8af530 7297b408 I/DEBUG ( 160): be8af534 740d1e04 /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so I/DEBUG ( 160): be8af538 00000000 I/DEBUG ( 160): be8af53c 00000000 I/DEBUG ( 160): be8af540 00000000 I/DEBUG ( 160): be8af544 734f7e60 I/DEBUG ( 160): be8af548 00000000 I/DEBUG ( 160): be8af54c 00000000 I/DEBUG ( 160): be8af550 00000000 I/DEBUG ( 160): be8af554 73fa81e3 /data/app-lib/com.yourcompany.firstandroid-1/libjuce_jni.so (juce::DocumentWindow::lookAndFeelChanged()+554)


#2

C-style cast of an unknown object to a MemoryInputStream?? WTF!? You’re lucky it returned a nullptr!

Have you made sure that your app’s manifest gives it network access permission?


#3

Thanks Jules, not sure what I was trying to do there TBH. Yes the internet access is ticked in the Introjucer. The permission is in the manifest.


#4

Ok, figured out what the first problem was. I was getting a NetworkOnMainThreadException.

[code]The exception that is thrown when an application attempts to perform a networking operation on its main thread.

This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it’s heavily discouraged. See the document Designing for Responsiveness.[/code]

Really!!??

Moving on…

Still not getting back any data, actually crashing in HTTPStream.read() now.

I’m still trying to get a handle on all of this Android building/debugging shtuff figure out with Eclipse.


#5

Has anyone used the URL class successfully on Android to fetch data?


#6

Wow. I guess you’d better use a background thread then!

But I guess it is a sensible restriction to impose these days.


#7

[quote=“jules”]Wow. I guess you’d better use a background thread then!

But I guess it is a sensible restriction to impose these days.[/quote]

Yes agreed, the main thread business is fine. What about it still not working even on a background thread?


#8

[quote=“aiit”][quote=“jules”]Wow. I guess you’d better use a background thread then!

But I guess it is a sensible restriction to impose these days.[/quote]

Yes agreed, the main thread business is fine. What about it still not working even on a background thread?[/quote]

My bad, I’m still getting a NetworkOnMainThreadException exception.


#9

All sorted out now. I was still reading the stream created by the URL class on the main thread. Well at least I got a little taste/contact with debugging the JuceAppActivity on Android.