Android Studio无法运行该项目

时间:2015-06-09 11:31:58

标签: android android-studio gradle

我正在尝试构建并运行一个使用库的项目。它构建正确,但是当我尝试运行它时,它会抛出这个错误: -

String  myLabel = 
    "<html>" + 
        label.getText() + 
        "<br/><br/>" +
        (String)boxTimes.getSelectedItem() + " - " + input + 
    "</html>;

label.setText(myLabel);

这是我整个项目的build.gradle: -

:testapp:preDexDebug                 
warning: Ignoring InnerClasses attribute for an anonymous inner class
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 57 more
Caused by: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_09\bin\java.exe'' finished with
 non-zero exit value 1
        at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:42)
        at com.android.builder.core.AndroidBuilder.preDexLibrary(AndroidBuilder.java:1296)
        at com.android.builder.internal.compiler.PreDexCache.preDexLibrary(PreDexCache.java:122)
        at com.android.builder.core.AndroidBuilder.preDexLibrary(AndroidBuilder.java:1248)
        at com.android.builder.core.AndroidBuilder$preDexLibrary$10.call(Unknown Source)
        at com.android.build.gradle.tasks.PreDex$PreDexTask.call(PreDex.groovy:150)
        at com.android.build.gradle.tasks.PreDex$PreDexTask.call(PreDex.groovy)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        ... 3 more
Caused by: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_09\bin\java.exe'' finished with non-zero exit value 1
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
        at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:40)
        ... 14 more

这是我的图书馆的build.gradle: -

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter{
            url "http://jcenter.bintray.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'

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

allprojects {
    repositories {
        mavenLocal()
        maven{
            url "D:/mavenrepository-new"
        }
        maven{
            url "http://bridge.mindtree.com/nexus/content/repositories/igg-releases/"
        }
        jcenter{
            url "http://jcenter.bintray.com"
        }
    }
}

这是我的应用的build.gradle: -

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        preDexLibraries = false
    }
    defaultConfig {
        multiDexEnabled true
    }
    lintOptions {
        abortOnError true
    }
    packagingOptions {
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.mindtree.bridge.framework:CoreAPI:1.0.0'
    compile 'com.mindtree.bridge.framework:bridge-account-lib:2.0.0'
    compile 'com.mindtree.bridge.platform:BRBASE-generated-java-api:2.0.0'
}

我已经尝试过对我的项目进行干净的构建以及SO上的相关答案所提出的所有内容。但没有任何帮助。一些正确的答案将非常感激。

2 个答案:

答案 0 :(得分:3)

  packagingOptions {
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/spring.schemas'
    exclude 'META-INF/spring.handlers'
    exclude 'META-INF/spring.tooling'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/dependencies.txt'
}

lintOptions {
    abortOnError false
}

这种排除可能有所帮助,如果lint产生了一些问题,你可以使用上面的&#34; lintOptions&#34;码。还需要注意的一件事是,尝试关闭所有外部应用程序,以便运行和应用程序可以使用RAM。当CPU使用率达到100%时会出现此错误。

答案 1 :(得分:0)

如果它不是我提到的内存问题那么试试这个:

File =&gt;无效的缓存/重启