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

Android

BlogReader android app has error?

package com.patriothighschool.rickyjames1750.blogreader;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;

import com.patriothighschool.rickyjames1750.blogreader.R;

public class BlogWebViewActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blog_web_view);

        Intent intent = getIntent();
        Uri blogUri = intent.getData();

        WebView webView = (WebView) findViewById(R.id.webView1);
        WebView.loadUrl(blogUri.toString());
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.blog_web_view, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

Can you tell us the error that you are getting?

Information:Gradle tasks [:app:assembleDebug] :app:preBuild :app:compileDebugNdk UP-TO-DATE :app:preDebugBuild :app:checkDebugManifest :app:preReleaseBuild :app:prepareComAndroidSupportAppcompatV71910Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJava C:\Users\RickyJames1750\AndroidStudioProjects\BlogReader\app\src\main\java\com\patriothighschool\rickyjames1750\blogreader\BlogWebViewActivity.java Error:(23, 54) error: cannot find symbol variable webView1 Error:(24, 16) error: non-static method loadUrl(String) cannot be referenced from a static context C:\Users\RickyJames1750\AndroidStudioProjects\BlogReader\app\src\main\java\com\patriothighschool\rickyjames1750\blogreader\MainListActivity.java Error:(185, 17) error: method logException in class MainListActivity cannot be applied to given types; required: JSONException found: MalformedURLException reason: actual argument MalformedURLException cannot be converted to JSONException by method invocation conversion Error:(188, 17) error: method logException in class MainListActivity cannot be applied to given types; required: JSONException found: IOException reason: actual argument IOException cannot be converted to JSONException by method invocation conversion Error:(191, 17) error: method logException in class MainListActivity cannot be applied to given types; required: JSONException found: Exception reason: actual argument Exception cannot be converted to JSONException by method invocation conversion Error:Execution failed for task ':app:compileDebugJava'.

Compilation failed; see the compiler error output for details. Information:BUILD FAILED Information:Total time: 44.742 secs Information:6 errors Information:0 warnings Information:See complete output in console

1 Answer

Your error seems to be generating in the MainListAtivity.java class. Could you paste the logException method code for us to see?