0

I am trying to migrate my gradle files to move from using buildscript{} to use plugins {}, however I am struggling to understand what I am doing wrong.

Here is my build.gradle (Project) - note I have commented out elements which I believe are no longer required:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
    id 'com.android.application' version '8.1.0' apply false
    id 'com.android.library' version '8.1.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}

repositories {
    mavenCentral()
    google()
}

//plugins {
//    id 'com.google.gms.google-services'
//    id 'androidx.navigation:navigation-safe-args-gradle-plugin'
//    id 'org.jetbrains.kotlin:kotlin-gradle-plugin'
//    id 'com.android.tools.build:gradle:8.1.0'
//}

//buildscript {
//
//
//
//    dependencies {
//
//        classpath 'com.google.gms:google-services:4.3.15'
//        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0'
//        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
//        classpath 'com.android.tools.build:gradle:8.1.0'
//
//        // NOTE: Do not place your application dependencies here; they belong
//        // in the individual module build.gradle files
//    }
//}

//allprojects {
//    repositories {
//        google()
//        mavenCentral()
//        maven { url 'https://developer.android.com/studio/build/repository' }
//
//
//    }
//}


//
//task clean(type: Delete) {
//    delete rootProject.buildDir
//}

Here is my build.gradle(App):

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}


android {
    namespace '_____________'
    compileSdk 33

    defaultConfig {
        applicationId "_____________"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

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

    buildTypes {
        release {
            minifyEnabled 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.3.2'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.10.1'
    implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
    implementation 'androidx.activity:activity-compose:1.7.2'
    implementation platform('androidx.compose:compose-bom:2023.06.01')
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.material3:material3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'


    implementation 'androidx.activity:activity-ktx:1.7.2'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.appcompat:appcompat-resources:1.6.1'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    // Lifecycle
    implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1" //https://www.simplifiedcoding.net/firebase-mvvm-example/

    // Compose
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3'
    implementation 'androidx.compose.material3:material3:1.1.1'
    implementation "androidx.compose.material:material-icons-extended"
    implementation 'androidx.compose.material:material:1.4.3'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    debugImplementation 'androidx.compose.ui:ui-tooling:1.4.3'
    debugImplementation 'androidx.compose.ui:ui-test-manifest:1.4.3'

    // Navigation
    implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.6.0'

    // Testing
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    testImplementation 'junit:junit:4.13.2'

    // Add the SDKs for any other Firebase products you want to use in your app
    // For example, to use Firebase Authentication and Cloud Firestore
    implementation 'com.google.firebase:firebase-firestore:24.7.0'
    implementation 'com.google.firebase:firebase-auth:22.1.1'
    implementation 'com.google.firebase:firebase-messaging:23.2.1'
    implementation 'com.google.firebase:firebase-core:21.1.1'
    implementation 'com.google.firebase:firebase-storage:20.2.1'
    implementation 'com.google.android.gms:play-services-auth:20.6.0'

    // Add the Firebase SDK for Google Analytics
    implementation 'com.google.firebase:firebase-analytics:21.3.0'

    // Material Dialogs (https://github.com/afollestad/material-dialogs, recommended by CodingWithMitch https://www.youtube.com/watch?v=_sOHZAk6KnA)
    implementation 'com.afollestad.material-dialogs:core:3.3.0'
    implementation 'com.afollestad.material-dialogs:input:3.3.0'
    implementation 'com.afollestad.material-dialogs:datetime:3.3.0'

//    // Picasso
//    implementation 'com.squareup.picasso:picasso:2.71828'

    //anko https://www.youtube.com/watch?v=uB7WeED1d1w
//    implementation "org.jetbrains.anko:anko:0.10.4"
//    implementation "org.jetbrains.anko:anko-design:0.10.4"
//    implementation "org.jetbrains.anko:anko-coroutines:0.10.4"

    // Material Dialogs (https://github.com/afollestad/material-dialogs, recommended by CodingWithMitch https://www.youtube.com/watch?v=_sOHZAk6KnA)
    implementation 'com.afollestad.material-dialogs:input:3.3.0'
    implementation 'com.afollestad.material-dialogs:lifecycle:3.3.0'

    // debugImplementation because LeakCanary should only run in debug builds.
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'

    // Couroutines Dependency
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
    
}

Here is my settings.gradle:

//https://developer.android.com/build/migrate-to-kotlin-dsl#migrate-buildscript
pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

include ':app'
rootProject.name='_______'

I am getting the following errors which I can't see how to solve:

    Configuration cache state could not be cached: field `__librarySourceSets__` of task `:app:mapDebugSourceSetPaths` of type `com.android.build.gradle.tasks.MapSourceSetPathsTask`: error writing value of type 'org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection'
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-tooling because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-test-manifest because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-tooling:1.4.3 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-test-manifest:1.4.3 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency com.squareup.leakcanary:leakcanary-android:2.12 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.core:core-ktx:1.10.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency org.jetbrains.kotlin:kotlin-bom:1.8.0 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.activity:activity-compose:1.7.2 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose:compose-bom:2023.06.01 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-tooling-preview because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.material3:material3 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.activity:activity-ktx:1.7.2 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.appcompat:appcompat:1.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.appcompat:appcompat-resources:1.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.multidex:multidex:2.0.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.legacy:legacy-support-v4:1.0.0 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.lifecycle:lifecycle-runtime-compose:2.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.lifecycle:lifecycle-runtime-ktx:2.6.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-graphics because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.ui:ui-tooling-preview:1.4.3 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.material3:material3:1.1.1 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.material:material-icons-extended because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.compose.material:material:1.4.3 because no repositories are defined.
     Required by:
         project :app
   > Cannot resolve external dependency androidx.cardview:cardview:1.0.0 because no repositories are defined.
     Required by:
         project :app  //more of these!!
Scamparelli
  • 756
  • 1
  • 12
  • 28

0 Answers0