当前位置: 首页 > 知识库问答 >
问题:

Gradle 7.1.0-alpha03和Composer的新Android项目无法构建

阮才俊
2023-03-14

所以我今天在Android studio中创建了一个新项目“2021.1.1金丝雀3”版本,但它无法正确构建我的项目。

> 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

这是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"
}

下面是我的Gradle的项目版本:

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

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

以下是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'

我也尝试过将静态编程语言的版本降低到1.5.0也不起作用,因为我已经搜索了很长一段时间,没有找到任何像我这样的东西,希望它可以向谷歌报告这个版本中的严重问题。

共有2个答案

关志
2023-03-14

我没有我的版本,它很好用。例如:

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

也许试试?

李光华
2023-03-14

好的,从现在到2021年7月23日,没有其他修复方法,你需要做的就是在gradle-wrapper.properties将Gradle版本降级到6.7.1,并将插件降级到4.2.2。此外,你必须清空你的gradle.setting,像以前一样使用Gradle,我在下面添加了我的,所以你也可以这样做:

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

设置。Gradle:

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

并删除所有其他内容。

建筑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项目,即使我编辑gradle属性,我也会得到以下错误: 我该如何解决这个问题?

  • ProjectConfigurationException:配置项目“:App”时出现问题。在org.gradle.configuration.project.lifecycleProjectEvaluator.addConfigurationFailure(lifecycleProjectEvaluator.java:94)在org.gradle.configuration.project.li

  • 我是新的和开始工作的基于项目,但面临一个问题时安装在项目级别(我使用Ide)。 composer安装--无交互--ansi 使用包信息加载composer存储库 从锁文件安装依赖项(包括需要开发) 没有要安装或更新的内容 生成优化的自动加载文件  过程:- 安装composer和wamp服务器 作曲家创建项目laravel/laravel 和项目创建与此错误和没有供应商文件夹创建 安装larave

  • 格拉德尔计划 应用程序Gradle 错误:配置根项目'webapp'时出现问题。 无法解决配置: classpath的所有依赖项。找不到com.android.tools.build: gradle: 3.0.0-alpha3。在以下位置搜索:file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/

  • 我已经用MFP做了几个项目,但今天早上我创造了一个全新的项目: 启动时,它运行,但随后在iPhone区域失败: 在多次重试之后,我只在这个区域得到错误。我可以确认该文件确实不存在,但我不知道为什么。

  • 由于butterknife依赖的错误,我无法构建android项目。 错误 任务': app: javaPreCompileDebug'执行失败。 无法解析配置的所有文件: app: dedegAnnotationProcessorClasspath。转换butterknife-compiler-8.6.0.jar失败(com.jakewharton:巴特切夫-编译器: 8.6.0)以匹配属性{a