TransformException: java.util.zip.ZipException in Android Studio - java

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

Related

Failed to resolve: com.android.support.constraint:constraint- layout:1.1.0-beta1

This is the error:
Error:(23, 13) Failed to resolve: com.android.support.constraint:constraint-
layout:1.1.0-beta1
Upgrade plugin to version 2.3.3 and sync project
Show in File
Show in Project Structure dialog
When i click in upgrade plugin, nothing happens. I dont know how to fix this. I have tried adding the repository maven google but it doesn't work.
Here is the app code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.google.googleio"
minSdkVersion 22
targetSdkVersion 25
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.constraint:constraint-layout:1.1.0-beta1'
}
To use ConstraintLayout 1.1.0 beta1 you have to add the google maven repo:
repositories {
maven {
url 'https://maven.google.com'
}
}
More info here.

Dex Exception - I can't resolve

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'

Android - Cannot use "import com.google.gdata.data.youtube" in my project

I think i have downloaded the correct .jar files but i cant seem to access com.google.gdata.data.youtube to get VideoEntry. Can someone please direct me to where this .jar file is.
This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.xxx.xxx.xxx"
minSdkVersion 15
targetSdkVersion 23
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:23.1.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.api-client:google-api-client:1.19.1'
compile files('libs/gdata-client-1.0.jar')
compile files('libs/google-api-client-1.21.0.jar')
compile files('libs/google-api-client-android-1.21.0.jar')
}
Ive been searching the web for this .jar file and cant find it.

Android Studio Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

I am getting started with Parse and Facebook SDK in Android Studio. I have integrated it successfully but while running the application I am getting the following error. Can anyone please help me with this. Thanks in advance.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/parse/AbstractQueryController$1.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.tanmaykulkarni.appname"
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(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.parse.bolts:bolts-android:1.3.0'
compile 'com.parse:parse-android:1.12.0'
compile 'com.parse:parsefacebookutils-v4-android:1.10.4#aar'
}
You should search for AbstractQueryController to check which dependency this class includes. Then you should update you script to ensure that this class is only included once. Do it like in the following example:
testCompile('org.robolectric:robolectric:3.0') {
//exclusions due to android.jar conflict
exclude module: 'httpclient'
exclude module: 'commons-logging'
}

How to run app in Android Studio with shared library-module from other project?

I use a self-written library-module within another project like it was suggested in
https://code.google.com/p/android/issues/detail?id=105570
and
Android Studio 0.8.1 Creating Modules without copying files?
I added the lines to settings.gradle and furthermore added the included library via "Project Structure"-Dialog as a dependency to the project. I use Android Studio 1.2.2.
Everything within the IDE looks fine (imports are working, library-code can be browsed and edited, both modules can be "maked" without errors), but I can't seem to launch the project on my phone / emulator.
I get a "classNotFoundException" for the first class from the library that is used in the app.
I copy-pasted the entire project class by class from Eclipse where it would run without problems.
What do I have to do to get the compiled classes of the library into my app onto my phone?
settings.gradle
include ':app'
include ':Sudoku'
project(':Sudoku').projectDir=new File('/../Libs/sudoku')
build.gradle (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.frozenmilkmeteoroids.sudokuapp"
minSdkVersion 15
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.2.0'
compile project(':Sudoku')
}
build.gradle (library)
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
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:22.2.0'
}
I also use Android Studio 1.2.2 and here is step by step of how to create the standalone library project and reference it from your main project:
create the android project library as you would for a normal android project. Call it libProjectName
rename the libProjectName's app module to libModuleName
in the libModuleName's build.gradle change:
apply plugin: 'com.android.application' to apply plugin: 'com.android.library' and remove applicationId from defaultConfig section
Go to the main project i.e the project to reference libProjectName
edit settings.gradle, add:
include ':libProjectName:libModuleName'
project(':libProjectName:libModuleName').projectDir=new File('relative/path/libProjectDir/libModuleDir')
edit build.gradle in app Module, add:
compile project(':libProjectDir:libModuleName')
Now assuming that the module and module-directory name in Sudoku is moduleSudoku and applying the steps above, the solution is:
settings.gradle
include ':app'
include ':Sudoku:moduleSudoku'
project(':Sudoku:moduleSudoku').projectDir=new File('/../Libs/sudoku/moduleSudoku')
build.gradle (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.frozenmilkmeteoroids.sudokuapp"
minSdkVersion 15
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.2.0'
compile project(':Sudoku:moduleSudoku')
}
build.gradle (library)
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
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:22.2.0'
}

Categories