Bob*_*sik 279 android gradle android-gradle-plugin
这是我在Android Studio上的第一次尝试.我安装了0.8.0并更新到0.8.2.创建项目后,我收到错误消息:
错误:(1,0)找不到ID为'com.android.application'的插件
C:\用户\鲍勃\ AndroidStudioProjects\HelloAgain6 \程序\的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.bob.helloagain6"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Run Code Online (Sandbox Code Playgroud)
和C:\ Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
Jar*_*ows 427
最新Gradle: 5.1.1
版本检查:
./gradlew -v如何更新:
./gradlew wrapper --gradle-version=5.6.2 --distribution-type=all./gradlew wrapper最新的Android Gradle插件: 3.3.0
如果下面的代码片段添加到顶部您的build.gradle文件.Gradle将更新构建工具.
buildscript {
repositories {
google() // For Gradle 4.0+
maven { url 'https://maven.google.com' } // For Gradle < 4.0
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
Run Code Online (Sandbox Code Playgroud)
在这里阅读更多内容:https://developer.android.com/studio/build/index.html以及版本兼容性:https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle.
我有同样的错误,您需要确保您的Gradle版本与您的Android Gradle插件兼容.
最新版本的Gradle是2.0,但您需要使用1.12才能使用Android Gradle插件.
Ash*_*Ash 29
如果您错过了添加顶级构建文件,则会发生这种情况.
只需将build.gradle添加到顶级.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.xx.y'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Run Code Online (Sandbox Code Playgroud)
根 gradle 文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
Gradle-wrapper.properties 文件:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x-all.zip
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
349764 次 |
| 最近记录: |