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.
Related
I am new to android. I am doing one project in that i want to use jar file. Actually I converted .apk file to .jar file by using dex2jar. I added that .jar file in lib folder and added as library. but when running the app it shows an 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 1
and my build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.protocolnet.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile files('libs/viabee-dex2jar.jar')
}
.
How to get rid from that error. Please anybody help me?
You can't use .jar file converted from apk as a Library because of that it is not Library. You can get source code using this method.
I am getting an ':app:packageAllDebugClassesForMultiDex' Error when I try to build an application using the YouTubeData API. I have researched several other threads that cover this error and the conclusion that I have come to is that I have libraries in my build file that are creating a duplicated reference to build files. I know that the file triggering the error is:
'com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class'
but how do I exclude the reference from the build file with out removing the entire library?
This is my build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "co.hannalupi.fitnessblenderapp"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.apis:google-api-services-youtube:v3-rev136-1.20.0'
}
This is the error I get:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/google/api/client/googleapis/json/GoogleJsonErrorContainer.class
I am new to Android, any direction you can point me in would be greatly appreciated. Thanks in advance.
An update for folks having a similar error - As a last resort I deleted the project file that I was working in from my desktop and cloned a fresh copy from GitHub. Importing and running the fresh copy gave me no errors!!
If i write in my gradle file this code
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
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(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
}
all work cool. but if i change
compile 'com.android.support:appcompat-v7:22.1.0'
my app crash. Android studio recomended me change version to 22.1.0 but if i chage version - crash.
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\zen_75\AppData\Local\Android\sdk\build-tools\22.0.1\dx.bat --dex --no-optimize --output C:\projects\android-customer\app\build\intermediates\dex\debug --input-list=C:\projects\android-customer\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)
how do I fix it or leave it?
EDIT:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.1.0'
}
i change file - not work!!!
You have Over 65K Methods in you project, seems like Google has add a lot of now methods to the appcomapt-v21.1 libs.
Anyway, For now you have those options:
1. Use Multidex, Follow the instructions below, more info here
2. Use the ProGuard
3. Cut down the number of methods you have in your project
You have to keep in mind:
Multidex may not work on devices running Android v3.x-, check all limitations here
ProGuard is not guaranteed to solve the problem
Re-write you code to cut down the number of methods is not easy.
Add multidex support:
build.gradle
android {
...
...
defaultConfig {
...
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
...
...
compile 'com.android.support:multidex:+'
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="x.xxx.xx">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
PS: You can count the number of methods you have in your project using dex-method-counts, it will give you a clear idea about your situation.
A possible solution is to start using ProGuard's minify capability. Please note that it breaks Dagger dependency injection over version 1.0.1.
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Test your application extensibly, as this removes unused methods, and does many other things.
http://developer.android.com/tools/help/proguard.html
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.
I am trying to learn android in android studio.Now i imported an eclipse project in android studio and now while trying to run it it is not building.Some problems in gradle may be..
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
my build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.practise"
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:gridlayout-v7:+'
}
Can anyone help me to find out the problem??
Change your dependencies
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:gridlayout-v7:19.1.0'
}
Using the +, you are getting the last release.
Currently the last release is the compile 'com.android.support:support-v4:21 and it has a minSdk='L' because it is a preview release.
Use it only to test the android 'L' preview.
Try editing the following line to your Android Manifest file, like so:
dependencies {
compile 'com.android.support:support-v4:21+'
}
Then your project should build.
Change your dependencies in app/build.gradle to lower version
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.eusecom.snowsmsden"
minSdkVersion 16
targetSdkVersion 20
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.+'
compile 'com.android.support:appcompat-v7:20.+'
}