java - Android Studio : UNEXPECTED TOP-LEVEL EXCEPTION: -
how can solve error
error:execution failed 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 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' // not use 22.2.0 newer one. reported cause problems 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 can add configuration options common sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' // note: not place application dependencies here; belong // in 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. @ first step of android gradle hell.
update android sdk components in sdk manager latest 1 including > google repository (recommend add in extra).
let's wash current file.
androidmanifest.xml: remove
<uses-sdk ... />
lines. it's redundant gradle file defines it.build.gradle: comment
compile files('libs/xxxxxxx.jar')
lines. first linecompile filetree(dir: 'libs', include: ['*.jar'])
include jar files inlibs
folder. and, usecompile
maven repository not jar files in order maintain dependencies fresh.
for example, simplexml has repository id below. place code below of compile filetree(dir: 'libs', include: ['*.jar'])
line , 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 libs folder , replace below of compile filetree(dir: 'libs', include: ['*.jar'])
line 1 one. make jar files unable find in maven repository remain in libs folder.
finally, remove proguardfiles
line. need find , fix problem in general condition, apply progruard afterward.
- set version of buildtoolsversion , compilesdkversion latest one.
my recommendation of today below,
(numbers may vary when see post in 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' // not use 22.2.0 newer one. reported cause problems other dependencies. compile filetree(dir: 'libs', include: '*.jar') compile('com.google.android.gms:play-services-gcm:7.5.+') { exclude module: 'support-v4' } }
command
gradle assembledebug
again. (for windows,gradlew assembledebug
)if failed again, try find , fix dependencies version conflict issues 1 one. may see
exclude module: ...
in code. these resolve conflict issue. detailed instruction given @ link: https://stackoverflow.com/a/30649660/361100
Comments
Post a Comment