在android studio中构建失败

时间:2015-11-19 11:42:10

标签: android android-studio gradle build.gradle

当我在线学习时,我收到此错误。

Error:Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Task 'testClasses' not found in project ':ProwessPride_V1.01'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

ProwessPride_V1.01 是我在项目中包含的jar文件。

我在工作室中使缓存/重新启动无效。重建和清理项目也,但我无法解决此错误。所以请帮助我如何解决它。

的build.gradle

     apply plugin: 'com.android.application'

        android {
            compileSdkVersion 23
            buildToolsVersion "23.0.0"

            defaultConfig {
                applicationId "com.example.technopits.dcn"
                minSdkVersion 17
                targetSdkVersion 23
                versionCode 1
                versionName "1.0"
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
        }

        dependencies {
            compile fileTree(include: ['*.jar'], dir: 'libs')
            compile 'com.android.support:appcompat-v7:23.0.0'
            compile 'com.android.support:recyclerview-v7:23.0.0'
            compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
            compile 'com.google.android.gms:play-services-gcm:7.3.0'
            compile project(':ProwessPride_V1.01')
        }

buil.gradle项目

//顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

2 个答案:

答案 0 :(得分:1)

按照以下步骤操作:

  1. 撤消在添加库时所做的任何更改(删除所有依赖项或JAR)
  2. 拖动n将jar文件放在libs文件夹中(在android studio中)
  3. 清洁构建

答案 1 :(得分:1)

定义compile project(':ProwessPride_V1.01'),gradle正在settings.gradle 中搜索具有相同名称的项目。

因为它是一个罐子是错误的。

只需删除此行。

compile project(':ProwessPride_V1.01')

如果你在libs文件夹中添加jar,这行就足够了。

compile fileTree(include: ['*.jar'], dir: 'libs')