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 Build a Blog Reader Android App Exploring the Master-Detail Template Creating a Project Using the Master-Detail Template

My project cant be created ...

i have done the same thing like Ben did till creating an android application project but my project cant be created and it is not opening its showing error Description Resource Path Location Type error: Error

retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. styles.xml /MasterDetailExample/res/values-v14 line 8 Android AAPT Problem and one more

Description Resource Path Location Type R cannot be resolved to a variable BlogPostDetailActivity.java /MasterDetailExample/src/com/example/masterdetailexample line 23 Java Problem

8 Answers

Calvin Nix
Calvin Nix
43,828 Points

Hey Junaid,

I don't believe you need to be using the Theme.AppCompat.Light.DarkActionBar theme.

Additionally, The 'Type R cannot be resolved to a variable' is a very common error that I encountered. In your imports you should see that you have imported Android.R. You will want to remove this import. You might also need to clean your project for the errors to go away.

Thanks, Calvin

after importing the Android.r the error show on the blog post detail

setContentView(R.layout.activity_blogpost_detail);

Calvin Nix
Calvin Nix
43,828 Points

Yeah you will need to re-reference R.layout.activity_blogpost_detail.

how to re -reference

Calvin Nix
Calvin Nix
43,828 Points

Erase R.layout.activity_blogpost_detail and re-add it.

the error is not going

Calvin Nix
Calvin Nix
43,828 Points

Yeah the problem that I have with debugging it is there are so many things that could go wrong and cause that issue.

Do you have an errors in your XML?

i have an error in styles.xml and not any error in the AndroidManifest.xml

Calvin Nix
Calvin Nix
43,828 Points

The error in your XML file is a problem.

whats the problem please help me fix this ..... i want to continue with Ben i am a beginner!!

Calvin Nix
Calvin Nix
43,828 Points

Umm it be due to one of Eclipses weird quirks if you are not seeing any actual error indicators in your XML. Cut all of the code from the file and paste it back in and the error should go away.

the styles.xml error has gone it was in the res folder i have done what you said and its gone but there still problem with that blogpost

Calvin Nix
Calvin Nix
43,828 Points

Now you need to recheck to see if Android.R was imported again. And delete it if it was. Clean your project and re-reference R.layout.activity_blogpost_detail

Calvin Nix
Calvin Nix
43,828 Points

You're importing Android.R. Remove this import.

yeah i have removed it. then what to do next

Calvin Nix
Calvin Nix
43,828 Points

Make sure that it is removed for good because it tends to re-add it self when you are adding references. Now you will want to re-reference one of your references.

i removed it ...... and what to re-reference i am new please explain in a simple language please !! and now the error is moved from blogpost to R. and if i import the android.R then the error goes back to blogpost Every time i make a move the error is still there what to do and the styles.xml error did not gone permanently when i clean or save the whole project the error comes again

Calvin Nix
Calvin Nix
43,828 Points

Hi Junaid,

If you ever hear anyone complaining about the Eclipse IDE it is because of bugs like these.

I'm sorry but I can't look at your code because honestly your code is probably correct. I receive these issues too and it takes me quite some time to resolve them.

You need to make sure: Android.R has not been imported into the project. You have no errors in your XML files. All of your XML files are named using only lowercase characters.

After you do this your project and code are correct. So now you are just trying to trick the Eclipse IDE into stop throwing the error.

An example of this was deleting the text in the XML file and re-adding it.

For resolving issues with your references (i.e. findViewById(R.id.just_an_example);

You will need to erase the part that is giving you an error... R.id.just_an_example Once you have deleted this I would suggest to type R.. After that let Eclipse give you options for the next text id. Select id, then you should be giving the options for the specific references. If you see just_an_example then you will just select it and you will see that all of the other errors with R in your project will go away, It's magic :). If you do not see the option just_an_example then you will need to import the correct reference file. You should be given a selection of items to import when you first type R..

I hope this helps.

Its still not happening i have re added it but its still an error now just like you said i have started working with Ben further and with the project and we will see what happens next

there are error in the BlogPostDetailActivity.java, BlogPostDetailFragment.java and BlogPostListActivity.java

i will paste you my code in which the error is and you please take a look and tell me

package com.example.masterdetailexample;

import android.R;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;


/**
 * An activity representing a list of BlogPosts. This activity
 * has different presentations for handset and tablet-size devices. On
 * handsets, the activity presents a list of items, which when touched,
 * lead to a {@link BlogPostDetailActivity} representing
 * item details. On tablets, the activity presents the list of items and
 * item details side-by-side using two vertical panes.
 * <p>
 * The activity makes heavy use of fragments. The list of items is a
 * {@link BlogPostListFragment} and the item details
 * (if present) is a {@link BlogPostDetailFragment}.
 * <p>
 * This activity also implements the required
 * {@link BlogPostListFragment.Callbacks} interface
 * to listen for item selections.
 */
public class BlogPostListActivity extends FragmentActivity
        implements BlogPostListFragment.Callbacks {

    /**
     * Whether or not the activity is in two-pane mode, i.e. running on a tablet
     * device.
     */
    private boolean mTwoPane;

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

        if (findViewById(R.id.blogpost_detail_container) != null) {
            // The detail container view will be present only in the
            // large-screen layouts (res/values-large and
            // res/values-sw600dp). If this view is present, then the
            // activity should be in two-pane mode.
            mTwoPane = true;

            // In two-pane mode, list items should be given the
            // 'activated' state when touched.
            ((BlogPostListFragment) getSupportFragmentManager()
                    .findFragmentById(R.id.blogpost_list))
                    .setActivateOnItemClick(true);
        }

        // TODO: If exposing deep links into your app, handle intents here.
    }

    /**
     * Callback method from {@link BlogPostListFragment.Callbacks}
     * indicating that the item with the given ID was selected.
     */
    @Override
    public void onItemSelected(String id) {
        if (mTwoPane) {
            // In two-pane mode, show the detail view in this activity by
            // adding or replacing the detail fragment using a
            // fragment transaction.
            Bundle arguments = new Bundle();
            arguments.putString(BlogPostDetailFragment.ARG_ITEM_ID, id);
            BlogPostDetailFragment fragment = new BlogPostDetailFragment();
            fragment.setArguments(arguments);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.blogpost_detail_container, fragment)
                    .commit();

        } else {
            // In single-pane mode, simply start the detail activity
            // for the selected item ID.
            Intent detailIntent = new Intent(this, BlogPostDetailActivity.class);
            detailIntent.putExtra(BlogPostDetailFragment.ARG_ITEM_ID, id);
            startActivity(detailIntent);
        }
    }
}