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 (retired 2014) Pretty Little Things Adding an Image

My app is not working

My app is stuck and showing the message that the Unfortunately Crystal Ball has stopped working please help i want to learn and finish my course and start with my new skill very fast please help please

2 Answers

Calvin Nix
Calvin Nix
43,828 Points

Junaid,

By reviewing your AndroidManifest.xml file I believe I have found your issue.

android:theme="@android:style/Theme"

This needs to be...

android:theme="@style/AppTheme"

Thanksssssssssssss a lot it has started working thanks i will never forget what have you done to me, best wishes for your future from bottom of my heart ...... and stay with me for future help ... i want to become an android developer

Calvin Nix
Calvin Nix
43,828 Points

You are very welcome! Keep up the hard work.

Calvin Nix
Calvin Nix
43,828 Points

Hello Junaid,

Have you followed the "Teacher's Notes" under the video?

" Teacher's Notes Known Issues

Theme Error: The Android tools have been updated and the theme we use, Theme.Black.NoTitleBar.Fullscreen, may no longer work for you. If you run the app and get an error, you need to use the following workaround:

**Download files if you want to use these as replacements or for copy/paste: styles.xml | activity_main.xml

1) Change your project back to using "AppTheme" like it was before.

2) Add the following two lines to the file res/values/styles.xml(inside the <style name="AppTheme"> tag):

<item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item>

3) Set the background color to black in the file res/layout/activity_main.xml. The root element, RelativeLayout, is the one that makes up the whole screen. Add this line after the layout_height line but before the closing angle bracket >:

android:background="@android:color/black"

If you are having trouble with the Action Bar still showing, you may also need to change MainActivity to extend Activity, not ActionBarActivity. "

I added both the lines in the correct path but the app is still not working .....

Calvin Nix
Calvin Nix
43,828 Points

Did you also remember to edit you manifest?

What to Edit please help me!!!

Calvin Nix
Calvin Nix
43,828 Points

AndroidManifest.xml

If I recall correctly you edited that originally when you changed the theme. You will need to change that back to the original.

Yes i did it...Sorry i dint do it can you write the code to change it to app theme again

Calvin Nix
Calvin Nix
43,828 Points

I would recommend to re-trace your steps to ensure that you didn't miss any details. If that still doesn't work you can post styles.xml and activity_main.xml and I will take a look at it.

... android:theme="@android:style/app theme" > ... Its giving me an error

Calvin Nix
Calvin Nix
43,828 Points

I believe that is supposed to be android:theme="@android:style/AppTheme"

Its giving an error

Calvin Nix
Calvin Nix
43,828 Points

What does the error message say?

its saying no resource found with the name android:theme="@android:style/AppTheme"

Calvin Nix
Calvin Nix
43,828 Points

At the top of the graphical editor you should see an option to edit the Theme from there. Change the theme to AppTheme here instead of going through the XML file and doing it manually.

i will send you styles.xml and activity_main.xml please take a look at it

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
        <item name="android:windowNoTitle">true</item>
       <item name="android:windowFullscreen">true</item>
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

and my activity_main,xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@android:color/black" 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=".MainActivity" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:scaleType="fitCenter"
    android:src="@drawable/ball01" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:gravity="center_horizontal"
    android:shadowColor="@android:color/white"
    android:shadowRadius="10"
    android:textColor="@android:color/white"
    android:textSize="32sp" />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imageView1"
    android:layout_alignParentBottom="true"
    android:text="Enlighten ME!!!"
    android:textColor="#3f0f7f"
    android:textSize="24sp"
    android:textStyle="italic|bold"
    android:typeface="serif" />

</RelativeLayout>

Calvin Nix
Calvin Nix
43,828 Points

Those files appear to be correct. Please post your AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.crystallball" android:versionCode="1" android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme" >
    <activity
        android:name="com.example.crystallball.MainActivity"
        android:label="@string/app_name" android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.crystallball" android:versionCode="1" android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme" >
    <activity
        android:name="com.example.crystallball.MainActivity"
        android:label="@string/app_name" android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.crystallball" android:versionCode="1" android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme" >
    <activity
        android:name="com.example.crystallball.MainActivity"
        android:label="@string/app_name" android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>