Android的工作室:意外顶级例外: [英] Android Studio : UNEXPECTED TOP-LEVEL EXCEPTION:

查看:236
本文介绍了Android的工作室:意外顶级例外:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能解决这个错误


  

错误:执行失败的任务:应用程序:dexDebug。
  com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:过程'命令'/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java'完成非零退出值2


应用程序的build.gradle

 应用插件:'com.android.application安卓{
compileSdkVersion 22
buildToolsVersion22.0.1
packagingOptions {
    排除META-INF /相关内容
    排除META-INF / ASL2.0
    排除META-INF /注意事项
    排除META-INF / NOTICE.txt
    排除META-INF / LICENSE
    排除META-INF / LICENSE.TXT
    排除META-INF / LICENSE.TXT
    排除META-INF / notice.txt
}defaultConfig {
    的applicationIDcom.app
    10的minSdkVersion
    targetSdkVersion 22
    版本code 1
    的versionName1.0
}buildTypes {
    发布 {
        minifyEnabled假
        proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
    }
}
}依赖{编译com.android.support:appcompat-v7:22.1.1'//不要使用22.2.0即使是较新的。据报道,导致一些问题的其他依赖。
编译文件树(导演:'库',包括:的* .jar)
编译('com.google.android.gms:播放服务:7.5 +。')
        {
            排除模块:支持-V4
        }
编译组:com.octo.android.robospice',名称:'robospice簧Android的版本:1.4.7编译com.octo.android.robospice:robospice簧安卓1.4.7编译组:,名'组织codehaus.jackson。':'杰克逊映射器-ASL',版本:1.9.11编译com.fasterxml.jackson.core:杰克逊 - 数据绑定:2.2.2编译com.fasterxml.jackson.core:杰克逊的注解:2.2.2编译com.fasterxml.jackson.core:杰克逊核心:2.2.2编译com.google code.gson:GSON:2.2.4编译com.octo.android.robospice:robospice-ormlite:1.4.6编译('org.simpleframework:简单的xml:2.7.1'){
//排除模块:'XPP3
//排除组:STAX
    排除组:XPP3',模块:'XPP3
    排除组:STAX,模块:STAX
    排除组:STAX,模块:STAX的API
}}

的gradle项目

  //顶级构建文件,您可以添加常用的配置选项,所有分项目/模块。buildscript {
库{
    jcenter()
}
依赖{
    类路径'com.android.tools.build:gradle:1.2.3    //注意:不要在这里把你的应用程序依赖关系;他们属于
    //在单个模块的build.gradle文件
}
}allprojects {
库{
    jcenter()
}
}

Android的Mainfest

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=com.app><! - 审批 - Internet连接 - >
<使用许可权的android:NAME =android.permission.INTERNET对/>
<使用许可权的android:NAME =android.permission.GET_ACCOUNTS/>
<使用许可权的android:NAME =android.permission.USE_CREDENTIALS/><! - 权限 - 位置 - GPS服务 - >
<使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/>
<使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/><! - 网络状态权限 - >
<使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
<使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/><! - 拨打电话权限 - >
<使用许可权的android:NAME =android.permission.CALL_PHONE/><应用
    机器人:名字=。app.AppHelper
    机器人:allowBackup =真
    机器人:图标=@绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>    <服务
        机器人:名字=com.octo.android.robospice.Jackson2SpringAndroidSpiceService
        机器人:出口=FALSE/>    &所述;元数据
        机器人:名字=com.google.android.gms.version
        机器人:值=@整数/ GOOGLE_PLAY_SERVICES_VERSION/>    &所述;元数据
        机器人:名字=com.google.android.maps.v2.API_KEY
        机器人:值=AIzaSyCU__5jhNC-QaU9tXNpr7ikPio3km1UYe8/>    <活动
        机器人:名字=。ui.splash.SplashActivity
        机器人:标签=@字符串/ APP_NAME
        机器人:noHistory =真
        机器人:screenOrientation =画像
        机器人:主题=@风格/ AppTheme>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;    <活动
        机器人:名字=。ui.base.BaseDrawerFragmentActivity
        机器人:configChanges =语言环境
        机器人:标签=
        机器人:launchMode =singleTask
        机器人:screenOrientation =画像
        机器人:主题=@风格/ AppTheme>
    < /活性GT;< /用途>

libs文件夹
没有libs文件夹存在现在


解决方案

欢迎。你在的gradle的Andr​​oid地狱的第一步。


  1. 在更新SDK管理器中你的Andr​​oid SDK组件,最新一期包括额外>谷歌存储(建议几乎所有的中添加额外的)。


  2. 让我们洗了当前的文件。


    • 的Andr​​oidManifest.xml :删除<采用-SDK ... /> 线。这是多余的,因为gradle这个文件已经定义了它。


    • 的build.gradle :评论均编译文件(库/ xxxxxxx.jar')线。第一行编译文件树(导演:'库',包括:['的* .jar'])将包括<为code>所有jar文件库文件夹中。而且,使用从Maven仓库编译为了保持你的依赖清爽不JAR文件。



例如,SimpleXML的具有如下存储库id。请将code以下的编译文件树(导演:'库',包括:['的* .jar'])行,并删除简单的XML-2.7 .1.jar在libs文件夹中的文件。

 编译('org.simpleframework:简单的xml:2.7.1'){
    排除模块:STAX
    排除模块:STAX的API
    排除模块:'XPP3
}

同样,找到每个jar文件的存储库id在你的libs文件夹并更换下的编译文件树中(导演:'库',包括:['的* .jar'])行一个接一个。只作jar文件找到Maven仓库这无法留在libs文件夹中。

最后,删除 proguardFiles 行。你需要找到并修复一般情况这个问题,以后再应用progruard。

<醇开始=3>
  • buildToolsVersion集版本,并compileSdkVersion到最新版本。

  • 我今天的建议是如下,结果
    (数字可能会有所不同,当有人看到这则讯息将来)

     安卓{
        compileSdkVersion 22
        buildToolsVersion '22 .0.1    dexOptions {
            preDexLibraries = FALSE
            javaMaxHeapSize2克
        }
        defaultConfig {
            ...
            multiDexEnabled = FALSE
        }
        lintOptions {
            abortOnError假
            禁用InvalidPackage
        }    ...
    }
    依赖{
        编译com.android.support:appcompat-v7:22.1.1'//不要使用22.2.0即使是较新的。据报道,导致一些问题的其他依赖。
        编译文件树(导演:'库',包括:的* .jar)
        编译('com.google.android.gms:播放服务-GCM:7.5 +。')
            {
                排除模块:支持-V4
            }
    }

    <醇开始=4>

  • 命令 gradle这个assembleDebug 一次。 (适用于Windows, gradlew assembleDebug


  • 如果再次失败,尝试查找并修复依赖版本冲突的问题一个接一个。在我的code ... :您可能会看到排除模块。这些解决冲突问题。详细说明的链接给出:<一href=\"http://stackoverflow.com/a/30649660/361100\">http://stackoverflow.com/a/30649660/361100


  • How Can I solve this error

    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

    App 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'
    }
    
    }
    

    Project 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 Folder No Libs Folder Exist Now

    解决方案

    Welcome. You are at the first step of Android gradle hell.

    1. Update your Android SDK components in SDK Manager to latest one including Extra > Google Repository (recommend to add almost all in Extra).

    2. Let's wash up your current file.

      • AndroidManifest.xml: Remove the <uses-sdk ... /> lines. It's redundant as gradle file already defines it.

      • Build.gradle: Comment all compile files('libs/xxxxxxx.jar') lines. The first line compile fileTree(dir: 'libs', include: ['*.jar']) will include all jar files in libs folder. And, use compile from maven repository not jar files in order to maintain your dependencies fresh.

    For example, SimpleXML has repository id as below. Place the code below of the compile fileTree(dir: 'libs', include: ['*.jar']) line and remove 'simple-xml-2.7.1.jar' file in libs folder.

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

    Likewise, find repository id of each jar file in your libs folder and replace it below of the compile fileTree(dir: 'libs', include: ['*.jar']) line one by one. Make only jar files which unable to find in maven repository remain in libs folder.

    Finally, remove proguardFiles line. You need to find and fix the problem in general condition, then apply progruard afterward.

    1. Set version of buildToolsVersion and compileSdkVersion to latest one.

    My recommendation of today is as below,
    (numbers may vary when someone will see this post in the future)

    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'
            }
    } 
    

    1. command gradle assembleDebug again. (for Windows, gradlew assembleDebug)

    2. If failed again, try to find and fix dependencies version conflict issues one by one. You may see exclude module: ... in my code. These resolve the conflict issue. Detailed instruction is given at the link: http://stackoverflow.com/a/30649660/361100

    这篇关于Android的工作室:意外顶级例外:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆