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 trialGuy Arnan
Courses Plus Student 6,300 PointsCannot find symbol variable showFactButtton?
I've typed the code exactly as it appears on screen, yet receive a compilation error stating that the compiler cannot find the symbol variable mShowFactButton. As a matter of fact, I also tried downloading and running the code provided in the Teacher's Notes and came down with the same error. I'd appreciate any help provided. Here's what my gradle console looks like: Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources]
Configuration on demand is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2321Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72321Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2321Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:preDebugAndroidTestBuild UP-TO-DATE :app:prepareDebugAndroidTestDependencies :app:compileDebugAndroidTestAidl UP-TO-DATE :app:processDebugAndroidTestManifest UP-TO-DATE :app:compileDebugAndroidTestRenderscript UP-TO-DATE :app:generateDebugAndroidTestBuildConfig UP-TO-DATE :app:generateDebugAndroidTestAssets UP-TO-DATE :app:mergeDebugAndroidTestAssets UP-TO-DATE :app:generateDebugAndroidTestResValues UP-TO-DATE :app:generateDebugAndroidTestResources UP-TO-DATE :app:mergeDebugAndroidTestResources UP-TO-DATE :app:processDebugAndroidTestResources UP-TO-DATE :app:generateDebugAndroidTestSources UP-TO-DATE
BUILD SUCCESSFUL
Total time: 4.038 secs Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2321Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72321Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2321Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJavaWithJavac C:\Users\guy\AndroidStudioProjects\FunFacts\app\src\main\java\com\guy\funfacts\FunFactsActivity.java:20: error: cannot find symbol mShowFactButton = (Button) findViewById(R.id.showFactButtton); ^ symbol: variable showFactButtton location: class id 1 error
FAILED
FAILURE: Build failed with an exception.
-
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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: 20.428 secs Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2321Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72321Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2321Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJavaWithJavac C:\Users\guy\AndroidStudioProjects\FunFacts\app\src\main\java\com\guy\funfacts\treehouseCopy.java:11: error: class FunFactsActivity is public, should be declared in a file named FunFactsActivity.java public class FunFactsActivity extends AppCompatActivity { ^ C:\Users\guy\AndroidStudioProjects\FunFacts\app\src\main\java\com\guy\funfacts\FunFactsActivity.java:21: error: cannot find symbol mShowFactButton = (Button) findViewById(R.id.showFactButtton); ^ symbol: variable showFactButtton location: class id 2 errors
FAILED
FAILURE: Build failed with an exception.
-
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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: 22.429 secs
3 Answers
Kourosh Raeen
23,733 PointsYou have three t's in showFactButtton:
mShowFactButton = (Button) findViewById(R.id.showFactButtton);
Guy Arnan
Courses Plus Student 6,300 PointsAbsolutely! "Error:(21, 53) error: cannot find symbol variable showFactButton"
And the console, if it helps: Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2321Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72321Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2321Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJavaWithJavac C:\Users\guy\AndroidStudioProjects\FunFacts\app\src\main\java\com\guy\funfacts\FunFactsActivity.java:21: error: cannot find symbol mShowFactButton = (Button) findViewById(R.id.showFactButton); ^ symbol: variable showFactButton location: class id 1 error
FAILED
FAILURE: Build failed with an exception.
-
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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: 2.595 secs
Many Thanks, your help is very much appreciated!
Kourosh Raeen
23,733 PointsDo you have a Button defined in the activity_fun_facts.xml file with the id showFactButton? There should be a line like this:
android:id="@+id/showFactButton"
Guy Arnan
Courses Plus Student 6,300 PointsOkay, yeah, so that was it. Thank you so much for your help, I really appreciate it!
Guy Arnan
Courses Plus Student 6,300 PointsGuy Arnan
Courses Plus Student 6,300 PointsYikes! Nice one. Unfortunately I'm still getting the compilation error, albeit for the double-t'ed showFactButton this time?
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsCan you post the error message?