I have two libraries on my proyect.
https://github.com/rengwuxian/MaterialEditText
https://github.com/navasmdc/MaterialDesignLibrary
It compiles, but when I run the program it reports an error.
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Alvaro\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output D:\ALVARO\AndroidStudioProjects\Proyecto\app\build\intermediates\dex\debug --input-list=D:\Alva\AndroidStudioProjects\Proyecto\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
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)
I KNOW THE PROBLEM, BUT I CAN'T SOLVE
Problem
Multiple dependencies are trying to import nineoldandroids exactly "nineoldandroids"
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.alva.proyecto"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
//seconds library
compile project(':materialDesign')
//first library
compile project(':EditText')
}
first library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:appcompat-v7:21.0.3'
}
seconds library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 8
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.+'
compile files('libs/nineoldandroids-2.4.0.jar')
}
I have tried:
1. Put on "app" build.gradle:
compile project(':EditText') {
exclude group: 'com.nineoldandroids', module: 'library:2.4.0'
}
NOT WORKS, IT'S REPORTS AN ERROR
Error:(31, 0) Gradle DSL method not found: 'exclude()'
Possible causes:<ul><li>The project 'Proyecto' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
2. Remove "nineoldandroids" from seconds library, NOT WORKS
Any suggestions?
I don't know how to import using their respective artifacts
It is in the documentation for each library.
The MaterialEditText "Download" section cites:
compile 'com.rengwuxian.materialedittext:library:1.8.2'
The "How to Use" section of MaterialDesignLibrary cites:
repositories {
jcenter()
}
dependencies {
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'
}
Then, Gradle will (hopefully) be able to detect that both of these dependencies themselves depend upon nineoldandroids and resolve the conflict. I say "hopefully" because whichever library the "seconds library build.gradle" comes from uses a local copy of nineoldandroids, which is not a good idea. Neither GitHub repo seems to have that particular build.gradle file, though, so you may be OK.
Related
When I Clean/Rebuild my project or even run app, It doesn't return any errors. But when I generate signed APK, It returns two errors.
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzox;
And this one
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzd.class
Below is the code from build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.wildlife.dbd"
minSdkVersion 16
targetSdkVersion 24
versionCode 10
versionName "2.2.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'com.google.gms.google-services'
dependencies
{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
// FB Ads
compile 'com.facebook.android:audience-network-sdk:4.10.0'
// Analytics
compile 'com.google.android.gms:play-services-analytics:9.0.0'
}
Facebook audience network will pull in play-services as well, so you'll have to exclude it:
I don't remember exactly what Facebook's dependencies are, so your 'analytics' line might not be complete enough for the audience network to run properly. You might want to add the entire play services like so: compile 'com.google.android.gms:play-services:9.2.1', and remove analytics.
Or if you can see exactly which dependencies Facebook requires, you can grab the correct ones here.
compile ('com.facebook.android:audience-network-sdk:4.10.0') {
exclude group: 'com.google.android.gms'
}
I am using google play services version 7.5.0 and getting below mentioned error while running a project.
My project contains 2 modules.
Here are the build.gradle file of each modules.
Module 1:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
}
Module 2:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':module1')
}
And here is build.gradle file of app
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.vserv.offerwall"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':module2')
}
repositories {
flatDir {
dirs 'libs'
}
}
When I am building the app, it get build successfully. But when I am trying to run the app, I am getting below mentioned error.
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:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2
I have done some Google and found below mentioned link.
Unable to execute dex: method ID not in [0, 0xffff]: 65536
I have tried this and edited the app gradle file by adding multiDexEnabled true into defaultConfig and compile 'com.android.support:multidex:1.0.0' in dependencies.
After that the above mentioned error is resolved and then I got another error while running the app.
:app:shrinkDebugMultiDexComponents FAILED
Error:Execution failed for task ':app:shrinkDebugMultiDexComponents'.
java.io.IOException: Can't read [D:\StudioWorkspace\SampleSDKDemoProject\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [org/fmod/FMODAudioDevice.class] (256))
Kindly help me to solve this.
Thanks in advance.
Instead of importing ALL modules from google services
compile 'com.google.android.gms:play-services:7.5.0'
Import only the modules you need. Check this page.
Note: If the number of method references in your app exceeds the 65K
limit, your app may fail to compile. You may be able to mitigate this
problem when compiling your app by specifying only the specific Google
Play services APIs your app uses, instead of all of them.
I know this sounds very easy, but android studio is eating my brains out. I know how to import my current project say myProject in to ADT very easily. But I came to know that soon the support for adt will be ending. So i decided to switch to Android studio. I am using the following libraries in my project
Commons
ActionBarSherlock
AndroidImageChacheMaster
SlidingMenuMaster
I tried to import the project myProject.
See its Project.Properties file
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-21
android.library.reference.1=../actionbarsherlocklibrary
android.library.reference.2=../Android-Image-Cache-master
android.library.reference.3=../Commons
android.library.reference.4=../google-play-services_lib
android.library.reference.5=../SlidingMenuMaster
When i tried to import it A.S told me unrecoverable errors and I pasted the library folder as instructed by android studio.
And it project was imported succesfully
but there are two error apparing in the log
/home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/manifests/tmp/manifestMerger2026412193483179673.xml
Error:(5, 5) uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library /home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/AndroidManifest.xml
Error:(5, 5) Execution failed for task ':commenorkingandroid:processDebugAndroidTestManifest'.
> java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 5 cannot be smaller than version 7 declared in library /home/mukund/StudioProjects/aftercrash62/commenorkingandroid/build/intermediates/exploded-aar/com.actionbarsherlock/actionbarsherlock/4.4.0/AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.actionbarsherlock" to force usage
please help what is wrong here?
and now my project structure is
actionbarsherlocklibrary(empty)
myProject(manifests,java,res,aidl,resources,c,assets)
androidimagecachemaster(manifests,java,res)
commenorkingandroid(manifests,java,res) // i havent imported anything with this name
commons(manifests,java,res)
Gradle Scripts
build.gradle(Project:myProject)
build.gradle(Module:actionbarsherlock)
build.gradle(Module:myProject)
build.gradle(Module:commons)
build.gradle(Module:androidimagecachemaster)
build.gradle(Module:commenorkingandroid)
gradle-wrapper.properties
settings.gradle
here are my gradle files
build.gradle(Project:myProject)
// 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'
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle(Module:actionbarsherlock)
apply plugin: 'java'
build.gradle(Module:myProject)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.five.myApp"
minSdkVersion 11
targetSdkVersion 16
ndk {
moduleName "cr3engine-3-1-1"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':actionbarsherlocklibrary')
compile project(':androidImageCachemaster')
compile project(':commons')
compile project(':commenorkingandroid')
compile 'com.google.code.gson:gson:2.1'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/commons-io-2.4.jar')
compile files('libs/epublib-core-latest.jar')
compile files('libs/slf4j-android-1.6.1-RC1.jar')
compile files('libs/slf4j-android-1.7.5-7-sources.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/zip4j_1.3.2.jar')
}
build.gradle(Module:commons)
apply plugin: 'com.android.library'
android {
compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/actionbarsherlock-plugin-maps-4.1.0.jar')
}
build.gradle(Module:androidimagecachemaster)
apply plugin: 'com.android.library'
android {
compileSdkVersion 10
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/CWAC-AdapterWrapper.jar')
}
build.gradle(Module:commenorkingandroid)
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 5
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
}
If you have added Sherlock as an AAR dep like
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
you can remove
compile project(':actionbarsherlocklibrary'), include ':sherlock' line from your settings.gradle, then related folder from your project.
And your targetSdkVersion can be the same as your compileSdkVersion as well.
In the project, there are 3 modules, A,B,C.
A is having dependency of B and B is having dependency of C.
Error Output:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\user\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Testing\MyApplication\app\build\intermediates\dex\debug --input-list=C:\Testing\MyApplication\a\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/test/test2/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
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)
MainProject[settings.gradle]:
include ':A', ':B', ':C'
MainProject[build.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.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
A.gradle :
apply plugin: 'com.android.application'
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':B')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
/*defaultConfig {
minSdkVersion 9
targetSdkVersion 21
}*/
lintOptions {
abortOnError false
}
}
B.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile('de.keyboardsurfer.android.widget:crouton:1.8.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'de.greenrobot:eventbus:2.2.1'
compile 'com.mobsandgeeks:android-saripaar:1.0.3'
compile 'com.loopj.android:android-async-http:1.4.6'
compile project(':C')
compile 'com.android.support:appcompat-v7:21.0.3'
}
C.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/classes.jar')
}
If I am removing the duplication of appcpmpat-v7 in A and module B then I am getting the errors.
Module C contains the compiled .class files.
I am unable to understand the duplication of build.config files. What can be the solution of this problem?
The support library is included several times (maybe because declared as dependency by several of the libraries you're using), look for that in your build script.
resolution remove appcompat library from Gradle A.
Dependency resolution
When a project references two Library projects that both require the same jar file, the build system has to detect and resolve the duplication.
A full dependency system would associate each jar file with a fully qualified name and a version number to figure out which version to use.
Unfortunately the Android build system does not have a full dependency resolution system (yet). In the meantime we have implemented a very basic system that follows these rules:
Jar file are identified strictly by their file names.
This means mylib.jar is different than mylib-v2.jar and both will be packaged, possibly resulting in “already added” dx error if they are actually the same library in a different revision.
For jars with the same file name, “same version” means same exact file.
Currently our detection is very basic, checking only that the files are identical in size and sha1.
If two libraries each include in their libs folder a file called mylib.jar but these two files are different, then the build system will fail indicating a dependency error.
check Android Dex: UNEXPECTED TOP-LEVEL EXCEPTION for more info.
I can getting the following error:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library .../com.android.support/recyclerview-v7/21.0.0-rc1/AndroidManifest.xml
Below is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 20
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
compile 'com.android.support:cardview-v7:21.0.0-rc1'
...
}
Using
<uses-sdk
tools:node="replace" />
does not work anymore.
I have looked at this. The solution suggested place following code in gradle.build
android.applicationVariants.all { variant ->
variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
variant.processManifest.enabled=false }
But I get error
Error:(21, 0) Could not find property 'processResources' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated#dac7b2d.
No matter where I place the code in gradle.build
Replace:
compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
compile 'com.android.support:cardview-v7:21.0.0-rc1'
with:
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
to use the production release versions of those libraries, instead of the L-only preview versions. They will work back to API Level 7.