google-developer-training / android-basics-kotlin-create-dice-roller-with-button-app-solution Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
In which task and step of the codelab can this issue be found?
Enable auto imports
1 In Windows go to File > Other Setting > Setting for New Projects... .
Describe the problem
Path failure:
In my case path:
File > Settings > Editor > General > Auto Import
Steps to reproduce?
Versions
Android Studio version: Android Studio\bin\studio64.exe" download latest 4 days ago.
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Enable auto imports
Describe the problem
The second screenshot (https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button/img/f8ce3f7a514126b.png) is wrong.
The arrow points to wrong options for the java section (Classes and Static methods and fields instead Add unambiquous imports on the fly and optimize imports on the fly).
Steps to reproduce?
Versions
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Step 5
Describe the problem
Using the default AVD in Android Studio and running the App, Toast message will never display
Steps to reproduce?
Versions
Android Studio version: 4.1.3
API version of the emulator: 30
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Comment your code
Describe the problem
The documentation states, "Use the /** and **/ symbols at the beginning and end of your comment", but the example uses "*/" at the end of the comment.
In which task and step of the codelab can this issue be found?
Incorrect content
Describe the problem
There is no "File > New Project Settings > Preferences for New Projects" on MacOS
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Enable auto imports
Describe the problem
The windows path to enable auto import is shown as File > Other Setting > Setting for New Projects... . This is incorrect
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button
In which task and step of the codelab can this issue be found?
3. Create the layout for the app
Change the Button Text
3. "In the Component Tree, click on the orange triangle."
Describe the problem
Nothing happens. It's very difficult to make it happen, but moving the mouse back and forth will eventually display most of the window you say I should see, but moving a single pixel away or clicking makes it disappear.
And it does NOT have a "fix" button to press, even if it stayed visible long enough to press it.
Steps to reproduce?
Versions
Android Studio version: 4.2.2
API version of the emulator: n/a
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
rollButton.setOnClickListener {
val toast = Toast.makeText(this, "Dice Rolled!", Toast.LENGTH_SHORT)
toast.show()
}
and
Toast.makeText(this, "Dice Rolled!", Toast.LENGTH_SHORT).show()
Describe the problem
A toast message did not pop up at the bottom of the screen
Steps to reproduce?
Versions
Android Studio version: 4.1.3
API version of the emulator: Pixel 3 XL API 30
Additional information
Include screenshots if they would be useful in clarifying the problem.
Create the layout for the app
**Having a hardcoded string will make it harder to translate to other languages and to reuse string resources. but to resolve this issue the tutorial says to click on to the yellow triangle besides the view in the component tree window, however in my installed android studio version 4.2.2 the fix will be found by clicking on the yellow triangle found on top of the layout editor window named "toggle issue panel E" **
Steps to reproduce?
Versions
Android Studio version: 4.2.2
API version of the emulator:
In which task and step of the codelab can this issue be found?
Last block of step 4. Your program should look like this.
Describe the problem
after myFirstDice.sides = 20
should call diceRoll = myFirstDice.roll()
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Add conditional behavior in Kotlin.
6.Summary
see screenshot - formatting problem
Describe the problem
mistake of formatting
Steps to reproduce?
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
add the dice roll logic.
Describe the problem
when adding the private fun rollDice information the val dice = Dice(6) has an issue
the Dice is showing red and i'm unsure of what to do to make the application run.
Steps to reproduce?
Versions
Android Studio version: latest
API version of the emulator: 19.1 kit kat
Additional information
Include screenshots if they would be useful in clarifying the problem.
Task 4 last step
6 -> println("Apologies! you rolled a 6. Try again!")
After ending the sentence with ! you should start with a capital letter. It is a small mistake so please fix it.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button
In which task and step of the codelab can this issue be found?
Step 5
Describe the problem
You are still using findByViewId instead of View Binding. In fact, how is view Binding not the default? Seriously.
Steps to reproduce?
n/a
Versions
Android Studio version: 4.2.2
API version of the emulator: n/a
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Hi,
We're asked to change the button name to roll. I did that but when I clicked on the triangle error in the component tree, the triangle on the right of "button roll." When I clicked nothing happens.
Describe the problem
Expecting the "1 Warning" window to show up as described on website (or the "Extract Resource" window to show up when Alt+Enter is pressed) but no matter what I do, nothing happens.
Steps to reproduce?
Versions
Android Studio version: 4.2.2
build #AI-202.7660.26.42.7486908, built on June 23, 2021
Runtime version: 11.0.8+10+b944.6842174 and64
VM: OpenJDK 64-Bit Server VM by N/A
API version of the emulator:
Additional information
I tried using Alt+Enter to call up 'Extract Resource' window but doesn't work as well. This occur on 2 different windows 10 laptops that I'm using.
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
step: 6
Describe the problem
There is not really a bug here, but an update on the new Andriod studio. The "change to private" function does not really exist now, so it would be better to just type the private
word out for the val numSides
variable
Versions
Android Studio version:
Android Studio 4.1.2
Build #AI-201.8743.12.41.7042882, built on December 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6915495 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 2014M
Cores: 4
Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin
API version of the emulator: 30
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-conditional-dice-roll-behavior
In which task and step of the codelab can this issue be found?
step 6 Summary
Describe the problem
HTML encoding error in the last sample:
"matches-value ->
execute-this-code
"
must be:
matches-value -> execute-this-code
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
3. Create the layout for the app
4. Introduction to Activities
Describe the problem
There are a bunch of formatting errors in this doc
Steps to reproduce?
Additional information
Include screenshots if they would be useful in clarifying the problem.
I'm sure there will be more as I continue... Please have an editor go over these docs. It's very distracting.
P.S. The singular of dice is die not dice. If you have many dice and pick one out to roll, you're rolling one die.
URL of codelab
In which task and step of the codelab can this issue be found?
At the bottom of the message, under Suggested Fix, click the Fix button. (You may need to scroll down.)
The Extract Resource dialog opens. To extract a string means to take the "Roll" text and create a string resource called roll in strings.xml (app > res > values > strings.xml). The default values are correct, so click OK.
Describe the problem
There is no Fix button that shows up. The only way I could pull Extract Resource dialog is to open Problems tab on the bottom and Editor Preview has to be open.
Steps to reproduce?
Versions
Android Studio version: 4.2.1
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Hi, I'm learning on this, and it automatically sign me out, so I cannot sync progress and receive Badge to my profile.
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found? In the solution downloaded from github
Describe the problem There is no Toast in the solution; my written code didn't work, so I just downloaded the solution and there is no Toast action as described at URL: https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-four%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-create-dice-roller-app-with-button#4
I am completely inexperienced, so it has been hours trying to figure out what I did wrong. It looks like it is possible it wasn't me this time.
Steps to reproduce?
Additional information
Include screenshots if they would be useful in clarifying the problem.
I changed the code as follows and it worked:
// Set a click listener on the button to roll the dice when the user taps the button
rollButton.setOnClickListener {
rollDice()
val toast = Toast.makeText(this, "Dice Rolled!", Toast.LENGTH_SHORT)
toast.show()
}
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button#2
In which task and step of the codelab can this issue be found?
In the "Style the TextView" section.
Describe the problem
The following sentence is put in the code block, but it seems more appropriate to be in plain text:
"Note that because this text is only viewed by app developers, you don't need to make a string resource for it."
Steps to reproduce?
As stated above
Versions
Not applicable.
Additional information
Nil.
URL of codelab
Create an interactive Dice Roller app
In which task and step of the codelab can this issue be found?
Add a button to an app > Create an interactive Dice Roller app > Enable auto imports
Describe the problem
The Auto Import setting position has been moved from Other Settings > Auto Import
to Editor > General > Auto Import
.
Versions
Android Studio version: 4.1.3
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-four%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-create-dice-roller-app-with-button#1
In which task and step of the codelab can this issue be found?
Set up your app. The second step.
Describe the problem
When I am creating a new project, I am not able to run the dice roller application on my android studio. It leads me to have to "declare a repository". Thus, I am not able to continue to learn how to program. Please help me out with this.
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Enable auto imports
In Windows go to File > Other Setting > Setting for New Projects... .
Describe the problem
I follow the above-mentioned
process but that is not correct there is no such option as Other Setting in file, and also if I choose settings in the file and then go to other settings then there is no Setting new projects option, instead 3 options as Clang-Tidy, Clangd, Kotlin Compiler.
Steps to reproduce?
Versions
Android Studio version: 4.2.1
API version of the emulator: Android 10.0
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
val rollButton: Button = findViewById(R.id.button) //switched to
val rollButton = findViewById(R.id.button)
val resultTextView: TextView = findViewById(R.id.textView) //switched to
val resultTextView = findViewById(R.id.textView)
Solution Code Url
**Solution Code Will Not Compile on my Android galaxy s8 **
Steps to reproduce?
19 kit kat
Android Studio version: 4.1.3
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
After reaching the end of the codelab there is no continue button to move to the next section i,e we need to go back to the main page in order to access the next section
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
> used to show a > but it doesn't show > just >. I am using google dev browser and haven't checked in other browsers.
It is in the summery when showing how a when statement works.
I know its only small, but someone who doesn't know much about programming it would probably confuse after using it the correct way in Kotlin playground. Hope you don't mind me pointing it out.
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Codelab: Creating an interactive Dice Roller app
Task: Introduction to Activities
Step: 4
Describe the problem
Missing line between the end of step 3 and the beginning of step 4
Steps to reproduce?
N/A
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
Create an interactive Dice Roller Part 6
In step 3, the code is written val diceRoll = dice.roll(), and this is repeated at the end of step 5. The code should instead be val diceRoll = Dice.roll(), otherwise the Gradle build will fail
Steps to reproduce?
Versions
_Android Studio version: 4.2.1
_API version of the emulator:30
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-dice-roller-images#0
In which task and step of the codelab can this issue be found?
2.1
Describe the problem
I have downloaded and opened the project from Github. The app should look like at the lesson, but it doesn't, there is a message on grey background: "Design editor is unavailable until next gradle sync."
I'm beginner and I don't know what does it mean and how to resolve the problem and build the project.
Steps to reproduce?
Versions
Android Studio version: 4.0.1
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Inside 'Create an interactive Dice Roller app' > 7th step > Comment your code
Describe the problem
Typo found as this '/** and /', this is a commend symbol, but the correct way is '/ and */'.
One star at the end required.
In which task and step of the codelab can this issue be found?
6 Add the dice roll logic
2 Notice that Android Studio may underline numSides with a wavy gray line. (This may take a moment to appear.)
5 Convert diceRoll to a string and use that to update the text of the resultTextView.
Describe the problem
No gray line under numSides (Studio Android), I cannot put it in private.
Studio Android doesnt recognize "Dice" as a reference.
Steps to reproduce?
Versions
Android Studio version: Yes
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
In the code
Describe the problem
The code us missing the () after the setOnClickListener
Instead of putting the (), the text just goes straight to {} which does not compile because we have to define the setOnLickListener as a function
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
step 6:
Describe the suggestion
It is great that you are introducing scoping here, but is it really necessary for the code to work in this case? I was able to compile and run without using the public / private scoping
I am providing this input here so that the new aspiring Android / kotlin developers dont get bogged down by the details of scoping and can get their apps out fast (and with less compile time errors)
Thanks again for the developer resources, they are super useful ❤️
In which task and step of the codelab can this issue be found?
Introduction to Activities > Enable auto imports, step 1.
Describe the problem
Step 1. The described method to display the "Preferences for New Projects" dialog reflects the OSX version of Android Studio (File > New Project Settings > Preferences for New Projects)
For the Windows version the method is different: File > Other Settings > Settings for New Projects...
This displays the "Setting for New Projects" dialog.
Steps to reproduce?
Described above (use Windows version).
Versions
Android Studio version: 4.0.2 (Windows)
API version of the emulator: N/A
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Step 4 Introduction to Activities
Enable auto imports
Describe the problem
Not sure about the macOS menus but it seems the Windows menu sequence should be File > New Projects Settings > Settings for New Projects
Steps to reproduce?
Versions
Android Studio version: 4.1.3
API version of the emulator: 29
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Enable auto imports, paragraph 1.
In Android Studio, open the settings by going to File > New Project Settings > Preferences for New Projects on macOS. In Windows go to File > Other Setting > Setting for New Projects... .
Need to change Other Setting to New Project Settings.
Steps to reproduce?
Versions
Android Studio 4.1.3
Additional information
In which task and step of the codelab can this issue be found?
Whole task
Describe the problem
The codelab uses the word "Dice" to refer to a single Die
The correct singular form of "Dice" is "Die"
Steps to reproduce?
Grammatical Error
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
In which task and step of the codelab can this issue be found?
Describe the problem
Steps to reproduce?
Versions
Android Studio version:
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
In "Add conditional behavior in Kotlin" please correct this.
matches-value ->
execute-this-code
matches-value ->
execute-this-code
Describe the problem
only a small problem that -> must be greater than right?
(not a big issue; Hope you forgive if i am disturbing)
Thank you
URL of codelab
link
In which task and step of the codelab can this issue be found?
Step 6 - Summary
Describe the problem
The illustrative description of a when
statement is rendering incorrectly:
Steps to reproduce?
when
is showcased `matches-value ->` *`execute-this-code`*
Versions
n/a
Additional information
expected fix: Should probably see something like matches value
-> execute this code
URL of codelab
In which task and step of the codelab can this issue be found?
In the step 5 "Make Button Interactive"
Describe the problem
When I run the project there is a notification in 'Event log'
Session 'app': Installation did not succeed.
The application could not be installed: SHELL_UNRESPONSIVE
Retry
Versions
_Android Studio version:_11
API version of the emulator: 30
Additional information
Include screenshots if they would be useful in clarifying the problem.
In which task and step of the codelab can this issue be found?
Enable auto imports, Step 1.
Describe the problem
The instructions to enable imports for Windows is incorrect. I am using Windows and found the information by using the instructions listed for MacOS
Steps to reproduce?
Instructions for Windows in Codelab: In Windows go to File > Other Setting > Setting for New Projects..
Versions
Android Studio version: 4.1.1
API version of the emulator:
Additional information
Include screenshots if they would be useful in clarifying the problem.
URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-create-dice-roller-app-with-button#6
In which task and step of the codelab can this issue be found?
Step: 7. Adopt good coding practices
Describe the problem
This step recommends reformatting …
rollButton.setOnClickListener {
rollDice()
}
to …
rollButton.setOnClickListener { rollDice() }
However, this reformatting seems to be against the following from the Kotlin style guide.
Line break after the opening brace.
Line break before the closing brace.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.