Unable to Sync Android Studio Gradle files in order to work JSON Serialization

35 Views Asked by At

So basically I am unable to get the imports for content negotiation json serialization even though I thought I had does all the necessary imports and plugins.This is the code that I am trying to ge tto work but dont have the imports to make work:

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

fun Application.proSubscriberApp() {
    install(ContentNegotiation) {
        json()
    }

    // Initialize services
    val userService = UserService()
    val planService = PlanService()
    val recommendationService = RecommendationService()
    val subscriptionService = SubscriptionService()
    val transactionService = TransactionService()

    // Configure routes
    routing {
        userRoutes(userService)
        planRoutes(planService)
        recommendationRoutes(recommendationService)
        subscriptionRoutes(subscriptionService)
        transactionRoutes(transactionService)
    }
}

Which made me think there is some problem with my gradle files.This is my project level gradle :

buildscript {
    dependencies {
        classpath("com.google.gms:google-services:4.4.1")
    }
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id("com.android.application") version "8.2.0"
    id("org.jetbrains.kotlin.android") version "1.9.22"
    id("com.google.gms.google-services") version "4.4.1"
}

and this is my module level gradle :

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.gms.google-services")
    kotlin("plugin.serialization") version "1.9.22"
}

android {
    namespace = "com.example.prosubscriberapp"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.prosubscriberapp"
        minSdk = 26
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.1"
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

val exposedLibraryVersion: String by project
val h2LibraryVersion: String by project

dependencies {

    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
    implementation("androidx.activity:activity-compose:1.8.2")
    implementation(platform("androidx.compose:compose-bom:2023.08.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 ("io.ktor:ktor-server-netty:2.3.7")
    implementation ("io.ktor:ktor-serialization:2.3.7")
    implementation ("mysql:mysql-connector-java:8.0.23")
    implementation("io.ktor:ktor-jackson:1.6.5")
    implementation ("io.ktor:ktor-server-core:2.3.7")
    implementation ("io.ktor:ktor-server-netty:2.3.7")
    implementation ("io.ktor:ktor-gson:2.3.7")
    implementation ("io.ktor:ktor-server-core:2.3.7")
    implementation ("io.ktor:ktor-server-netty:2.3.7")
    implementation ("io.ktor:ktor-locations:2.3.7")
    implementation ("io.ktor:ktor-features:2.3.7")
    implementation("com.google.apis:google-api-services-gmail:v1-rev110-1.31.0")
    implementation("com.google.api-client:google-api-client:1.31.0")
    implementation("com.google.oauth-client:google-oauth-client-jetty:1.31.0")
    implementation("com.google.apis:google-api-services-gmail:v1-rev110-1.31.0")
    implementation ("io.ktor:ktor-gson:1.7.4")
    implementation ("javax.sql:javax.sql-api:2.0.1")
    implementation ("org.jetbrains.exposed:exposed:0.33.2")
    implementation ("org.jetbrains.exposed:exposed-java-time:0.36.2")
    implementation("org.jetbrains.exposed:exposed-java-time:0.36.2")
    implementation("com.google.firebase:proto-lite-well-known-types:18.0.0")
    implementation ("mysql:mysql-connector-java:8.0.23")
    implementation ("org.jetbrains.exposed:exposed-core:0.41.1")
    implementation ("org.jetbrains.exposed:exposed-dao:0.41.1")
    implementation ("org.jetbrains.exposed:exposed-jdbc:0.41.1")
    implementation ("org.jetbrains.exposed:exposed:0.33.2")
    implementation ("org.jetbrains.exposed:exposed-java-time:0.36.2")
    implementation("org.jetbrains.exposed:exposed-java-time:0.36.2")
    implementation ("org.jetbrains.exposed:exposed-java-time:0.36.2")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22")
    implementation("org.jetbrains.exposed:exposed-core:0.41.1")
    implementation("org.jetbrains.exposed:exposed-dao:0.41.1")
    implementation("org.jetbrains.exposed:exposed-jdbc:0.41.1")
    implementation("org.jetbrains.exposed:exposed-java-time:0.36.2")
    implementation("org.jetbrains.exposed:exposed-core:0.41.1")
    implementation("org.jetbrains.exposed:exposed-dao:0.41.1")
    implementation("org.jetbrains.exposed:exposed-jdbc:0.41.1")
    implementation("mysql:mysql-connector-java:8.0.23")
    implementation("com.h2database:h2:2.1.214")
    implementation("com.jakewharton.threetenabp:threetenabp:1.3.7")
    implementation ("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.3")
    implementation("org.apache.mahout:mahout-math:0.13.0")
    implementation("org.apache.mahout:mahout-cf:0.14.0")
    implementation ("org.apache.commons:commons-lang3:3.12.0")
    implementation("org.apache.mahout:mahout-cf:0.14.0") // Adjust the version according to your Mahout version
    implementation ("org.apache.commons:commons-lang3:3.12.0")
    implementation ("org.apache.commons:commons-text:1.9")
    implementation ("io.github.pickle4j:pickle4j:1.3.0")
    implementation ("org.apache.mahout:mahout-cf:0.14.0")
    implementation ("org.apache.commons:commons-csv:1.8")
    implementation ("io.reactivex.rxjava3:rxjava:3.0.0")
    implementation ("io.reactivex.rxjava3:rxandroid:3.0.0")
    implementation ("commons-io:commons-io:2.11.0")
    implementation("io.ktor:ktor-client-core:1.7.4")
    implementation("io.ktor:ktor-client-json-jvm:1.7.4")
    implementation("io.ktor:ktor-client-serialization-jvm:1.9.22")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.22")
    implementation("io.ktor:ktor-client-content-negotiation:1.9.22")
    implementation("io.ktor:ktor-serialization-kotlinx-json:1.9.22")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
    implementation(platform("com.google.firebase:firebase-bom:32.7.2"))
    implementation("com.google.firebase:firebase-analytics")
    implementation("com.google.firebase:firebase-messaging:23.4.1")
    implementation("io.ktor:ktor-server-core-jvm:2.3.7")
    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.08.00"))
    androidTestImplementation("androidx.compose.ui:ui-test-junit4")
    debugImplementation("androidx.compose.ui:ui-tooling")
    debugImplementation("androidx.compose.ui:ui-test-manifest")

}

At This point after many different confusing changes with the plugins and gradle files , I get this error :Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

Which confuses me because i have specified the namespace.I am new to kotlin if you couldnt already tell.Please help

i tried this Choose only one version for the Kotlin plugins you are using, Remove the Kotlin JVM plugin, and Apply the Kotlin serialization plugin in your Android subproject. but this is what gave me the namespace error

0

There are 0 best solutions below