Git Product home page Git Product logo

andfun-kotlin-android-trivia's Issues

NavigationUp

val navController = this.findNavController(R.id.myNavHostFragment)

For this code, below error is showing:
"

Type mismatch: inferred type is Int but View was expected ย 

"

deprecated way for options Menu

setHasOptionsMenu(true) is deprecated at title fragment
onCreateOptionsMenu is deprecated at title fragment
onOptionsItemSelected is deprecated at title fragment

Gradle sync failure. Could not find androidx.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07.

Adding the Up-Button causes app crashing

I had an issue with adding the Up-Button, where my App crashed with the message that my MainActivity would not have a NavController set.

I fixed this by accessing the navHostFragment directly:
// Delete this line
val navController = this.findNavController(R.id.myNavHostFragment)

//Replace it with:
val navHostFragment = supportFragmentManager.findFragmentById(R.id.myNavHostFragment) as NavHostFragment
val navController = navHostFragment.navController

//Continue with
NavigationUI.setupActionBarWithNavController(this, navController)

Can't use safe args

After adding safe-args dependency and plugins, there are no generated class.
GameFragmentDirections doesn't show up.

When I type below code in GameFragment Kotlin file, an error shows up at GameFragmentDirections. The error says unresolved references
(screenshot as below)

safe args issue

Unsolved referense

What is it supposed to refer to GameoverFragmentDirections, TitleFragmentDirections?

Fails to build in Android Studio 3.4, citing Gradle errors or IDE fatal error

This code does not build in Android Studio 3.4. It cites these Gradle errors if I choose "Don't remind me again for this project" when asked to update Gradle, as the lesson asks:

Screen Shot 2019-05-13 at 9 55 28 AM

When I do update Gradle contrary to the lesson plans, and then rebuild, I get this "IDE Fatal Error":

java.lang.IndexOutOfBoundsException: Index: 45, Size: 407
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at com.intellij.ui.speedSearch.FilteringListModel.getElementAt(FilteringListModel.java:111)
	at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1360)
	at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1311)
	at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:578)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1663)
	at com.intellij.ui.components.JBList.getPreferredSize(JBList.java:184)
	at javax.swing.JList.getScrollableTracksViewportWidth(JList.java:2772)
	at com.intellij.ui.components.JBScrollPane$Layout.preferredLayoutSize(JBScrollPane.java:699)
	at java.awt.Container.preferredSize(Container.java:1797)
	at java.awt.Container.getPreferredSize(Container.java:1781)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1665)
	at javax.swing.BoxLayout.checkRequests(BoxLayout.java:484)
	at javax.swing.BoxLayout.preferredLayoutSize(BoxLayout.java:301)
	at javax.swing.plaf.basic.DefaultMenuLayout.preferredLayoutSize(DefaultMenuLayout.java:60)
	at java.awt.Container.preferredSize(Container.java:1797)
	at java.awt.Container.getPreferredSize(Container.java:1781)
	at javax.swing.JComponent.getPreferredSize(JComponent.java:1665)
	at com.android.tools.adtui.stdui.DefaultLookupUI.getPopupSize(Lookup.kt:314)
	at com.android.tools.adtui.stdui.Lookup.computeLocation(Lookup.kt:221)
	at com.android.tools.adtui.stdui.Lookup.display(Lookup.kt:203)
	at com.android.tools.adtui.stdui.Lookup.updateFilter(Lookup.kt:107)
	at com.android.tools.adtui.stdui.Lookup.showLookup(Lookup.kt:70)
	at com.android.tools.adtui.stdui.CommonTextField$18.textChanged(CommonTextField.kt:78)
	at com.intellij.ui.DocumentAdapter.insertUpdate(DocumentAdapter.java:15)
	at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:201)
	at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:748)
	at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
	at javax.swing.text.PlainDocument.insertString(PlainDocument.java:130)
	at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:669)
	at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1330)
	at javax.swing.text.DefaultEditorKit$DefaultKeyTypedAction.actionPerformed(DefaultEditorKit.java:884)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2883)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2930)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2846)
	at java.awt.Component.processEvent(Component.java:6325)
	at java.awt.Container.processEvent(Container.java:2237)
	at java.awt.Component.dispatchEventImpl(Component.java:4903)
	at java.awt.Container.dispatchEventImpl(Container.java:2295)
	at java.awt.Component.dispatchEvent(Component.java:4725)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
	at com.intellij.ide.IdeKeyboardFocusManager.dispatchEvent(IdeKeyboardFocusManager.java:27)
	at java.awt.Component.dispatchEventImpl(Component.java:4774)
	at java.awt.Container.dispatchEventImpl(Container.java:2295)
	at java.awt.Window.dispatchEventImpl(Window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4725)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
	at java.awt.EventQueue$4.run(EventQueue.java:737)
	at java.awt.EventQueue$4.run(EventQueue.java:735)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:755)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:682)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:391)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I've been having a lot of trouble going through these lessons in Android Studio 3.4.

ActivityMainBinding and FragmentTitleBinding unresolved reference

I don't know if this only happened to me, but when I tried binding the layout to the TitleFragment, the com.example.android.navigation.databinding.ActivityMainBinding (in MainActivity.kt) and com.example.android.navigation.databinding.FragmentTitleBinding (in TitleFragment) imports were giving me an unresolved reference error and consequently a compilation error.

I fixed them by adding kapt "com.android.databinding:compiler:3.1.4" to the app build.gradle file and that seems to have done the trick, but given that I am somewhat of a novice I'm unsure whether it's just a quick fix or it was the right thing to do. Could you please confirm? Thanks.

Redundant code in GameFragment.kt (Branch: Step.03-Exercise-Conditional-Navigation)

// The first answer in the original question is always the correct one, so if our
// answer matches, we have the correct answer.
if (answers[answerIndex] == currentQuestion.answers[0]) {
questionIndex++
// Advance to the next question
if (questionIndex < numQuestions) {
currentQuestion = questions[questionIndex]
setQuestion()
binding.invalidateAll()
} else {

The code in line number 96 is redundant because the setQuestion() method also does that. (line 126)

private fun setQuestion() {
currentQuestion = questions[questionIndex]
// randomize the answers into a copy of the array
answers = currentQuestion.answers.toMutableList()

The code in the setQuestion() method can't be changed because it also sets the first question. Therefore it is better to remove the code in line 96.

Can't build the project as license for sdk is not accepted

Gradle sync shows error on startup

> Configure project :app
Checking the license for package Android SDK Build-Tools 28.0.3 in /Users/ishaansarna/Library/Android/sdk/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in /Users/ishaansarna/Library/Android/sdk/licenses
Warning: License for package Android SDK Platform 28 not accepted.
Aborting configuration as SDK is missing components in sync mode.

CONFIGURE SUCCESSFUL in 1s

Using Android Studio 4.0

AndroidX implementation

This project seems to use, old android versioning for navigation, thus, leading to lot's of confusion when on some exercise. Is there a way, we can rewrite the commit history and fix the versioning and move the code to proper AndroidX?

Step.09-Solution not working

It is giving java.lang.IllegalArgumentException: No drawer view found with gravity LEFT
and marking return NavigationUI.navigateUp(navController, drawerLayout) as the issue.

I tried everything like setting gravity to right|left or just left, even degrading the dependencies, but it's not working at all.

Please someone help as I wasted a lot of time with this.

Method onSupportNavigateUp: Sequence of method arguments interchanged

Sequence of method arguments interchanged:

Class:  MainActivity
Method: onSupportNavigateUp()

Change from:
return NavigationUI.navigateUp(drawerLayout, navController)
to:
return NavigationUI.navigateUp(navController, drawerLayout)

Branches affected:

Step.09-Solution-Adding-the-Navigation-Drawer
    Line 44
Step.10-Exercise-Using-Navigation-Listeners
    Line 48
Step.10-Solution-Using-Navigation-Listeners
    Line 54
Step.11-Exercise-Adding-Animation
    Line 54
Step.11-Solution-Adding-Animation
    Line 54

GameWonFragment compiler error when passing fragment in ShareCompat.IntentBuilder.from()

In GameWonFragment, in the fun getShareIntent the line:

return ShareCompat.IntentBuilder.from(activity)
                .setText(getString(R.string.share_success_text, args.numCorrect, args.numQuestions))
                .setType("text/plain")
                .intent

gives the error:
"Type mismatch. Required: Activity, Found: Fragment Activity?"
image

Error is in starter code branch, and Step 11 Solution Branch so I guess it is in every branch but I have not checked yet.

Can't add "layout_gravity" property to NavigationView in DrawerLayout

I get the following exception while clicking on hamburger icon:
java.lang.IllegalArgumentException: No drawer view found with gravity LEFT

Here is the activity_main.xml:

<androidx.drawerlayout.widget.DrawerLayout
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">

        <fragment
            android:id="@+id/myNavHostFragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            app:defaultNavHost="true"
            app:navGraph="@navigation/navigation"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </LinearLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/navView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:menu="@menu/navdrawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.