Closed BeepDroid closed 4 months ago
Hey Kerry, same here. Could you please just update the due date in the roadmap for it? Put the date that you expect to finish it.
I've updated the code to be prepared for Firebase implementation; however, I've started encountering errors due to missing dependencies. Resolving these both using manual input and Android Studios automatic resolution results in the same errors, current fix suggestions have to do with re-formatting my gradle.
Expected behavior is successful database connection; however, what's happening is a number of dependecy errors I still haven't found how to fix.
`dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.activity:activity-compose:1.8.0")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation ("com.google.firebase:firebase-database:24.0.0")
implementation("com.google.firebase:firebase-common:20.4.2")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}` Depencies in the Gradle build.
Code written for the connection that is providing errors: ` //Reference to the root of the Firebase RealTime Database DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
// This is for calling nodes in the database.
DatabaseReference shoppinglistRef = databaseReference.child("shoppinglist");
//Adding to the database
ShoppingSearchResult shoppinglist = new ShoppingSearchResult("Value1", 8.2); shoppinglistRef.push().setValue(shopplingList); `
Android Studio version 3.5, Windows OS.
I've looked up some resources that have mentioned my problem, a lot of them suggest reformatting the gradle file and restarting the IDE, or verifying my files. I unfortunately didn't have much time tonight to try these fixes after wrestling with the coding structure for a while, but I intend to try them out as soon as possible.
In progress
API - Edamam Shopping List - Class ApiAndDatabaseHandler
Description:
"ApiAndDatabaseHandler" is a java class that handles both the API call and the database operations. The "ApiTask AsyncTask" performs the API call in the background and then processes the result in the "onPostExecute" method. The parsed search results are then inserted into the existing database using the "insertDataIntoDatabase" method. The "DatabaseHelper" class is responsible for handling most of our Database logic, and it DOES at the moment use SQLLite just so I could get said logic written, and then update it with the appropriate Firebase logic.
Steps to Reproduce:
Expected vs. Actual Behavior:
Expected behavior: Successful connection to the database and uploading of data points to the appropriate columns.
Actual behavior: Encountering errors on database connection.
Code Snippets:
` private static class DatabaseHelper extends SQLiteOpenHelper {
This is the previously mentioned DatabaseHelper class that is going to be handling our database connection logic.
private class ApiTask extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... urls) { // Perform the API call in the background try { return makeApiCall(urls[0]); } catch (IOException e) { Log.e(TAG, "Error making API call", e); return null; } } }
Our ApiTask AsyncTask. What do these do? They handle our API call logic! The "ApiTask AsyncTask" performs the API call in the background and then processes the result in the "onPostExecute" method, shown below.protected void onPostExecute(String apiResult) { // Handle the API result and insert into the database if (apiResult != null) { List<ShoppingSearchResult> searchResults = parseApiResult(apiResult); insertDataIntoDatabase(searchResults); } else { Log.e(TAG, "API result is null"); } }
Environment Details:
Built in Android Studio, Windows OS.
Current Status:
In progress / Completed