UNEXPECTED TOP-LEVEL EXCEPTION when using renderscriptSupportModeEnabled true - android

Hi i previously using renderscriptSupportModeEnabled true whiteout any problem but today when i want to run my app i giving this error message
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
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: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_51\bin\java.exe'' finished with non-zero exit value 2
i even create new empty sample project with no dependency but same error message here is my .gradle file
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.mk.sample"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}

I can't say I understand this solution - or that it's necessarily a good fix, but it got my app compiling again:
configurations.all {
exclude group: 'com.android.support', module: 'support-annotations'
}
Also, see: Getting Multiple dex error when using render script support lib
and Using buildToolsVersion 23 fails because Multiple dex files define 'AnimRes'
Credit to Luboš Staráček for this solution

Related

Build APK - ERROR - app:transformClassesWithDexForDebug

I watched so many threads here and still didnt find working solution.
When I want to BUILD APK, I get this main error:
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException: Error while executing
java process with main class com.android.dx.command.Main with
arguments {--dex --num-threads=4 --multi-dex --main-dex-list
C:\Users\ratik\Desktop\BUILDBOX\VOLUNTEER\STUDIO\app\build\intermediates\multi-dex\debug\maindexlist.txt
--output C:\Users\ratik\Desktop\BUILDBOX\VOLUNTEER\STUDIO\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main
C:\Users\ratik\Desktop\BUILDBOX\VOLUNTEER\STUDIO\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}
There is few more errors, but then apear only sometimes, some of them:
Error: at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
Error: at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:723)
Error: at
com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
What I tried:
In build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.biif.volunteer"
minSdkVersion 14
targetSdkVersion 25
multiDexEnabled true
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
dependencies {
compile ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-19.0.1.jar')
compile ('com.android.support:multidex:1.0.1')
}
In Manifest
android:name="android.support.multidex.MultiDexApplication"
Plus I turned off Instant run (saw in one thread here).
Nothing helped :( Any ideas please? Thanks for help guys :)
I included gradle.properties file in the project with:
org.gradle.jvmargs=-Xmx10248m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
and it works.

Error while building application on Android Studio

I am new on Android Studio. I am facing below mentioned error while building the project.
: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))
Here is my build.gradle file inside app folder.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.test.offerwall"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.bee7.gamewall.aar:bee7#aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-base:6.5.87'
compile 'com.test.android.ads.aar:myapp#aar'
compile 'com.google.android.gms:play-services:7.5.0'
}
repositories {
flatDir {
dirs 'libs'
}
}
I have updated the android sdk also but no luck. Could you guys help me out that why I am facing this issue.
Kindly help me out with the solution.
Thanks in advance.
As commented: I have tried using removing the multiDexEnabled true
Then I got this 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: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)
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
For the first error remove multiDexEnabled true.
UNEXPECTED TOP-LEVEL EXCEPTION:
for this one remove one of your com.google.android.gms:play-services libraries it is included more than once.
or add this in your build.gradle at the root level:
configurations {
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
hope this will help.

error while creating PDF

I am trying to generate a PDF using Android Studio. I am using the iText library, but when I add it into Android studio, I get the following error:
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_79\bin\java.exe'' finished with non-zero exit value 2
When I remove the library, my project successfully compiles. It works as expected when using Eclipse instead of Android Studio.
EDIT
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.abc"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile project(':Wheel')
compile project(':facebook')
compile files('libs/mint-4.0.8.jar')
compile 'com.android.support:support-v4:22.1.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:recyclerview-v7:22.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile files('libs/itextpdf-5.5.6.jar')
}
And error list instead of line posted
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: Cannot merge new index 66843 into a non-jumbo instruction!
at com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)
at com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)
at com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)
at com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)
at com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)
at com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)
at com.android.dx.merge.DexMerger.transformCode(DexMerger.java:842)
at com.android.dx.merge.DexMerger.transformMethods(DexMerger.java:813)
at com.android.dx.merge.DexMerger.transformClassData(DexMerger.java:785)
at com.android.dx.merge.DexMerger.transformClassDef(DexMerger.java:682)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:542)
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)
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_79\bin\java.exe'' finished with non-zero exit value 2
I faced a similar problem yesterday. Just add this to your build.gradle file and clean/invalidate your project =)
android {
....
dexOptions {
jumboMode = true
}
}
I used iTextG library as suggesed by "Bruno Lowagie" in comment and Remove unused libraries.
The com.android.dex.DexIndexOverflowException: exception is arrived because
As per android developer site
The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code.
https://developer.android.com/tools/building/multidex.html
But with this method we got out of memory issue. To fix this we have to add in android closure.
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
http://www.mutualmobile.com/posts/dex-64k-limit-not-problem-anymore-almost

Android GraphView Gradle "Failed to run" Error?

i need to do more graph in my app and i thought to import that library ( http://www.android-graphview.org/ ).
I just follow the rules and i add to the gradle the compile row.
That is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.btc.btcmobile"
minSdkVersion 17
targetSdkVersion 21
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:appcompat-v7:21.0.3'
compile 'com.jjoe64:graphview:4.0.0'
}
after that, i copy-paste the example on the site, but when i compile now i can see that error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\valerio\AppData\Local\Android\sdk2\build-tools\21.1.1\dx.bat --dex --no-optimize --output C:\Users\valerio\Desktop\BtcMobile\btcmobile\app\build\intermediates\dex\debug --input-list=C:\Users\valerio\Desktop\BtcMobile\btcmobile\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/jjoe64/graphview/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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
How i can resolve?
Thanks.
In my case I had the GraphView4.1.jar inside the libs folder. I also had compile 'com.jjoe64:graphview:4.0.1' in the build.gradle. As soon as I removed the jar file from libs folder, the com.android.dex.DexException error was resolved.

How to Remove Duplicate Libraries added via gradle?

I am using two libraries in my project. One is this and the other is this.
Whenever I run the App with Edit Test library it shows UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':mobile:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\Android\me\me\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\dex\debug --input-list=C:\Project\RemoteiT\RemoteiT\mobile\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 Assume that the above error shows that com.nineoldandroids is added twice or conflicting.
So I tried to remove it in the build.gradle file. But it is still showing the error!
Is my Assumption is right? Or elsewhere did I go wrong?
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "me.aruhan.remt"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
// to avoid double inclusion of support libraries
all*.exclude group: 'com.nineoldandroids', module: 'materialDesign'
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':materialDesign')
compile 'com.rengwuxian.materialedittext:library:1.7.1'
}
Instead of adding it in the Configurations. I added the exclude for only the library like this:
compile ('com.rengwuxian.materialedittext:library:1.7.1') {
exclude group: 'com.nineoldandroids', module: 'library'
}
Go to File > project structure > Inside module select your > click on Dependencies on right hand side and see there are duplicate libraries are present or not?
Also try invalidate/Restart cache
If the error occurring due to duplication of libraries you can use packagingOptions in build.gradle file.
android {
....
packagingOptions {
exclude '.....'
pickFirst '.....'
}
}

Categories

Resources