8

so I've created a new project in Android studio today "2021.1.1 Canary 3" version, but it won't build my project correctly.

> Build file 'C:\Users\Arash\Desktop\JPCompose\app\build.gradle' line: 2
> 
> Plugin [id: 'com.android.application', version: '7.1.0-alpha03'] was
> not found in any of the following sources:
> 
> * Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.
> 
> * Exception is: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.application', version: '7.1.0-alpha03'] was not
> found in any of the following sources:
> 
> - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
> - Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.1.0-alpha03')
> Searched in the following repositories:
>     Gradle Central Plugin Repository
>     Google
>     MavenRepo

Here is the App version of Gradle:

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

android {
    compileSdk 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.arash.afsharpour.jpcompose"
        minSdk 21
        targetSdk 30
        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 compose_version
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-alpha06'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
}

and this below is the Project version of my Gradle:

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

buildscript {
    ext {
        compose_version = '1.0.0-beta09'
    }
}

this below is the settings.gradle:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    plugins {
        id 'com.android.application' version '7.1.0-alpha03'
        id 'com.android.library' version '7.1.0-alpha03'
        id 'org.jetbrains.kotlin.android' version '1.5.10'
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "JPCompose"
include ':app'

I've also tried lowering the version of Kotlin to 1.5.0 didn't work either, and as I've been searching for this quite a while now and didn't find anything remotely like what I'm having, hopefully, it can be report to google for this serious problem in this version.

Arash Afsharpour
  • 1,282
  • 11
  • 22

2 Answers2

6

okay, as of now July 23rd, 2021 there's no other fix and All you need to do is Downgrade the Gradle version to 6.7.1 in gradle-wrapper.properties and downgrade the plugin to 4.2.2. also, you have to empty your gradle.setting and use the Gradle like old times, I've added mine down below so you can do the same:

gradle-wrapper.properties:

distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Setting.Gradle:

include ':app'
rootProject.name = "YourProjectName"

and remove all else.

build.gradle (project):

buildscript {
    ext.compose_version = "1.0.0-rc02"
    ext.kotlin_version = "1.5.10"
    ext.room_version = "2.3.0"
    ext.dagger_hilt_version = "2.37"
    ext.coroutines_version = "1.5.0"
    ext.navigation_components_version = "2.3.5"
    ext.glide_version = "4.11.0"
    ext.java_version = JavaVersion.VERSION_1_8

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_components_version"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$dagger_hilt_version"
    }

}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

hope it helps you go on. Happy Coding

Arash Afsharpour
  • 1,282
  • 11
  • 22
0

I don't have the versions on mine and it works fine. Like:

    plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

Maybe try that?

Code Poet
  • 6,222
  • 2
  • 29
  • 50
  • already have those plugins, it seems its a bigger problem with Gradle itself with some libraries – Arash Afsharpour Jul 18 '21 at 14:29
  • 1
    Try decreasing Gradle version to 7.1.0-alpha01 in build.gradle file and increase Compose version to 1.0.0-rc02 –  Jul 19 '21 at 01:25
  • @Unknown Yes tried it and it worked, downgraded from 71.0 to 6.7.1 and 4.2.2 in the plugin version, also I've moved everything from setting.Gradle file to build.Gradle file like old times, it seems it's a Gradle problem. – Arash Afsharpour Jul 19 '21 at 16:59
  • Welcome Happy Composing –  Jul 20 '21 at 01:17