New Android project with Gradle 7.1.0-alpha03 and Composer doesn#39;t build(使用Gradle 7.1.0-alpha03和Composer的新Android项目没有构建)
问题描述
所以我今天在Android Studio中创建了一个新项目&2021.1.1 Canary 3";版本,但它无法正确构建我的项目。
> Build file 'C:UsersArashDesktopJPComposeappuild.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
Gradle的App版本如下:
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"
}
以下是My Gradle的项目版本:
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
ext {
compose_version = '1.0.0-beta09'
}
}
以下是设置。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'
我也尝试过将Kotlin版本降至1.5.0也不起作用,由于我已经搜索了很长时间,也没有找到任何像我现在这样的东西,希望这个版本能报告给谷歌这个严重的问题。
Gradle
好的,截至2021年7月23日没有其他修复程序,您所需做的就是在<推荐答案-wrapper.Properties中将Gradle版本降级至6.7.1,并将插件降级至4.2.2。此外,您还必须清空您的Gradle.Setting并像以前一样使用Gradle,我在下面添加了我的Gradle.Setting,这样您也可以这样做:
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"
并删除所有其他内容。
build.gradle(项目):
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
}
希望它能帮助你继续前进。快乐编码
这篇关于使用Gradle 7.1.0-alpha03和Composer的新Android项目没有构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!