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 Simple Android App (2014) Basic Android Programming Adding the onClick() Method

Steve Marreros Chuco
Steve Marreros Chuco
9,900 Points

processDebugManifest - I cannot run the app properly

Everytime I run my application at this point, it keeps showing the "Hello word" message from the beginning. I got this message at every run:

11:46:18 AM: Executing external task 'processDebugManifest'... Configuration on demand is an incubating feature. :app:preBuild :app:preDebugBuild :app:checkDebugManifest :app:preReleaseBuild :app:prepareComAndroidSupportAppcompatV72200Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42200Library UP-TO-DATE :app:prepareDebugDependencies :app:processDebugManifest UP-TO-DATE

BUILD SUCCESSFUL

Total time: 0.999 secs 11:46:19 AM: External task execution finished 'processDebugManifest'.

This what I have in gradle:

buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects { repositories { jcenter() } }

Could you post your java files?

6 Answers

Steve Marreros Chuco
Steve Marreros Chuco
9,900 Points

This is the java file James. file: FunFactsActivity.java

package com.steveleec.funfacts;

import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView;

import java.util.Random;

public class FunFactsActivity extends ActionBarActivity {

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

    //Declare our view variables
    /* Longer comments */
    final TextView factLabel = (TextView) findViewById(R.id.factTextView);
    Button showFactButton = (Button) findViewById(R.id.showFactButton) ;

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //The button was clicked, so update the factlabel wit new fact
            String fact = "";
            //Randomly select a fact
            Random randomGenerator = new Random();
            int randomNumber = randomGenerator.nextInt(3); //random number between 1 and 3.

// fact = randomNumber + "";

            String[] factsArray = new String[3];
            factsArray[0] = "Ants stretch when they wake up in the morning";
            factsArray[1] = "Ostriches can run faster than horses.";
            factsArray[2] = "Olympic gold medals are mostly made by silver.";

            fact = factsArray[randomNumber];
            //Update the label with a dynamic fact
            factLabel.setText(fact);
        }
    };
    showFactButton.setOnClickListener(listener);
}


@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);
}

}

I might also need your activity_fun_facts.xml file. I don't immediately see anything wrong in the java file, but I forgot to ask for the layout file. There is also a chance I'd need to see your AndroidManifest.xml file.

Steve Marreros Chuco
Steve Marreros Chuco
9,900 Points
<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"
                android:background="#ff51b46d">

    <TextView
        android:text="Did you know?"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        android:textSize="24sp"
        android:textColor="#80ffffff"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Ants strech when thwy wake up in the morning."
        android:id="@+id/factTextView"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textSize="24sp"
        android:textColor="@android:color/white"/>

    <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"
        android:background="@android:color/white"/>

</RelativeLayout>
Steve Marreros Chuco
Steve Marreros Chuco
9,900 Points
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.steveleec.funfacts" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".FunFactsActivity"
            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>

</manifest>

Hmm, I'm not seeing anything wrong. In fact, when I run this using a fresh project and copying and pasting your code in. It works perfectly fine. I hate to keep asking for more files, but how about your build.gradle for the app (there are two build.gradle files, the one you provide was the project level build.gradle). Otherwise, I'd suggest try building a new clean project and copying and pasting your code above in.

Steve Marreros Chuco
Steve Marreros Chuco
9,900 Points
//I will try to create new project if this doesn't work.
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.steveleec.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:22.0.0'
}

It runs as well for myself. Only other suggestion I could make to try to salvage this project is to try to go to Build, Clean Project. Then try running the project again.

Steve Marreros Chuco
Steve Marreros Chuco
9,900 Points

Thank you for you help James! I'll keep trying to fix it somehow.

I always forget about the second option besides just Clean Project. You could try File, Invalidate Caches/Restart and invalidate the caches and restart. This should hopefully clean out anything that Android Studio isn't wanting to update.