I have an error in my gradle: - java

I have an error in my gradle:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [C:\Users\El-Othmane\Desktop\tes11\android2\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\El-Othmane.gradle\caches\transforms-1\files-1.1\support-core-ui-26.1.0.aar\744d5e6087e939bc5d55ea9f4d6a237d\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [classes.jar:android/support/v4/view/ViewPager$2.class]))
enter code here Here is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 27
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
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')
}

First add this library in Gradle:
compile 'com.android.support:multidex:1.0.0'
Also you can add multidex:
multiDexEnabled true
and make your application to extend class MultiDexApplication.

Put code like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 16
targetSdkVersion 25
versionCode 4
versionName "1.3"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
useLibrary 'org.apache.http.legacy'
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'
}
}
dependencies {
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:support-v4:25.4.0'
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')
}
apply plugin: 'com.google.gms.google-services'
You are talking about how to exclude V4 See
Instead of V4 you can put V7 also like this
compile 'com.android.support:appcompat-v7:25.4.0'
You got this error may be because of Prograurd Duplicate zip entry
check below Links1 , Links2
Hope this solved your problem.

The error is expected because you're using an old support library which is conflicted with your compileSdkVersion and Google play service. So, you need to change your build.gradle to something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.companyname.gamename"
minSdkVersion 14
targetSdkVersion 27
multiDexEnabled true
dexOptions {
javaMaxHeapSize "4g"
}
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
productFlavors {
}
}
dependencies {
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
// Don't use the following
//compile files('libs/support-v4-19.0.1.jar')
// instead, use support library with the same version with your compileSdkVersion
compile 'com.android.support:support-v4:27.1.1'
// You should NOT use all the google play service
// use what you need, please refer to https://developers.google.com/android/guides/setup
compile 'com.google.android.gms:play-services:11.2.0'
}

Related

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateReleaseBuildConfig

Here is my build.gradel modul.app
PROBLEM org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateReleaseBuildConfig
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.packagename"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
// Prevent OutOfMemory with MultiDex during the build phase
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets.main {
jni.srcDirs = []// <-- disable automatic ndk-build call
}
}
dependencies {
implementation 'com.google.android.gms:play-services:+'exclude module: 'support-v4'
implementation 'com.parse:parse-android:1.10.3'
implementation 'com.android.support:multidex:1.0.1'exclude module: 'support-v4'
implementation 'com.google.android.ads.consent:consent-library:1.0.3'
}
I get tired with this problem when i want to build this project to apk from buildbox by android studio

'provided' is obsolete but where is the provided

apply plugin: 'com.android.application'
apply plugin: 'net.saliman.cobertura'
android {
compileSdkVersion 26
buildToolsVersion '28.0.2'
defaultConfig {
applicationId "ch.zhaw.facerecognition"
minSdkVersion 21
targetSdkVersion 26
versionCode 28
versionName "1.5.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
cobertura {
coverageFormats = [ 'html', 'xml' ]
}
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.4.0'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
api 'com.android.support:appcompat-v7:26.0.0'
api 'com.android.support:support-v4:26.0.0'
api 'ch.zhaw:facerecognitionlibrary:1.5.3'
}
The compiler is android studio.
Above is my build file after I build it the compiler told me that Configuration 'provided' is obsolete and has been replaced with 'compileOnly'.
But where is the provided?
Replace "api" with "implementation" and your issue will be solved, like this:
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:support-v4:26.0.0'
implementation 'ch.zhaw:facerecognitionlibrary:1.5.3'

Error while build apk

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [C:\Users\Akash\Desktop\android\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Akash.gradle\caches\transforms-1\files-1.1\support-compat-25.2.0.aar\876e5d10a24579a64796f25edbd33794\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/v4/view/ViewCompat.class]))
App Gradle :
apply plugin: 'com.android.application'
android {`enter code here`
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.razorworld.bike"
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')
}

Java\jdk1.7.0_06\bin\java.exe'' finished with non-zero exit value 1 android studio

I am getting this error while i run program in the Android studio.. There is no anyother is here i guess.
Error:Execution failed for task ':app:createDebugMainDexClassList'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_06\bin\java.exe'' finished with non-zero exit value 1
Here it is my gradle file copy..
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "app.example.com"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
lintOptions { abortOnError false }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/socialauth-4.9.jar')
compile 'com.android.support:recyclerview-v7:+'
compile project(':linkedin-sdk')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.lucasr.twowayview:twowayview:0.1.4'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:design:+'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile ('org.apache.httpcomponents:httpmime:4.3.5')
{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
}
what's the issue ?
its seems to be multidex issue. just add maximum heap size and multidex library dependency.
android {
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
defaultConfig {
multiDexEnabled true
}
also put Dependency
compile 'com.android.support:multidex:1.0.0'
you will also need to extend your application class to MultiDexApplication
public class App extends MultiDexApplication {
#Override
public void onCreate()
{
super.onCreate();
// Initialize
}
#Override
protected void attachBaseContext(Context base)
{
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Don't forgot to make an entry of app class in manifest.
Use this in app build.gradle worked for me
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}

Android Generate Signed APK getting duplicate issue

When I try to generate Signed APK, I am getting the following error
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gson/annotations/Expose.class
The Debug APK is working perfectly. After I include Facebook SDK then only I am facing this issue... Can anyone help me how to solve this issue
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.5'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "mani.com.howhighru"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
compile('com.twitter.sdk.android:twitter:2.3.1#aar') {
transitive = true;
}
}

Categories

Resources