Coder Social home page Coder Social logo

android-basics-kotlin-bus-schedule-app's Introduction

Bus Scheduler App

This folder contains the source code for the Bus Scheduler app codelab.

Introduction

The Bus Scheduler app displays a list of bus stops and arrival times. Tapping a bus stop on the first screen will display a list of all arrival times for that particular stop.

The bus stops are stored in a Room database. Schedule items are represented by the Schedule class and queries on the data table are made by the ScheduleDao class. The app includes a view model to access the ScheduleDao and format data to be display in a list, using Flow to send data to a recycler view adapter.

Pre-requisites

  • Experience with Kotlin syntax.
  • Familiarity with activities, fragments, and recycler views.
  • Basic knowledge of SQL databases and performing basic queries.

Getting Started

  1. Install Android Studio, if you don't already have it.
  2. Download the sample.
  3. Import the sample into Android Studio.
  4. Build and run the sample.

android-basics-kotlin-bus-schedule-app's People

Contributors

android-dev-lxl avatar osuleymanova avatar yenerm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

android-basics-kotlin-bus-schedule-app's Issues

Android Basics: Introduction to Room and Flow

Issue:
In the portion of the codelab labeled Create an Entity I run into to an error with the data keyword. In the Problems tab I get the error message "Expecting a top level declaration: 8". I tried redoing the codelab but the same issue persists.

Images from Android Studio:
Screen Shot 2021-07-15 at 3 15 35 PM
Screen Shot 2021-07-15 at 3 14 56 PM

Issue downloading `starter` branch

Whenever you try to download the starter app in GitHub, the main branch is downloaded instead. All the changes are already done for the codelab. The only way I could get around it was to copy and change the URL to say "starter" rather than "main."

Android Basics: Introduction to Room and Flow

recyclerView = binding.recyclerView
recyclerView.layoutManager = LinearLayoutManager(requireContext())
val busStopAdapter = BusStopAdapter({})
recyclerView.adapter = busStopAdapter
busStopAdapter.submitList(viewModel.scheduleForStopName())

last string replace for
usStopAdapter.submitList(viewModel.scheduleForStopName(stopName))

Execution failed for task :app:kaptDebugKotlin

URL of codelab
URL

In which task and step of the codelab can this issue be found?
All the steps

Describe the problem
This problem is also present in the other CodeLab about Sql basics

Steps to reproduce?

  1. Error is generated when Building

Versions
_Android Studio version: Artic Fox 2020.3.1 Patch3
_API version of the emulator: API31
_ Using Mac M1

Additional information

Execution failed for task ':app:kaptDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
java.lang.reflect.InvocationTargetException (no error message)
.
.
.

Caused by: java.lang.Exception: No native library is found for os.name=Mac and os.arch=aarch64. path=/org/sqlite/native/Mac/aarch64
at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:333)
at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:64)
at androidx.room.verifier.DatabaseVerifier.(DatabaseVerifier.kt:71)

StackTrace included

StackTrace.txt

Data changes using Flow: Android Basics: Introduction to Room and Flow

In the instructions for changing the FullScheduleFragment it says:

Replace the line.

busStopAdapter.submitList(viewModel.fullSchedule())

With this code that uses the flow returned from fullSchedule().

lifecycle.coroutineScope.launch {
   viewModel.fullSchedule().collect() {
       busStopAdapter.submitList(it)
   }
}

When it should say to replace the entire GlobalScope function.
The same goes for the StopScheduleFragment section

Android Basics: Introduction to Room and Flow

It seems as if there's a typo in step 6 of the "Introduction to Room and Flow" Codelab.

"As the ViewModel class BusScheduleViewModel needs from is meant to be lifecycle aware, it should be instantiated by an object that can respond to lifecycle events."
image

Android Basics: Introduction to Room and Flow (ViewRootImpl$CalledFromWrongThreadException)

URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-intro-room-flow?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-5-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-intro-room-flow#7

In which task and step of the codelab can this issue be found?
Step 7, "Take a moment to run the app and you should see a list of arrival times"

Describe the problem
On running the app in the emulator, it terminates immediately with the following error in Logcat:

2021-11-19 10:42:59.802 5772-5798/com.example.busschedule E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
    Process: com.example.busschedule, PID: 5772
    android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
        at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8798)
        ...
        at com.example.busschedule.FullScheduleFragment$onViewCreated$1.invokeSuspend(FullScheduleFragment.kt:75)
        ...
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

Steps to reproduce?
Follow tutorial as described.

Versions
Android Studio version: Android Studio Arctic Fox | 2020.3.1 Patch 3
API version of the emulator: 30

Additional information
Include screenshots if they would be useful in clarifying the problem.
The referenced code block which is causing the crash:
image

Option to hide the top bar or make it thinner

The document font is too small, so if I zoom the page in, the top bar gets thicker, taking up limited vertical space of modern wide-screen monitors. I do not think the top bar serves any useful features for the most people. How about providing a feature to hide that top bar?

image

Android Basics: Introduction to Room and Flow

In 8. create the ListAdapter

at point 6
recyclerView = binding.recyclerView recyclerView.layoutManager = LinearLayoutManager(requireContext()) val busStopAdapter = BusStopAdapter({}) recyclerView.adapter = busStopAdapter busStopAdapter.submitList(viewModel.scheduleForStopName())

viewModel.scheduleForStopName() will not run because scheduleForStopName() function require a stop name and even if I edit this and send stopName as parameter the app does not run it crashes on load

Android Basics: Introduction to Room and Flow

The code in Number 6 requires a parameter

...
recyclerView.adapter = busStopAdapter
busStopAdapter.submitList(viewModel.scheduleForStopName())

Instead of

...
recyclerView.adapter = busStopAdapter
busStopAdapter.submitList(viewModel.scheduleForStopName(stopName))

Occasional crash in FullScheduleFragment.kt & StopScheduleFragment.kt due to UI updation from background thread

In FullScheduleFragment.kt the line
GlobalScope.launch(Dispatchers.IO) { busStopAdapter.submitList(viewModel.fullSchedule()) }
In StopScheduleFragment.kt the line
GlobalScope.launch(Dispatchers.IO) {busStopAdapter.submitList(viewModel.scheduleForStopName(stopName)) }

sometimes crash. Resolved by calling submlitList using Dispatchers.main:

GlobalScope.launch(Dispatchers.IO) {
val fullSchedule = viewModel.fullSchedule()
launch(Dispatchers.Main) {busStopAdapter.submitList(fullSchedule)}
}

Android Basics: Introduction to Room and Flow

GlobalScope.launch(Dispatchers.IO) is causing an exception [Only the original thread that created a view hierarchy can touch its views.] with Kotlin version "1.6.21" this can cause some confusion in inexperienced developers in the basic training. This issue is fixed when we use Flow later in the same training.

I think is good to have some advice in the course about this error.

Android Basics: Introduction to Room and Flow

Create list adapter
at the end
"Now that you've set up the adapter, you're done integrating Room into the Bus Schedule app. Take a moment to run the app and you should see a list of arrival times. Tapping on a row should navigate to the detail screen."
Got error

FATAL EXCEPTION: main
    Process: com.example.busschedule, PID: 22917
    java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

in main branch

        lifecycle.coroutineScope.launch {
            viewModel.fullSchedule().collect() {
                busStopAdapter.submitList(it)
            }
        }

But in course there is none

        recyclerView.adapter = busStopAdapter
        busStopAdapter.submitList(viewModel.fullSchedule())

soz you have to use something like this:

        lifecycleScope.launch {
            busStopAdapter.submitList(viewModel.fullSchedule())
        }

and in viewModel sort of:

    suspend fun fullSchedule(): List<Schedule> = withContext(Dispatchers.IO) {
        scheduleDao.getAll()
    }

Android Basics: Introduction to Room and Flow

In chapter 6, the sentance is a little hard to read seemingly because of typos.
image

Also the boilerplate code at the end of chapter 6 is quite hard to understand. I think it would be nice to add a bit of explanation.
image

Update dependencies to resolve app build errors on Mac M1

URL of codelab

In which task and step of the codelab can this issue be found?

Step 7

Describe the problem

App doesn't build due to outdated dependencies on Mac M1

Steps to reproduce?

Pre-requisites:

  • Mac with M1 chip with Android Studio
  1. Download the starter code and complete steps until step 7, then try to build the app
    OR
    Download the solution code and try to build the app

Notes

The starter app builds just fine until implementing Step 7 where we add everything to retrieve data from database.

I've downloaded the solution code from main branch and tried to build the app - I got the same errors.

I was able to successfully run solution code and then the starter code after updating the dependencies and manifest file.

Solution

Update gradle and manifest files to use the latest stable versions of dependencies.

In build.gradle (Project):

buildscript {
    ext {
        kotlin_version = "1.6.10" // old version: 1.3.72
        room_version = '2.4.1' // old version: 2.3.0 
...
    }
}

In build.gradle (Module):

android {
    compileSdkVersion 31 // old version: 30
    ...
    defaultConfig {
         ...
         targetSdkVersion 31 // old version: 30
       ...
     }
}

In AndroidManifest.xml:

<activity
            android:name="com.example.busschedule.MainActivity"
            android:exported="true" > // add this line 

I've also upgraded gradle when Android studio suggested this, but I couldn't capture all the details of the automated changes.

Android Basics: Introduction to Room and Flow

The base project just won't build.
It says "Unable to load class 'build_4ei2j6orgipxqxl9qkqwlur0o'.

This is an unexpected error. Please file a bug containing the idea.log file."

Android Basics: Introduction to Room and Flow

in StopScheduleFragment where you create the bindings, an argument should be passed into viewModel.scheduleForStopName.
the argument is obviously the stopName, but it doesn't show there in the code lab.

snippet from the code lab:
recyclerView = binding.recyclerView
recyclerView.layoutManager = LinearLayoutManager(requireContext())
val busStopAdapter = BusStopAdapter({})
recyclerView.adapter = busStopAdapter
busStopAdapter.submitList(viewModel.scheduleForStopName())

what should really be the smippet:
recyclerView = binding.recyclerView
recyclerView.layoutManager = LinearLayoutManager(requireContext())
val busStopAdapter = BusStopAdapter({})
recyclerView.adapter = busStopAdapter
busStopAdapter.submitList(viewModel.scheduleForStopName(stopName))

Missing database.schedule package as described in codelab

URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-intro-room-flow?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-5-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-intro-room-flow#3

In which task and step of the codelab can this issue be found?
4

Describe the problem
"To create an entity for the "schedule" table, in the database.schedule package, create a new file called Schedule.kt and define a data class called Schedule."

  • There is no database.schedule package in the Starter app

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions
Android Studio version:
API version of the emulator:

Additional information
Include screenshots if they would be useful in clarifying the problem.
Screenshot (8)

Android Basics: Introduction to Room and Flow

Inside onCreate() in the StopScheduleFragment,
busStopAdapter.submitList(viewModel.scheduleByStopName()) should be called instead as :
busStopAdapter.submitList(viewModel.scheduleByStopName(stopName))
I am not sure but most probably this is correct!

image

Step 8: Accessing database on main thread leads to app crash


name: 'Android Basics: Introduction to Room and Flow issue template'
about: 'Cannot access database on the main thread.'
title: 'Android Basics: Introduction to Room and Flow'
labels: ''
assignees: ''


URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-training-intro-room-flow?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-5-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-intro-room-flow#7

In which task and step of the codelab can this issue be found?
8 - 4. (really 9, also bad numbers on indexes)Finally, to update a list view, call submitList(), passing in the list of bus stops from the view model
8- 11 Then configure the recycler view in onCreate(). This time you just need to pass in an empty block (function) with {}. You don't actually want anything to happen when rows on this screen are tapped.

Describe the problem
these lines code
busStopAdapter.submitList(viewModel.scheduleForStopName())
busStopAdapter.submitList(viewModel.fullSchedule())
java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
no sure but need to run it on corouitines? (only that way i make it work)
also the onCreate() of 8 - 11 (onViewCreated)

Steps to reproduce?
complete the codelabs to the poit 8 inclusive 6/12 inclusive

Versions
_Android Studio version:_4.2.1
API version of the emulator: 28

Additional information

Android Basics: Introduction to Room and Flow

First of all thank you very much for the elaborate tutorial on Room in Android.

The code of FullScheduleFragment didn't compile on my side when I changed the code to use Flow.

Step:

[9. Respond to data changes using Flow]
When replacing the existing code to load the data with the following I had an error saying Unresolved reference: collect

lifecycle.coroutineScope.launch {
viewModel.fullSchedule().collect() {
busStopAdapter.submitList(it)
}
}

So after looking at the solution code I found I had to add the import kotlinx.coroutines.flow.collect -- this was not a suggestion of Android Studio. So I suggest you add this instruction in the tutorial.

Also it is not clear at all for me lifecycle is and why we would need to use it but I understand this aspect might go further than what the tutorial is intended to.

Thanks again

Update Kotlin version to be compatible with latest Android Studio version

  1. Create the ListAdapter

Mistake 1:
Then configure the recycler view in onCreate()
We should configure the recycler view in onViewCreated()

Mistake 2:
busStopAdapter.submitList(viewModel.scheduleForStopName())
We should pass stopName to scheduleForStopName

Suggestion:
At the beginning of the tutorial add a note that needs to change the version of Kotlin in the Gradle. Android Studio did not work correctly for me

Android Basics: Introduction to Room and Flow: 8. Create the ListAdapter

at the end of this step there is a point 7: Now that you've set up the adapter, you're done integrating Room into the Bus Schedule app. Take a moment to run the app and you should see a list of arrival times. Tapping on a row should navigate to the detail screen.

The app doesn't start as fo this error:

2021-10-21 12:21:44.373 6418-6418/com.example.busschedule E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.busschedule, PID: 6418
    java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
        at androidx.room.RoomDatabase.assertNotMainThread(RoomDatabase.java:385)
        at androidx.room.RoomDatabase.query(RoomDatabase.java:441)
        at androidx.room.util.DBUtil.query(DBUtil.java:83)
        at com.example.busschedule.database.schedule.ScheduleDao_Impl.getAll(ScheduleDao_Impl.java:29)
        at com.example.busschedule.viewmodels.BusScheduleViewModel.fullSchedule(BusScheduleViewModel.kt:9)
        at com.example.busschedule.FullScheduleFragment.onViewCreated(FullScheduleFragment.kt:71)
        at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2987)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
        at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
        at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:3065)
        at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2988)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
        at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
        at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:501)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:246)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1433)
        at android.app.Activity.performStart(Activity.java:7986)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3677)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

This error also affects the execution of step 9 - the beginning of this step.

Missing mention of entity table name

@Entity
data class Schedule(
   @PrimaryKey val id: Int,
   @NonNull @ColumnInfo(name = "stop_name") val stopName: String,
   @NonNull @ColumnInfo(name = "arrival_time") val arrivalTime: Int
)

as 'schedule' as table name is used in Dao class.
@entity(tableName="schedule") should be mentioned.

Android Basics: Introduction to Room and Flow

Attempting to run the app after the step "Create the ListAdapter' I encounter the following error output:

/Users/user/AndroidStudioProjects/android-basics-kotlin-bus-schedule-app-starter/app/build/tmp/kapt3/stubs/debug/com/example/busschedule/database/schedule/ScheduleDAO.java:11: error: cannot find symbol
    public abstract java.util.List<Schedule> getAll();
                                   ^
  symbol:   class Schedule
  location: interface ScheduleDAO/Users/user/AndroidStudioProjects/android-basics-kotlin-bus-schedule-app-starter/app/build/tmp/kapt3/stubs/debug/com/example/busschedule/database/schedule/ScheduleDAO.java:15: error: cannot find symbol
    public abstract java.util.List<Schedule> getByStopName(@org.jetbrains.annotations.NotNull()
                                   ^
  symbol:   class Schedule
  location: interface ScheduleDAO/Users/user/AndroidStudioProjects/android-basics-kotlin-bus-schedule-app-starter/app/build/tmp/kapt3/stubs/debug/com/example/busschedule/viewmodels/BusScheduleViewModel.java:10: error: cannot find symbol
    public final java.util.List<Schedule> fullSchedule() {
                                ^
  symbol:   class Schedule
  location: class BusScheduleViewModel/Users/user/AndroidStudioProjects/android-basics-kotlin-bus-schedule-app-starter/app/build/tmp/kapt3/stubs/debug/com/example/busschedule/viewmodels/BusScheduleViewModel.java:15: error: cannot find symbol
    public final java.util.List<Schedule> scheduleForStopName(@org.jetbrains.annotations.NotNull()
                                ^
  symbol:   class Schedule
  location: class BusScheduleViewModel/Users/user/AndroidStudioProjects/android-basics-kotlin-bus-schedule-app-starter/app/build/tmp/kapt3/stubs/debug/com/example/busschedule/database/schedule/AppDatabase.java:5: error: cannot find symbol

Android Basics: Introduction to Room and Flow

After finishing Create The ListAdapter code, I can't run my app on device and give me below Exception.

FATAL EXCEPTION: main
Process: com.example.busschedule, PID: 15586
java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.

Is it normal? I am not sure this step can run safely in device.

Android Basics: Introduction to Room and Flow

In step 8: "8. Create the ListAdapter" there is typo in code in last string in point 6 (Then configure the recycler view in onViewCreated(). This time you just need to pass in an empty block (function) with {}. You don't actually want anything to happen when rows on this screen are tapped.):

recyclerView = binding.recyclerView
recyclerView.layoutManager = LinearLayoutManager(requireContext())
val busStopAdapter = BusStopAdapter({})
recyclerView.adapter = busStopAdapter
// this is a string with typo. Must be: busStopAdapter.submitList(viewModel.scheduleForStopName(stopName)) 
busStopAdapter.submitList(viewModel.scheduleForStopName()) 

Android Basics: Introduction to Room and Flow

This codelab is using ViewModelProvider class and the Factory design pattern while both are never mentioned in previous codelabs nor properly introduced in this one. Also there are many grammar/typo mistakes present.
The mentioned problems make understanding this codelab difficult for learners.

Android Basics: Introduction to Room and Flow

In section 4: Create an Entitiy, it is stated, "To create an entity for the "schedule" table, in the database.schedule package, create a new file called Schedule.kt and define a data class called Schedule."

There is not a "database.schedule" package within the Project Manager. My assumption is that it is referencing "assets/database", but this needs to be clarified.

Step 8: Accessing database on main thread leads to app crash

Followed instructions as provided. App crashes while testing the result of Step 8.

I compared my code to the main code and apart from the Flow introductions in Step 9 is the same.

Error given by the debugger is:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.busschedule, PID: 26884
java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
at androidx.room.RoomDatabase.assertNotMainThread(RoomDatabase.java:385)
at androidx.room.RoomDatabase.query(RoomDatabase.java:441)
at androidx.room.util.DBUtil.query(DBUtil.java:83)
at com.example.busschedule.database.schedule.ScheduleDao_Impl.getAll(ScheduleDao_Impl.java:29)
at com.example.busschedule.viewmodel.BusScheduleViewModel.fullSchedule(BusScheduleViewModel.kt:10)
at com.example.busschedule.FullScheduleFragment$onViewCreated$1.invokeSuspend(FullScheduleFragment.kt:77)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:342)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:27)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:49)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
at com.example.busschedule.FullScheduleFragment.onViewCreated(FullScheduleFragment.kt:76)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2987)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
at androidx.fragment.app.FragmentManager.dispatchViewCreated(FragmentManager.java:3065)
at androidx.fragment.app.Fragment.performViewCreated(Fragment.java:2988)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:501)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:246)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425)
at android.app.Activity.performStart(Activity.java:7825)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Android Basics: Introduction to Room and Flow

Just letting you know that the package database.schedule doesn't exist in this project. There is only a database package located in the assets directory and no subdirectory or package named schedule within it. Should we just create a directory within database called schedule or create a new package altogether within java called database.schdule?

These are the instructions I'm referring to:

"Note that the SQL types used in the database are actually INTEGER for Int and TEXT for String. When working with Room, however, you should only be concerned with the Kotlin types when defining your model classes. Mapping the data types in your model class to the ones used in the database is handled automatically.

To create an entity for the "schedule" table, in the database.schedule package, create a new file called Schedule.kt and define a data class called Schedule."

Android Basics: Introduction to Room and Flow

Hello i started learning kotlin like 4 monnths ago and i reached this unit about SQL and dataBase but i've noticed along the journy that the courses are not updated tpo my current version of andriod studio and i listed some of the problems or isuues i faced :

1- the imports are automatic but not alawys the right ones
2- the gradel version always not up to date which causes some issues during compling and building apps
3-sometimes but not always the steps on the lesson can misslead instad of guid you throw the lesson
4- id the same exact steps but i don't get the same results as the solution codes

if any one can help it will be much apreshiated

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.