I'm suddenly running into this issue when building/running my project.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/aidanfollestad/Documents/android-sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Users/aidanfollestad/Android Projects/Impression/app/build/intermediates/dex/debug --input-list=/Users/aidanfollestad/Android Projects/Impression/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
My Gradle file contains this:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.14.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'versionPlugin'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.afollestad.impression"
minSdkVersion 16
targetSdkVersion 21
versionCode 19
versionName "0.7.0"
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.koushikdutta.ion:ion:2.0.+'
compile 'com.github.chrisbanes.photoview:library:1.2.+'
compile 'com.afollestad:material-dialogs:0.4.5'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.api-client:google-api-client:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.api-client:google-api-client-gson:1.18.0-rc'
compile 'com.google.apis:google-api-services-drive:v2-rev152-1.19.0'
compile('com.crashlytics.sdk.android:crashlytics:2.1.0#aar') {
transitive = true;
}
}
versionPlugin{
buildTypesMatcher = 'release'
supportBuildNumber = false
fileNameFormat = '$appPkg-v$versionName-$versionCode'
}
My material-dialogs library references only AppCompat-v7, the same version this Gradle file is referencing. I don't have any JARs in my libs folder that I'm referencing. I have no idea what libraries are interfering with each other (other than the possibility of Play Services and AppCompat?). Any ideas or solutions?
I noticed Ion references v4 of the support library (https://github.com/koush/ion/blob/master/ion/build.gradle#L17), maybe that could be interfering with AppCompat?
Try to enable multidex build.gradle :
android {
defaultConfig {
...
multiDexEnabled = true
}
}
Ref : Unable to execute dex: method ID not in [0, 0xffff]: 65536
You may hitted the 65k methods limit. Instead of using multiDex, try to use Google Play Services with more granularity. Follow this guide, you can use only parts that you want. Probably this will fix your problem.
This exception shows that your project have reached to maximum number of methods 65536. you just do the below work.It worked for me
Step 1:
inside build.gradle
defaultConfig {
multiDexEnabled = true
}
Step 2:
inside manifest application tag
android:name="android.support.multidex.MultiDexApplication"
or
Step 3: if You use Class which extends Application then do:
public class MyApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Step 4:
inside build.gradle
android{
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
Related
I am trying out Hawk authentication by https://github.com/wealdtech/hawk. I would like to include this library by source in an empty project so that I can experiment with the apis. I do not want to use a jar or gradle dependency.
I import the project as a module and I run into this error:
Error:(2, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'HawkTest' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
I tried solutions from these links but I could not derive any information that could help resolve this issue:
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
I have spent many hours on this problem but do not seem anywhere near a solution. Any direction or a solution would be greatly appreciated.
This my top-level build file:
// 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:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The app level file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.test.android.hawktest"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
The Hawk module's gradle file:
dependencies {
compile 'com.wealdtech:wealdtech-core:2.0.0'
compile 'com.wealdtech:wealdtech-configuration:2.0.0'
compile 'com.google.guava:guava:17.0'
}
uploadArchives {
repositories {
mavenDeployer {
pom.project {
pom.artifactId = 'hawk-core'
name 'Hawk Core'
description 'Java implementation of Hawk protocol - core'
}
}
}
}
And my directory structure:
hawk top level build.gradle contains all subproject configuration (check https://github.com/wealdtech/hawk/blob/develop/build.gradle)
For the whole process, from your project root directory :
git clone git#github.com:wealdtech/hawk.git
In your settings.gradle, this will configure the gradle modules :
include ':app',':hawk-core', ':hawk-server-jersey', ':hawk-client-jersey'
project(':hawk-core').projectDir = new File('hawk/hawk-core')
project(':hawk-server-jersey').projectDir = new File('hawk/hawk-server-jersey')
project(':hawk-client-jersey').projectDir = new File('hawk/hawk-client-jersey')
Then edit your top level build.gradle to specify the configuration for the Java project. Add the following :
configure(subprojects.findAll {it.name.startsWith('hawk')}) {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'signing'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testCompile 'org.testng:testng:6.8'
}
task copyLibs (type: Copy) {
into "$buildDir/output/libs"
from configurations.testRuntime
}
task testJar (type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
}
You cant add Java plugin (apply plugin: 'java') for your Android project . If you do so, you will have this error : The 'java' plugin has been applied, but it is not compatible with the Android plugins.. This is why I use the configure(subprojects.findAll and perform a filter on hawk modules. I've copied the remaining configuration from https://github.com/wealdtech/hawk/blob/develop/build.gradle
Today I migrated to Android Studio 1.1 and started to update the version of some libraries. When I build the project using the gradle button everything seems work properly but when I try to run the application I read in the gradle console output the error message that you can see at the end of the post. For the error message is clear for me that some libraries are using internally some libraries that are common between my dependencies and they have likely different versions. Someone knows how can I discover what are the libraries in conflict and how can I fix that issue (I can not remove any library from the project). Below you can find an abstraction of the build files in my project. Thanks in advance :)
Project's gradle file:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
app's (main module) gradle file
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'com.myapp'
minSdkVersion 16
targetSdkVersion 19
versionCode 1
versionName '1.0.0'
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
}
}
dexOptions {
preDexLibraries = false
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile project(':facebook')
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
compile 'com.path:android-priority-jobqueue:1.1.2'
compile 'com.google.android.gms:play-services-base:6.5.87' // Analytics, GCM
compile 'com.google.android.gms:play-services-maps:6.5.87'
compile 'com.google.android.gms:play-services-location:6.5.87'
compile 'com.android.support:support-v13:21.0.0'
}
Gradle console output:
Error:Class android.support.v4.util.TimeUtils has already been added to output. Please remove duplicate copies.
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Users/MyMAC/Documents/Development/IDE's/adt-bundle-mac-x86_64-20140702/sdk/build-tools/19.1.0/dx --dex --no-optimize .........
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/util/TimeUtils;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting
Information:BUILD FAILED
remove android-support-v4 in libs folder in facebook proj or your app module
i know this question has been answered a many times,i tried all ways bt not working for me at all. I refered a lib in android studio,build the project and am getting the following error:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\manalim\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output E:\MigrationFromEclTostudio\app\build\libs\app-debug.dex E:\MigrationFromEclTostudio\app\build\classes\debug E:\MigrationFromEclTostudio\app\build\dependency-cache\debug E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\classes-9f889413450cab598adf7f9e7fbc4b615d2af144.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\google-play-services-cbe976cd78aae99b019ba10bdd87d55acb9949b6.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\simple-xml-2.6.1-07b87981e87a36154f3c945922849669a8a391c7.jar E:\MigrationFromEclTostudio\app\build\pre-dexed\debug\support-v4-19.0.1-94b91e1fee2be61286a1fe04c97fca852e863a63.jar
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
below is the build.gradle:
**apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 18
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services:+'
compile files('libs/google-play-services.jar')
compile files('libs/simple-xml-2.6.1.jar')
}
**
build.gradle for app:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
thats it..help would be really appreciated as am working oj it since a very long time..
Thanks & Regards.
Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode
Try removing com.google.admobsdk-googleplay or similar if you already have it, it seems like another plugin is already including the need libraries.
The solution is to remove this line:
compile files('libs/google-play-services.jar')
and to delete the corresponding jar from the lib folder. This is not necessary any more because of this line:
compile 'com.google.android.gms:play-services:+'
Also note that you should generally not put a + there but rather maintain a fixed version number to ensure your app's stability.
E.g.
compile 'com.google.android.gms:play-services:6.5.87'
I'm trying to add a library as a dependency but it keeps giving me this error:
Class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat.AccessibilityServiceInfoIcsImpl
has already been added to output. Please remove duplicate copies.
Execution failed for task ':BrooklynTech:dexDebug'.
Could not call IncrementalTask.taskAction() on task ':BrooklynTech:dexDebug'
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
dependencies {
compile files('libs/Simple-Rss2-Android.jar')
compile 'org.jsoup:jsoup:1.7.3'
compile 'uk.co.androidalliance:edgeeffectoverride:1.0.1'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile project(':libraries:calendar-card')
compile 'com.twotoasters.jazzylistview:library:1.0.0' }
the dependency I added was for jazzylistview - https://github.com/twotoasters/JazzyListView
How can I fix the error?
More than one of your dependencies is including the classes from the v4 support library; you'll need to track it down. You ought to be able to open up the jar files from the project viewer and find the culprit.
Ideally none of your dependencies ought to be bundling the support library; it's the responsibility of your app's build to make sure that gets finally linked in.
Not sure, but could you try the following snippet. Maybe the transitive libs are causing the trouble
dependencies{
...
compile ('com.twotoasters.jazzylistview:library:1.0.0'){
transitive = false
}
}
cheers,
René
I am trying to add AdMob sdk to my android project using Android SDK.
Here is what is did.
i added admob jar file to the lib folder.
added as module
then added dependencies to my build.gradle.
Below is the build.gradle file looks as
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
dependencies{
compile files('libs/android-support-v4.jar','libs/GoogleAdMobAdsSdk-6.4.1')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
Below is the error.
Gradle 'StoriesIndian' project refresh failed:
Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
Build file 'C:\Users\lokesh\Desktop\MyStoryProject\StoriesIndianProject\StoriesIndian\build.gradle' line: 11
A problem occurred evaluating project ':StoriesIndian'.
A problem occurred evaluating project ':StoriesIndian'.
No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection) values: [file collection]
Possible solutions: module(java.lang.Object
)
Please help, what do to make it work and where to include module java.lang.object.
thanks