简体   繁体   English

安卓初始启动

[英]Android initial start-up

I have just installed Android and all relative tools required to run android development.我刚刚安装了 Android 和运行 android 开发所需的所有相关工具。 Unfortunately at the initial build of Gradle sync, event log prints out an error message不幸的是,在 Gradle 同步的初始构建中,事件日志会打印出一条错误消息

Error message (Event log):错误信息(事件日志):

Gradle sync failed: Plugin with id 'com.android.applications' not found. Gradle 同步失败:未找到 ID 为“com.android.applications”的插件。 Consult IDE Log for more details查阅 IDE 日志了解更多详情

Here's is the current Project (build.gradle) My application configuration:这是当前的 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
}

And the current Module (build.gradle) configuration:以及当前的模块(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 {
 }

Try this尝试这个

File -> Invalidate caches / Restart

Shutdown Android Studio Rename/remove .gradle folder in the user home directory关闭 Android Studio 重命名/删除用户主目录中的.gradle文件夹

Restart Android Studio let it download all the Gradle stuff it needs Gradle build success !重新启动 Android Studio 让它下载它需要的所有 Gradle 东西 Gradle 构建成功!

Rebuild project.... success !重建项目....成功!

Out of curiousity I compared the structure of the old .gradle and the new one.出于好奇,我比较了旧的.gradle和新的结构。

they were pretty different.!他们很不一样。!

  1. make a file named "settings.gradle".制作一个名为“settings.gradle”的文件。

  2. add this line to this file -> include ':app'将此行添加到此文件 -> 包含 ':app'

  3. copy this file to the root directory of your project.将此文件复制到项目的根目录。

  4. Re-open project重新打开项目

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

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