Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Eugene Luebker
1,959 PointsUnable to open WebView after rewriting AndroidManifest.xml
I accidentally deleted my android manifest code! I tried to rewrite it, but now my app crashes when I try to display the WebView by clicking on a link in the ListView. Am I missing something in AndroidManifest.xml? Here it is:
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionName="1.0"
android:versionCode="1"
package="com.eugene.blogreader"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:targetSdkVersion="17" android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
-<application android:theme="@style/AppTheme"
android:label="@string/title_activity_web_view"
android:icon="@drawable/ic_launcher"
android:allowBackup="true">
-<activity android:name="com.eugene.blogreader.MainListActivity"
android:label="@string/app_name">
-<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
-<activity android:name="com.eugene.blogreader.WebViewActivity"
android:label="@string/title_activity_web_view"
</activity>
</application>
</manifest>
This is what LogCat displays:
06-26 20:20:17.712: E/AndroidRuntime(684): FATAL EXCEPTION: main
06-26 20:20:17.712: E/AndroidRuntime(684): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eugene.blogreader/com.eugene.blogreader.WebViewActivity}: java.lang.NullPointerException
06-26 20:20:17.712: E/AndroidRuntime(684): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
1 Answer
Ernest Grzybowski
Treehouse Project ReviewerFirst, did your application run before you deleted the manifest?
Second, use this code for your manifest
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eugene.blogreader"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/title_activity_web_view"
android:theme="@style/AppTheme" >
<activity
android:name="com.eugene.blogreader.MainListActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.eugene.blogreader.WebViewActivity"
android:label="@string/title_activity_web_view" >
</activity>
</application>
</manifest>
Let me know. Thanks!
Eugene Luebker
1,959 PointsEugene Luebker
1,959 PointsI think so. I guess there was something wrong with the way the WebView activity was being referenced, because I made a new activity with the exact same code and it works just fine. Thanks for your help and speedy reply!