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
Gast贸n Yelmini
2,758 PointsFunFacts App running error
Hi,
I have a problem when running the FunFacts App. I get this errors in the console:
- Error:(38) Error parsing XML: no element found
Grande Console:
-
What went wrong: Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.62 secs
My code is:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_fun_facts" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="ar.com.tunegocioenlinea.funfacts.FunFactsActivity" android:background="#51b46d">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Did you know? "
android:textSize="24sp"
android:textColor="@color/colorAccent" />
<TextView
android:text="Ants strech when they wake up in the morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/factTextView"
android:textSize="24sp"
android:textColor="@android:color/white" />
<Button
android:text="Show Another Fun Fact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/showFactButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
package ar.com.tunegocioenlinea.funfacts;
import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;
public class FunFactsActivity extends AppCompatActivity {
// Declare our view variable
private TextView mFactTextView;
private Button mShowFactButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fun_facts);
// Assing the views from the layout file to the correspondante value
mFactTextView = (TextView)findViewById(R.id.factTextView);
mShowFactButton = (Button) findViewById(R.id.showFactButton);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
//The button was clicked so update the fact TextView with a new fact
String fact = "Ostriches can run faster than horses.";
mFactTextView.setText(fact);
}
};
mShowFactButton.setOnClickListener(listener);
}
}
Thanks for your help
Gast贸n Yelmini
2,758 PointsGast贸n Yelmini
2,758 PointsI solved it! I was just misssing the </RelativeLayout> tag at the end of the XML file.