Webview Broken in 1.5 SDK?

73 views
Skip to first unread message

sss

unread,
May 3, 2009, 9:20:50 PM5/3/09
to Android Developers
Can anyone confirm the fact that webview is broken in the 1.5 sdk?
Either that, or update the code page on the google developer side as
neither that code nor any other (including my previously working
webview code) is showing anything but a blank black screen.

Mark Murphy

unread,
May 4, 2009, 2:17:34 PM5/4/09
to android-d...@googlegroups.com
sss wrote:
> Can anyone confirm the fact that webview is broken in the 1.5 sdk?

WebView is not broken in the Android 1.5 SDK.

> Either that, or update the code page on the google developer side as
> neither that code nor any other (including my previously working
> webview code) is showing anything but a blank black screen.

Can you provide a link to the code in question? You might get more help
that way.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

dni_linux

unread,
May 4, 2009, 3:34:00 PM5/4/09
to Android Developers
I'm getting the same problem too. I'm using Eclipse with ADT plugin
on a Mac (10.5.6).

I'm a newb so i'm having trouble just running the Hello, WebView
example. Blank screen in the webview when I run it.

http://developer.android.com/guide/tutorials/views/hello-webview.html

Nothing seems wrong in the console log:

<log>
Installing HelloWebView.apk...
Success!
Starting activity com.example.webview.HelloWebView on device
ActivityManager: Starting: Intent { comp={com.example.webview/
com.example.webview.HelloWebView} }
</log>

Any help/suggestions would be appreciated !!! :)

On May 4, 1:17 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> sss wrote:
> > Can anyone confirm the fact thatwebviewis broken in the 1.5 sdk?
>
> WebViewis not broken in the Android 1.5 SDK.
>
> > Either that, or update the code page on the google developer side as
> > neither that code nor any other (including my previously working
> >webviewcode) is showing anything but a blank black screen.
>
> Can you provide a link to the code in question? You might get more help
> that way.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy

Mark Murphy

unread,
May 4, 2009, 3:50:17 PM5/4/09
to android-d...@googlegroups.com
dni_linux wrote:
> I'm getting the same problem too. I'm using Eclipse with ADT plugin
> on a Mac (10.5.6).
>
> I'm a newb so i'm having trouble just running the Hello, WebView
> example. Blank screen in the webview when I run it.
>
> http://developer.android.com/guide/tutorials/views/hello-webview.html
>
> Nothing seems wrong in the console log:
>
> <log>
> Installing HelloWebView.apk...
> Success!
> Starting activity com.example.webview.HelloWebView on device
> ActivityManager: Starting: Intent { comp={com.example.webview/
> com.example.webview.HelloWebView} }
> </log>
>
> Any help/suggestions would be appreciated !!! :)

Are you behind a firewall, proxy server, or anything that might
interfere with Web access?

Does the built-in Browser application work? If it fails, then the issue
is not with your code, but with something about your environment.

I have tried some WebView code from both my Android and Advanced Android
books with Android 1.5 within the past couple of hours, and they have
all worked, so I feel really confident that WebView is not completely
broken.

--

Android App Developer Training: http://commonsware.com/training.html

dni_linux

unread,
May 4, 2009, 4:14:08 PM5/4/09
to Android Developers
I should have mentioned that. Yes, I did try the Browser app in
Android and it was able to bring up websites. Yes, I'm behind a
firewall. However, i've never before experienced web access problems
(and besides, the built-in android browser works as just mentioned).

I figured that most people are not having problems. (Otherwise,
there'd be a bigger outcry.) I'm guessing too it's with my setup but
I have no idea what it could be. I also should have mentioned I'm
using Eclipse 3.4. As for user sss who started this thread, i'm not
sure if his setup is similar to mine. Can this be some kind macos-
ganymede-sdk1.5 problem?
> Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy

Mark Murphy

unread,
May 4, 2009, 4:37:03 PM5/4/09
to android-d...@googlegroups.com
dni_linux wrote:
> I should have mentioned that. Yes, I did try the Browser app in
> Android and it was able to bring up websites. Yes, I'm behind a
> firewall. However, i've never before experienced web access problems
> (and besides, the built-in android browser works as just mentioned).

That eliminates several possible sources of problems.

> Can this be some kind macos-ganymede-sdk1.5 problem?

Possibly. I'm a Ubuntu-Eclipseless-SDK1.5 kind of guy. ;-)

Try loading some other Web page than www.google.com, preferably one that
does not have any Javascript dependencies, and see if that changes your
results.

Or, head over to:

http://commonsware.com/Android/

and download the source code to my book. Try the WebKit set of projects.
I tried WebKit/Browser1 and it worked fine on 1.5 in the emulator. I
also tried WebView/GeoWeb1 from my Advanced Android book on 1.5, and it
too worked fine, and that one uses Javascript.

Since you're using Eclipse, you'll need to import the files into an
Eclipse project. However, it eliminates the cutting-and-pasting you're
having to do from the online tutorial, which may help matters.

Android App Developer Books: http://commonsware.com/books.html

dni_linux

unread,
May 4, 2009, 4:49:22 PM5/4/09
to Android Developers
Mark Murphy, Thanks for your assistance!

I'll check out that link and will probably try setting up ubuntu in a
vbox vm on my mac to test for different results.

Thanks again.

On May 4, 3:37 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> dni_linux wrote:
> > I should have mentioned that.  Yes, I did try the Browser app in
> > Android and it was able to bring up websites.  Yes, I'm behind a
> > firewall.  However, i've never before experienced web access problems
> > (and besides, the built-in android browser works as just mentioned).
>
> That eliminates several possible sources of problems.
>
> > Can this be some kind macos-ganymede-sdk1.5 problem?
>
> Possibly. I'm a Ubuntu-Eclipseless-SDK1.5 kind of guy. ;-)
>
> Try loading some other Web page thanwww.google.com, preferably one that
> does not have any Javascript dependencies, and see if that changes your
> results.
>
> Or, head over to:
>
> http://commonsware.com/Android/
>
> and download the source code to my book. Try the WebKit set of projects.
> I tried WebKit/Browser1 and it worked fine on 1.5 in the emulator. I
> also tried WebView/GeoWeb1 from my Advanced Android book on 1.5, and it
> too worked fine, and that one uses Javascript.
>
> Since you're using Eclipse, you'll need to import the files into an
> Eclipse project. However, it eliminates the cutting-and-pasting you're
> having to do from the online tutorial, which may help matters.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy

Mariano Kamp

unread,
May 4, 2009, 9:45:22 PM5/4/09
to android-d...@googlegroups.com
It works fine on OSX. FWIW some of the Android devs use OSX.

Did you check out your code with 1.1 and now it's not working with 1.5?

Do you have the right permission (http://developer.android.com/reference/android/Manifest.permission.html#INTERNET). The most common gotcha seems to be that this permission has not been declared in the manifest.

Yes, great idea to run Mark's code.

sss

unread,
May 4, 2009, 11:39:07 PM5/4/09
to Android Developers
I can say that while yesterday and the day before I was getting
countless complaints from users regarding my program that uses
webview, today they seem to have ceased. I haven't updated anything
so not sure if this is a fluke.. in any event, I'm going to try the
webkit mentioned above and will get back to this post if it works. If
so, it will be the first of about a dozen webview variations I've
tried that DOES work, so i'm skeptical but anxious.

On May 4, 9:45 pm, Mariano Kamp <mariano.k...@gmail.com> wrote:
> It works fine on OSX. FWIW some of the Android devs use OSX.
> Did you check out your code with 1.1 and now it's not working with 1.5?
>
> Do you have the right permission (http://developer.android.com/reference/android/Manifest.permission.ht...).

sss

unread,
May 4, 2009, 11:56:07 PM5/4/09
to Android Developers
Mark, same setup as you've got. I went so far as to download the
latest windows Version: 3.4.1Build id: M20080911-1700 of eclipse
yesterday, then did the latest android plugin .9 in my ganymede 1.5
sdk.

FYI, today I'm getting website cannot be found errors for CNN and
other test sites. This seems like either firewall or something
obviously internet related missing in the project declarations. i am
just so tired of digging and digging. why can't someone on all these
android help sites just post a (working) 1.5 project in zip format?
Stop with the millions of "chunks" of code and just put the stupid
25kb zip files already :)

Bill Zimmerly

unread,
May 11, 2009, 6:20:00 AM5/11/09
to Android Developers
Has this highly frustrating issue been resolved yet?

I haven't been able to use WebView under 1.5 on either the Linux or
Windows platforms. Here is source code that *worked perfectly* under
1.1 on both, but only displays under 1.5, as "sss" wrote in his
original message, "a blank black screen"...

package webApp.Webapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Webapp extends Activity
{
WebView webview;

private class WebAppClient extends WebViewClient
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
}

public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack())
{
webview.goBack();
return true;
}

return super.onKeyDown(keyCode, event);
}

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new WebAppClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.google.com");
}
}

Note: it isn't a firewall issue, and Google comes up fine under the
built-in Browser. Just for completeness, here are the only other two
files modified from the auto-generated "Hello World" example
project...

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="webApp.Webapp"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".Webapp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="3" />
</manifest>

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>

Any help is *GREATLY* appreciated!

Bill Zimmerly

unread,
May 11, 2009, 9:56:55 PM5/11/09
to Android Developers
I was successful in fixing the problem (above) and this details it...

This line in the Webapp.java file had to be changed from this ...
> webview= (WebView) findViewById(R.id.webview);

To this...
> webview= (WebView) findViewById(R.id.webkit);

And, in the main.xml file these two lines had to be replaced...
>   android:layout_width="wrap_content"
>   android:layout_height="wrap_content"

By these two...
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"

- Bill

superjet

unread,
May 16, 2009, 9:06:28 PM5/16/09
to Android Developers
I'm running into the same problem, but when I make this change
(webview to webkit) I get a compile error saying it cannot be
resolved. Ctrl-Shift-O doesnt bring in any new imports, so I'm at a
loss as to how to get the compiler to recognize this.

Can you shine some light?

Many thanks. SJ

Diptanshu Parui

unread,
May 17, 2009, 6:33:30 PM5/17/09
to Android Developers
Thanks Bill.
Your suggestion worked for me. I had same problem as couple of other
posters. WebView example from android's website was not working
despite having the right permissions and no firewall issue. In fact, I
tried a to do a HTTPGet into a TextView. That worked fine, but WebView
example was giving me grief.

Besides, the correction suggested by you I would also like to point
out that the client classes mentioned in the example @
http://developer.android.com/guide/tutorials/views/hello-webview.html
are inconsistent.

Cheers,
Dips

superjet

unread,
May 25, 2009, 1:13:27 PM5/25/09
to Android Developers
I actually just subscribed to your subscription service and am happy
to report your solution works for this problem! (I needed a little
more explanation than the code itself.) Looks like a nice set of
instructions all together, I look forward to the rest, and updates!
Thanks,
SJ

> Are you behind a firewall, proxy server, or anything that might
> interfere with Web access?
>
> Does the built-in Browser application work? If it fails, then the issue
> is not with your code, but with something about your environment.
>
> I have tried someWebViewcode from both my Android and Advanced Android
> books with Android1.5within the past couple of hours, and they have
> all worked, so I feel really confident thatWebViewis not completely
> broken.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy

Mark Murphy

unread,
May 25, 2009, 1:22:44 PM5/25/09
to android-d...@googlegroups.com
superjet wrote:
> I actually just subscribed to your subscription service and am happy
> to report your solution works for this problem! (I needed a little
> more explanation than the code itself.) Looks like a nice set of
> instructions all together, I look forward to the rest, and updates!

Happy to help, and thanks for subscribing!

--

Need Android talent? Ask on HADO! http://wiki.andmob.org/hado

David Bickley

unread,
May 23, 2009, 1:56:41 AM5/23/09
to Android Developers
I had the same problem with the android hello-webview example. (link
below)

http://developer.android.com/guide/tutorials/views/hello-webview.html


Changing the layout_width and layout_height of LinearLayout to
"fill_parent" from "wrap_content" fixed it.


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

</LinearLayout>



I hope this helps,
David Bickley

MIND GAME

unread,
Jun 10, 2009, 6:02:49 AM6/10/09
to Android Developers
hii
thanks this woks for me.....

Bill Zimmerly

unread,
Jul 9, 2009, 2:33:28 AM7/9/09
to Android Developers
You're welcome, MIND GAME.
- Bill
Reply all
Reply to author
Forward
0 new messages