I try launch android project and get error
Error Code: 2
Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
My gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "nit.livetex.livetexsdktestapp"
minSdkVersion 10
targetSdkVersion 21
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 files("libs/sdk.jar")
compile 'com.android.support:appcompat-v7:21.0.0'
}
I think It occurs because of using support-library in sdk.jar.
Where I should add exclude rule?
I am not sure but can you try that please?
compile('com.android.support:appcompat-v7:21.0.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
or
compile files("libs/sdk.jar"){
exclude group: 'com.android.support', module: 'support-v4'
}
Related
While building APK for my android app the following error is shown:
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.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;
I couldn't find what the error was. My module:app gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.0"
defaultConfig {
applicationId "//my application"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.google.android.gms:play-services-fitness:11.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I read somewhere that Unless you have an absolute need to enable multiDex in your build.gradle DO NOT DO IT!
But when i removed the line from gradle file,
compile 'com.google.firebase:firebase-messaging:9.0.1'
then building apk was successful.
Since i need firebase in my application, this wouldn't be a solution for me.
can anyone help me?
You need to use same version of dependencies
Use this
compile 'com.google.android.gms:play-services-fitness:11.0.0'
compile 'com.google.firebase:firebase-messaging:11.0.0'
Instead of this
compile 'com.google.android.gms:play-services-fitness:11.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
Build gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.imageditor.Image"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
I am writing android project. Some of the external libraries requires the use of Java8. However, when I add Java8 using Jack, the project isn't recognizing the components of Java8. What might be the problem?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.infiniteloop.android.translateyandex"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
jackOptions {
enabled true
}
}
dexOptions {
incremental true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildscript {
tasks.withType(JavaCompile) {
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.2.0'
compile 'com.github.vbauer:yandex-translate-api:1.2.5'
testCompile 'junit:junit:4.12'
}
And here is the error list
Errorlist
You use
multiDexEnabled true
Add above link to AndroidManifest.xml:
android:name="android.support.multidex.MultiDexApplication"
OR
MultiDex.install(this);
in your custom Application's attachBaseContext method
or your custom Application extend MultiDexApplication
and add above
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Hope it help.
You can use this gradle plugin for getting java lambda support in java 6, 7 and android
Just add: apply plugin: 'me.tatarka.retrolambda'
line in your app level build.gradle file below the line: apply plugin: 'com.android.application'
Now in your project level build.gradle add :
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
in your dependencies section
EG:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
}
And sync it :)
I am facing following issue while running application.
Error:Execution failed for task ':app:transformJackWithJackForDebug'.
com.android.sched.scheduler.RunnerProcessException: Error during
'MethodIdMerger' runner on '': GC overhead limit exceeded
I have also declared heap size in gradle file
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
I am using android studio 2.2 and JackOption is enabled.
Update : build.gradle included
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion '24.0.2'
compileOptions.encoding = 'ISO-8859-1'
useLibrary('org.apache.http.legacy')
lintOptions{
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
}
defaultConfig {
applicationId "appID"
minSdkVersion 14
targetSdkVersion 22
versionCode 2033
versionName "6.1"
multiDexEnabled true
ndk {
abiFilters "armeabi", "x86"
}
jackOptions {
enabled true
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':SettingsPluginv9')
compile project(':DragLib')
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile project(':PDFViewCtrlTools')
compile project(':PullToRefreshLibrary')
compile project(':SmoothProgressBar')
compile project(':ViewpagerLibrary')
compile project(':BoxAndroidLibraryV2')
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.nuance:speechkit:2.1+#aar'
compile 'com.parse:parse-android:1.10.1'
}
any possible solution for it?
I am able to solve above problem by increasing memory size of Gradle Daemon VM to 2GB. To do that , You need to modify gradle.properties
Add following line in your properties file.
org.gradle.jvmargs=-Xmx2048m
The problem is happening after I add the Realm Library to my project. I have this dependences in my gradle project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.realm:realm-android:0.87.2'
}
I Found a lot of answers in the StackOverflow and I tested many of this but i have no success. Tryied this answer and this answer but i think my problem is something more specific.
I also added the suggestion of the LogCat error, but im getting the same error. Any answer will be appreciated.
I provide an image of the full error for a better look.
Move your android closure to be after the dependencies closure:
apply plugin: 'com.android.library'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'io.realm:realm-android:0.87.2'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
The LogCat show this error Gradle DSL method not found: 'packagingOptions()'
Then you do not have packagingOptions inside android.
This is the packagingOptions { I use to typically be able to build anything so far.
android {
...
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
I've been working on this issues for a several hours but can't find the solution. Tried a lots of answers from stackoverflow but no luck.
What am I getting is the following gradle error while running the app:
:app:packageAllDebugClassesForMultiDex FAILED
Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/widget/SearchViewCompatIcs$MySearchView.class
Android studio throws the error when i add the dependency of ShareThis Sdk into the gradle. Here is the full gradle:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'Alies'
keyPassword 'password'
storeFile file('path.jks')
storePassword 'password'
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "example.com.app"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
incremental true
}
//configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }
//configurations { all*.exclude module: 'support-v4' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided files('libs/universal-image-loader-1.9.3.jar')
compile project(':library-circular')
compile('com.android.support:appcompat-v7:22.2.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':sliding_library1')
compile('com.google.android.gms:play-services:7.5.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':sdk')
}
A small help will be greatly appreciated.
Seems the problem is in Compile independent modules in parallel (may require larger heap size). So, disabling that option and clear rebuild should fix it.
Looks like Android Build Tools for multidex sometimes try to include lib project in both dex files and it causes some conflict then compiled simultaneously.
So, the problem has been resolved. Actually there was a conflict between support-v4 jar files, So I simply used the same support-v4.jar everywhere and the problem is fixed.