繁体   English   中英

安卓初始启动

[英]Android initial start-up

我刚刚安装了 Android 和运行 android 开发所需的所有相关工具。 不幸的是,在 Gradle 同步的初始构建中,事件日志会打印出一条错误消息

错误信息(事件日志):

Gradle 同步失败:未找到 ID 为“com.android.applications”的插件。 查阅 IDE 日志了解更多详情

这是当前的 Project (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:2.1.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
    repositories {
    jcenter()
  }
}

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

以及当前的模块(build.gradle)配置:

 apply plugin: 'com.android.application'

 android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

 defaultConfig {
    applicationId "com.example.user.myapplication"
    minSdkVersion 9
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
 }
 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
        'proguard-rules.pro'
      }
  }
 }

 dependencies {
 }

尝试这个

File -> Invalidate caches / Restart

关闭 Android Studio 重命名/删除用户主目录中的.gradle文件夹

重新启动 Android Studio 让它下载它需要的所有 Gradle 东西 Gradle 构建成功!

重建项目....成功!

出于好奇,我比较了旧的.gradle和新的结构。

他们很不一样。!

  1. 制作一个名为“settings.gradle”的文件。

  2. 将此行添加到此文件 -> 包含 ':app'

  3. 将此文件复制到项目的根目录。

  4. 重新打开项目

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM