简体   繁体   English

Android Studio无法运行项目

[英]Android Studio unable to run the project

I am trying to build and run the a project which uses a library. 我正在尝试构建和运行一个使用库的项目。 It builds properly but when I try to run it, it throws me this error :- 它可以正确构建,但是当我尝试运行它时,会抛出此错误:-

: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

This is the build.gradle of my complete project :- 这是我完整项目的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"
        }
    }
}

This is the build.gradle of my Library :- 这是我的图书馆的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'
}

This is the build.gradle of my app :- 这是我的应用程序的build.gradle:-

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.igotgarbage.testapp"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    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.android.support:appcompat-v7:22.2.0'
    compile project(':app')
}

I have tried clean build on my project and everything which the related answers on SO have suggested. 我已经尝试在我的项目以及SO的相关答案所建议的所有内容上进行干净的构建。 But nothing is helping. 但是没有任何帮助。 Some proper answers would be really appreciated. 一些正确的答案将不胜感激。

  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
}

This exclusion might help and if lint creates some problem you can use the above "lintOptions" code. 此排除方法可能会有所帮助,如果lint造成了一些问题,则可以使用上面的“ lintOptions”代码。 One more thing you need to take care is, try to close all external applications so that you have free RAM to run and application.This error comes when your CPU usage reaches 100%. 您还需要注意的另一件事是,尝试关闭所有外部应用程序,以使您有可用的RAM来运行应用程序。当CPU使用率达到100%时,就会出现此错误。

If its not a memory issue as I mentioned.. try this: 如果它不是我提到的内存问题,请尝试以下操作:

File => Invalidate caches/restart File =>使高速缓存无效/重新启动

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

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