【问题标题】:Android initial start-up安卓初始启动
【发布时间】:2016-09-21 04:23:26
【问题描述】:

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

错误信息(事件日志):

Gradle 同步失败:未找到 ID 为“com.android.applications”的插件。有关详细信息,请参阅 IDE 日志

这是当前项目(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
}

以及当前的Module(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 {
 }

【问题讨论】:

  • 我阅读了整个解决方案,但它无法正常工作@W4R10CK
  • 当你没有gradle库时,一般会出现这种情况,请尝试将其与googleplay库一起添加。
  • 将此添加到以下文件的依赖项中。 compile fileTree(include: ['*.jar'], dir: 'libs')testCompile 'junit:junit:4.12'
  • 嗯,是的,我尝试了 nitinsingh 尝试删除 gradle 目录并让 android 重新创建适当的 gradle,我发现您提到的相同依赖项出现在一个具有额外附加依赖项的新模块中,例如 compile 和 testCompile @W4R10CK

标签: java android android-gradle-plugin mobile-application android-sdk-tools


【解决方案1】:
  1. 创建一个名为“settings.gradle”的文件。

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

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

  4. 重新打开项目

【讨论】:

  • 抱歉,除了模块文件@HiteshLalwani 上缺少的依赖项之外,初始配置中确实存在此类文件
  • 在这种情况下,我认为你将不得不更新“gradle-wrapper.properties”distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
【解决方案2】:

试试这个

File -> Invalidate caches / Restart

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

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

重建项目....成功!

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

他们完全不同。!

【讨论】:

  • 大声笑...好吧,它是如何工作的:/出于好奇,您能澄清一下这种行为吗? @nitinsingh
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-05
  • 1970-01-01
相关资源
最近更新 更多