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

Hello There, Brand new whiner here :) I'm getting 3 errors when attempting to run my FunFacts App.

I'm also unable to get my app to run on my emulator. Error as it displayed in Gradle console:

AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:TextAppearance.Material.Widget.Button.Inverse\u0027.","sources":[{"file":"C:\Users\HeatherGuin\AndroidStudioProjects\FunFacts\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v23\values-v23.xml","position":{"startLine":1}}],"original":""} AGPBI: {"kind":"error","text":"Error retrieving parent for item: No resource found that matches the given name \u0027android:Widget.Material.Button.Colored\u0027.","sources":[{"file":"C:\Users\HeatherGuin\AndroidStudioProjects\FunFacts\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v23\values-v23.xml","position":{"startLine":1}}],"original":""}

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processDebugResources'.

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\HeatherGuin\AppData\Local\Android\sdk\build-tools\23.0.0\aapt.exe'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Farouk Charkas
Farouk Charkas
1,957 Points

Try debugging it and, please format the error in code, and debug it and give us the line of code that is causing the error.

4 Answers

Harry James
Harry James
14,780 Points

Hey there Heather!

It looks like you're using the appCompat library for API 23:

compile 'com.android.support:appcompat-v7:23.0.0'
                                          ^

But you are compiling with and targeting API 22.

Both your appCompat and compileSdkVersion must use the same API version - You should also set the targetSdkVersion to this API as well (This just tells Google Play that your app should work up to that version). Also, the buildToolsVersion should reflect the compileSdkVersion (This is used to say which version of the compilers you want to use - a new version of this is released with each API).


If you want to use API 23 then set these attributes and dependencies as follows (Note: They will not be in this order):

compileSdkVersion 23
buildToolsVersion "23.0.0"
targetSdkVersion 23
compile 'com.android.support:appcompat-v7:23.0.0'

Using API 22

If you want to use API 22 then set the attributes and dependencies as follows (Note: They will not be in this order):

compileSdkVersion 22
buildToolsVersion "22.0.1"
targetSdkVersion 22
compile 'com.android.support:appcompat-v7:22.2.1'

Hope it helps and if you have any questions about any of this, give me a shout :)

Thank You So much! I have yet to use the shell in android studio, I will attempt to add this api

Harry James
Harry James
14,780 Points

Hey Heather!

Just to let you know that these are for the build.gradle file - just replace the appropriate lines. There's no need to use the shell/terminal.

Let me know if you have any problems :)

Jon Kussmann
PLUS
Jon Kussmann
Courses Plus Student 7,254 Points

Hi Heather,

It looks like something could be off with your build.gradle file. Could you post it (the app:module one).

Christopher Augg
Christopher Augg
21,223 Points

Yes, it looks like you are correct. She can look over this stackoverflow post and see if that helps.

Harry James
Harry James
14,780 Points

+1 seems like the cause is likely a mismatching AppCompat version.

Hello Jon and Christopher!

this is the build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.heatcode.funfacts"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
}

Hello to you too Harry

Christopher Augg
Christopher Augg
21,223 Points

Hello Heather,

You can try setting compileSdkVersion to 23 & targetSdkVersion to 23 in the app:module Gradle build file after making sure that the build tools for that Rev is installed in the SDK manager. However, if that does not resolve it then please try the following:

  • Make sure that you have the latest version of Android Studio: 1.3.2. You can see this as soon as you start Android Studio on the bottom left of Welcome to Android Studio window.
  • Once updated, Click on Configure -> SDK Manager
  • Make sure that Android SDK Platform-tools Rev 23 & Android SDK Build-tools Rev 23.0.1 are installed.
  • Scroll down to the bottom under Extras
  • Make sure that Android Support Repository Rev 19 & Android Support Library Rev 23.0.1 are installed.

Now go into project and edit the build.gradle file (app:module) and make it like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.heatcode.funfacts"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
}
  • Sync up by clicking on the Sync Project with Gradle Files button. It is next to the AVD button.

Please post back on the results.

Regards,

Chris

not exactly sure how to do that yet... but I attached the debugger to all aspects of the code and was given this message in the Debug console:

Connected to the target VM, address: 'localhost:8600', transport: 'socket'

Farouk Charkas
Farouk Charkas
1,957 Points

format the code by using that key above the tab key, and like these ```

I apologize I don't see a key? what part of the window is on?

Farouk Charkas
Farouk Charkas
1,957 Points

What computer do you have, or search it up on Google for the key "How to format code in Team Treehouse?"

I'm using window. Hold tight.

Farouk Charkas
Farouk Charkas
1,957 Points

I am using window too, it is above the tab key where two arrows are pointing in opposite directions, and it has an approximately something sign

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-release/frameworks/support/v7/appcompat/res/values-v23/styles_base_text.xml -->
    <eat-comment/>
    <style name="Base.TextAppearance.AppCompat.Widget.Button.Inverse" parent="android:TextAppearance.Material.Widget.Button.Inverse"/>
    <!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-release/frameworks/support/v7/appcompat/res/values-v23/themes_base.xml -->
    <eat-comment/>
    <style name="Base.Theme.AppCompat" parent="Base.V23.Theme.AppCompat"/>
    <style name="Base.Theme.AppCompat.Light" parent="Base.V23.Theme.AppCompat.Light"/>
    <style name="Base.V23.Theme.AppCompat" parent="Base.V22.Theme.AppCompat">
        <!-- We can use the platform drawable on v23+ -->
        <item name="actionBarItemBackground">?android:attr/actionBarItemBackground</item>

        <item name="controlBackground">@drawable/abc_control_background_material</item>
    </style>
    <style name="Base.V23.Theme.AppCompat.Light" parent="Base.V22.Theme.AppCompat.Light">
        <!-- We can use the platform drawable on v23+ -->
        <item name="actionBarItemBackground">?android:attr/actionBarItemBackground</item>

        <item name="controlBackground">@drawable/abc_control_background_material</item>
    </style>
    <!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-release/frameworks/support/v7/appcompat/res/values-v23/styles_base.xml -->
    <eat-comment/>
    <style name="Base.Widget.AppCompat.Button.Colored" parent="android:Widget.Material.Button.Colored"/>
</resources>

This is the values-v23.xml file

Farouk Charkas
Farouk Charkas
1,957 Points

Nice job formatting, but paste your MainActivity file

Ok this is the Java file:

package com.heatcode.funfacts;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class FunFactsActivity extends AppCompatActivity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_fun_facts, 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();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

This is the XML file

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".FunFactsActivity">

    <TextView
        android:text="Did You Know?"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="24sp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Did You Know Ants stretch when they wake up  in the morning?"
        android:id="@+id/factTextView"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textSize="24sp" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Show Another Fun Fact!"
        android:id="@+id/showFactButton"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    </RelativeLayout>

The errors seem to be tied to the: values-v23.xml file

Farouk Charkas
Farouk Charkas
1,957 Points

I think I know some people who can help you

Jon Kussmann and Gloria Dwomoh

Thanks. Should I contact them directly?

Farouk Charkas
Farouk Charkas
1,957 Points

I mean you can, but I have already summoned them by the @

Ok Awesome Thanks again! Can you tell it's my first time using the Forum? :)

Farouk Charkas
Farouk Charkas
1,957 Points

I figured, but do not feel down, at one time Mark Zuckerburg (Facebook Founder) and Bill Gates and Sergey Brin (Co-Founder of Google) and Larry Page (Co-Founder) were once learning if and else statements

That cleared up the issues! Thanks Guys!!