This error came after when I added compile 'org.apache.httpcomponents:httpmime:4.2.3'. Can't find solution I also tried multiple dex file true in default config section. I also tried creating another app for testing which was running successfully.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: 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
This is my build.gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.qualwebs.assistme"
minSdkVersion 19
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.1.1'
compile 'com.android.support:design:23.1.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'org.apache.httpcomponents:httpmime:4.2.3'
}
The Android plugin for Gradle available in Android SDK Build Tools
21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android
Support Repository to the latest version using the SDK Manager before
attempting to configure your app for multidex.
Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:
Change your Gradle build configuration to enable multidex
Modify your manifest to reference the MultiDexApplication class
Modify your app Gradle build file configuration to include the support library and enable multidex output .
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 23
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
In your manifest add the MultiDexApplication class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited
You can use
compile 'org.apache.httpcomponents:httpmime:4.5.1'
Read
https://developer.android.com/intl/es/tools/building/multidex.html
You have problem of multidex file so please add below dependency to your app Gradle file.
compile 'com.android.support:multidex:1.0.1'
Also add this line:
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
Also add below in Manifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited :
Try the following:
Change setting
Ctrl + Alt + S -> Compiler -> Gradle
InVM Options field write:
-Xmx2048m -XX:MaxPermSize=512m
Add in gradle
dexOptions { javaMaxHeapSize "2g" }
Thanks..!!
This issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android. This problem can be solved either by cleaning the project, and removing some unused libraries and methods from dependencies in build.gradle, OR by adding multidex support.
So, If you have to keep libraries and methods, then you can enable multi dex support by declaring it in the gradle config.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Related
I trying to user multiple module android project to work on my application and when I try to build the project. the project build fails with Manifest merge failures. I need help to resolve this issue.
I already tried changing the dependencies in Gradle files and tried rearranging them, searched other solutions in this and here as well, but none of them helped
my AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.atomnest.chitfund">
<application
xmlns:tools="http://schemas.android.com/tools"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory" />
</manifest>
since the project is not build successfully I'm not able to add any activity to the project
and my build.gradle File
apply plugin: 'com.android.application'
buildscript {
ext {
support_version = '1.0.2'
}
repositories {
mavenCentral()
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.atomnest.chitfund"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation "androidx.appcompat:appcompat:$support_version"
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.firebase:geofire-android:2.1.1'
implementation project(':utility')
implementation project(':library')
}
I am expecting to get the project build successfully and be able to launch the app in the emulator. pls help
here is the logcat image
If you are using androidx then you have to use all libraries compatible with androidx so you can use this code:-
In gradle.build (app) add this
compileSdkVersion 28
defaultConfig {
......
minSdkVersion 21
targetSdkVersion 28
......
}
And there are some implementations required to use androidx :-
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
And add these given two lines(below) to gradle.properties:-
android.useAndroidX=true
android.enableJetifier=true
Solution 1:
Suggestion: add 'tools:replace="android:appComponentFactory"' to
element at AndroidManifest.xml to override.
If you added the tools:replace="android:appComponentFactory" and still got trouble by fixing it, create a new project, copy-paste the codes and the same dependencies in there. After that, it should be fixed i hope.
If it didn't solve the issue, try adding these two:
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
In AndroidManifest.xml > <application tag of course.
Solution 2:
Add below two lines in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
You can also follow below link:
https://developer.android.com/jetpack/androidx/migrate
Do let me know if you get any problem.
Actually I had the same issue.In my case it was butterknife. I changed the dependency into 8.8.1 and it works fine for me.
I have this error and I can't resolve it, I looking for interhet but not working...
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzzf;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "sk.tipos.paradox02.citaj"
minSdkVersion 11
targetSdkVersion 23
versionCode 26
versionName '2.0021'
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
// signingConfig signingConfigs.release
}
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.firebase:firebase-ads:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.gms:google-services:3.0.0'
compile 'com.google.firebase:firebase-crash:9.0.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.android.support:design:23.0.0'
}
Error shown if I launch app. If rebuild project everything OK but when run project..
you are have several duplicate versions of library, keep only what you need nothing extra, Even after removing the duplicate libraries you are facing this error then try enabling multidex
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
in manifest inside application tag
<application
android:name="android.support.multidex.MultiDexApplication">
</application>
refer this
You've got both version 10.0.1 and 9.0.0 of 'com.google.firebase:firebase-ads'.
Remove the 10.0.1 version, as everything else is 9.0.0 and they should always have the same version.
This can be a lot of problems, but I believe this one is related to multidexing. You are enabling multidexing for the project and that's ok but this needs the multidex support library to be able to work on pre-Lolliopop.
Please add this to your dependencies
compile 'com.android.support:multidex:1.0.1'
I'm importing JellyRefreshLayout as modul (for some updates)
check this link :
https://github.com/allan1st/JellyRefreshLayout
but I always get this gradle build error :
Information:Gradle tasks [:app:generateDebugSources,
:app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :jellyrefresh:generateDebugSources, :jellyrefresh:mockableAndroidJar, :jellyrefresh:prepareDebugUnitTestDependencies, :jellyrefresh:generateDebugAndroidTestSources]
extractDebugAnnotations is incompatible with java 8 sources and has been disabled.
extractReleaseAnnotations is incompatible with java 8 sources and has been disabled.
:jellyrefresh:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:jellyrefresh:compileReleaseJavaWithJavac UP-TO-DATE
:jellyrefresh:compileRetrolambdaRelease FAILED
Error:Execution failed for task ':jellyrefresh:compileRetrolambdaRelease'.
> Could not resolve all dependencies for configuration ':jellyrefresh:retrolambdaConfig'.
> Could not resolve net.orfjackal.retrolambda:retrolambda:2.0.3.
Required by:
JellyRefreshLayout-master:jellyrefresh:unspecified
> No cached version of net.orfjackal.retrolambda:retrolambda:2.0.3 available for offline mode.
> No cached version of net.orfjackal.retrolambda:retrolambda:2.0.3 available for offline mode.
project gradle build :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
}
}
allprojects {
repositories {
jcenter()
}
}
App gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "uk.co.imallan.jellyrefreshlayout"
minSdkVersion 19
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:appcompat-v7:23.3.0'
compile project(":jellyrefresh")
}
Library model :
repositories {
mavenCentral()
}
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
}
Note : my project JDK selection and Default JDK is:
/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
Please Advice !
Thanks !
it's solved now .
The problem was : the internal_impl.jar is not on the retrolambda classpath sometimes.
because one of the following :
because dependencies might be updated in 2nd execution.
Maybe it is a bug in the Gradle Android plugin.
The Solution is :
I run gradle cleaning and assembling in commands from gradle terminal befor syncing gradle :
./gradlew clean assembleDebug
from Gradle terminal .
please check this helpful conversation :
https://github.com/evant/gradle-retrolambda/issues/105
I am getting the following error when I build my project in android studio
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/ArrayRes.class
My build.gradle file
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.android.instagram_project"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
defaultConfig {
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
}
This is the screenshot of my lib folder in the project
http://i.stack.imgur.com/qDjL4.jpg
Remove the Android support libraries from the libs directory. Since you are using gradle and have indicated a compile dependency with appcompat-v7 you do not need to include the JARs manually. This is causing a conflict at build time with duplicate symbols. Listing it as a compile dependency will cause gradle to work with Maven to pull the lib automatically (and its dependencies.)
for more detail look here.java.util.zip.ZipException in Android Studio
Till now I have been using Eclipse IDE, but now I changed PC and I have a lot of troubles with setting up Eclipse again. So I decided to use Android Studio. I am trying to import one project but I get an error during the build..
Error:
Error:Execution failed for task ':app:mergeDebugResources'.
> Unsupported type 'alpha' in file /Users/user/AndroidStudioProjects/Test/app/src/main/res/Anim/fade_in.xml
I am totally new to Android Studio and I am lost a lot..
This is my file fade_in.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="2000"/>
</set>
I tried to clean the project but with no success.I still get this error.
In the folder Gradle scripts I have 2 build.gradle files (I don't know if this is ok)
I have: 1.) build.gradle (Module app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "test.android"
minSdkVersion 14
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:+'
}
2.) build.gradle (Project Test):
// 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()
}
}