2015-06-13 40 views
2

我怎樣才能解決這個錯誤Android的工作室:意外的頂級例外:

Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

應用的build.gradle

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 22 
buildToolsVersion "22.0.1" 


packagingOptions { 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/ASL2.0' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/license.txt' 
    exclude 'META-INF/notice.txt' 
} 

defaultConfig { 
    applicationId "com.app" 
    minSdkVersion 10 
    targetSdkVersion 22 
    versionCode 1 
    versionName "1.0" 
} 

buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 

compile 'com.android.support:appcompat-v7:22.1.1' // Do NOT use 22.2.0 even it is newer one. It reported to cause some problems with other dependencies. 
compile fileTree(dir: 'libs', include: '*.jar') 
compile('com.google.android.gms:play-services:7.5.+') 
     { 
      exclude module: 'support-v4' 
     } 
compile group:'com.octo.android.robospice', name:'robospice-spring-android', version:'1.4.7' 

compile 'com.octo.android.robospice:robospice-spring-android:1.4.7' 

compile group:'org.codehaus.jackson', name:'jackson-mapper-asl', version:'1.9.11' 

compile 'com.fasterxml.jackson.core:jackson-databind:2.2.2' 

compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.2' 

compile 'com.fasterxml.jackson.core:jackson-core:2.2.2' 

compile 'com.google.code.gson:gson:2.2.4' 

compile 'com.octo.android.robospice:robospice-ormlite:1.4.6' 

compile('org.simpleframework:simple-xml:2.7.1') { 
//  exclude module: 'xpp3' 
//  exclude group: 'stax' 
    exclude group: 'xpp3', module: 'xpp3' 
    exclude group: 'stax', module: 'stax' 
    exclude group: 'stax', module: 'stax-api' 
} 

} 

項目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:1.2.3' 

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

allprojects { 
repositories { 
    jcenter() 
} 
} 

的Android Mainfest

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.app" > 

<!-- Permission - Internet Connect --> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> 

<!-- Permission - Location - GPS Service --> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

<!-- Network State Permissions --> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

<!-- Call Phone Permissions --> 
<uses-permission android:name="android.permission.CALL_PHONE" /> 

<application 
    android:name=".app.AppHelper" 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme"> 

    <service 
     android:name="com.octo.android.robospice.Jackson2SpringAndroidSpiceService" 
     android:exported="false" /> 

    <meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 

    <meta-data 
     android:name="com.google.android.maps.v2.API_KEY" 
     android:value="AIzaSyCU__5jhNC-QaU9tXNpr7ikPio3km1UYe8" /> 

    <activity 
     android:name=".ui.splash.SplashActivity" 
     android:label="@string/app_name" 
     android:noHistory="true" 
     android:screenOrientation="portrait" 
     android:theme="@style/AppTheme"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name=".ui.base.BaseDrawerFragmentActivity" 
     android:configChanges="locale" 
     android:label="" 
     android:launchMode="singleTask" 
     android:screenOrientation="portrait" 
     android:theme="@style/AppTheme"> 
    </activity> 

</application> 

libs文件夾 沒有libs文件夾存在現在

+0

你問之前(而不是重複的問題,你應該把一個賞金對原來的問題)這個問題:http://stackoverflow.com/questions/29518323/android-studio -com-android-ide-common-process-processexception –

+0

或許你應該更新你的構建工具? 21.1.2是舊的,現在有22.0.1 – eriuzo

+0

@ Quintin Balsdon這是同樣的錯誤,但與另一個應用程序與另一個結構,所以我發佈它作爲另一個問題 –

回答

5

歡迎。你正處在Android gradle hell的第一步。

  1. 將SDK Manager中的Android SDK組件更新到最新版本,包括Extra> Google Repository(建議幾乎全部添加到Extra中)。

  2. 讓我們來洗你當前的文件。

    • AndroidManifest.xml中:刪除<uses-sdk ... />線。由於gradle文件已經定義了它,這是多餘的。

    • Build.gradle:評論全部compile files('libs/xxxxxxx.jar')行。第一行compile fileTree(dir: 'libs', include: ['*.jar'])將包含libs文件夾中的所有jar文件。並且,從maven repository中使用compile而不是jar文件,以保持新的依賴關係。

例如,SimpleXML的具有如下文庫標識。將代碼放在compile fileTree(dir: 'libs', include: ['*.jar'])行的下面,並在libs文件夾中刪除'simple-xml-2.7.1.jar'文件。

compile('org.simpleframework:simple-xml:2.7.1') { 
    exclude module: 'stax' 
    exclude module: 'stax-api' 
    exclude module: 'xpp3' 
} 

同樣地,發現在你的libs文件夾和一個替換它下面的compile fileTree(dir: 'libs', include: ['*.jar'])線一個的每個jar文件的存儲庫id。只允許在maven資源庫中找不到的jar文件保留在libs文件夾中。

最後,刪除proguardFiles一行。您需要在一般情況下查找並解決問題,然後應用progruard。

  1. 將buildToolsVersion和compileSdkVersion的版本設置爲最新版本。

我今天的建議是在如下狀態,
(數字可能會發生變化,當有人能看到此信息在未來)

android { 
    compileSdkVersion 22 
    buildToolsVersion '22.0.1' 

    dexOptions { 
     preDexLibraries = false 
     javaMaxHeapSize "2g" 
    } 
    defaultConfig { 
     ... 
     multiDexEnabled = false 
    } 
    lintOptions { 
     abortOnError false 
     disable 'InvalidPackage' 
    } 

    ... 
} 


dependencies { 
    compile 'com.android.support:appcompat-v7:22.1.1' // Do NOT use 22.2.0 even it is newer one. It reported to cause some problems with other dependencies. 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile('com.google.android.gms:play-services-gcm:7.5.+') 
     { 
      exclude module: 'support-v4' 
     } 
} 
再次
  • 命令gradle assembleDebug 。 (對於Windows,gradlew assembleDebug

  • 如果再次失敗,請嘗試逐個查找並修復依賴關係版本衝突問題。您可能會在我的代碼中看到exclude module: ...。這些解決了衝突問題。詳細指令在鏈接中給出:https://stackoverflow.com/a/30649660/361100

  • +0

    Youngjae檢查我更新的gradle,刪除所有庫,但仍然發生同樣的錯誤。 –

    +0

    @ahmedShoeib //先刪除'proguardFiles'行。而且,你是否繼續我推薦的第5號?如果是這樣,我建議你執行'gradle assembleDebug --stacktrace'並且準確地找到問題。您可以發佈'--stacktrace'或'--info'選項的失敗結果。 – Youngjae

    +0

    命令的結果./gradlew -q依賴關係應用程序:依賴關係 - 配置編譯:檢查此URL https://gist.github.com/ahmedshoeib/f433839f392e7a650eaa –

    1

    您是否嘗試過註釋掉你的build.gradle如下:

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

    參考:https://code.google.com/p/android/issues/detail?id=161605

    +0

    是的,我發現此頁之前,並測試如果我會做什麼,如果我評論此行,但沒有發生 –

    0

    同樣的錯誤,當我進口的所有的谷歌播放服務API,與您一樣

    compile('com.google.android.gms:play-services:7.5.+')

    嘗試刪除該行並僅導入您需要的服務API:Google Play Services Setup

    相關問題