Android studio APK buil error transformClassesWithJarMergingForDebug - android-studio

I'm trying to build APK, but there is an error when I try to make it.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback.class
Following is my build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "jordan.personicle"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
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 files('libs/ajt-2.9.jar', 'libs/javaml-0.1.7.jar')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services:11.0.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'org.jsoup:jsoup:1.7.3'
compile 'com.android.support:multidex:1.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
This is my build.gradle (Project)
// 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:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I think there is no duplication for gcm. What is the problem?
Thanks,

Make sure you use the same version in all your google play services libs:
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
See https://stackoverflow.com/a/42610163/1370087

Related

Migrating to the New Places SDK Client

When I add in my gradle dependencies implementation 'com.google.android.libraries.places: places: 1.0.0'
I continue with the error: Java Compiler error: cannot access Hide
org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
Here is my list of dependencies:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
buildToolsVersion '26.0.3'
defaultConfig {
applicationId 'com.test.pass'
minSdkVersion 17
targetSdkVersion 26
versionCode 13
versionName '1.0.3'
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
dexOptions {
javaMaxHeapSize '4g'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
}
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'
exclude group: 'com.google.code.findbugs'
})
compile('com.mikepenz:fastadapter:2.0.0#aar') {
transitive = true
}
compile 'com.afollestad.material-dialogs:core:0.9.0.0'
compile 'com.mikepenz:iconics-core:2.8.1#aar'
compile 'com.mikepenz:fontawesome-typeface:4.6.0.2#aar'
compile('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.guava:guava:19.0'
compile 'com.dmitrymalkovich.android:material-design-dimens:1.4'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'me.relex:circleindicator:1.2.2#aar'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.google.firebase:firebase-core:12.0.1'
compile 'com.google.firebase:firebase-messaging:12.0.1'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.google.android.gms:play-services:12.0.1'
compile 'org.greenrobot:eventbus:3.1.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.siyamed:android-shape-imageview:0.9.3'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.balysv:material-ripple:1.0.2'
}
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
dependencies {
implementation 'com.google.android.libraries.places:places:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
and here is my project level gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.realm:realm-gradle-plugin:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
// maven {
// url 'https://maven.google.com/'
// name 'Google'
// }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Add this in your app gradle file under dependencies:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
this is not my solution, I got it from other guy from SO, but can't find that question. I will add the link to that post later.
Edited: Original Answer

Design view not getting displayed on Android Studio

I just imported a project, but when i try to enter design view this shows up:
My current gradle version is the latest 26.0.2 by the way. I'm not sure what to do, anyone have an idea?
Here are some Gradle Scripts:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion
defaultConfig {
applicationId "com.example.Ron.myapp"
minSdkVersion 15
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'
}
and
// 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:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I solved the problem myself. I upgraded the compileSdkVersion aswell as the minSdkVersion along with the dependencies. It now looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion
defaultConfig {
applicationId "com.example.Ron.myapp"
minSdkVersion 18
targetSdkVersion 26
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:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'
}
please update your support lib and compileSdkVersion like below.
compileSdkVersion = 25
buildToolsVersion = "25.0.2"
minSdkVersion = 18
// Library versions
supportLibraryVersion = "25.0.0"
also add ConstraintLauout gradle in gradle file.
compile 'com.android.support.constraint:constraint-layout:1.0.2'
For More details please check : https://stackoverflow.com/a/45115111/1343788
known problem
just add
compile 'com.android.support.constraint:constraint-layout:1.0.2'
in your gradle file,
it will fix it

Android Studio cannot resolve dependency

I use Android studio to create a blank project, but cannot compile.
below is its error:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration':app:_debugUnitTestApkCopy'.
> Could not resolve junit:junit:4.12.
Required by:
project :app
> Could not resolve junit:junit:4.12.
> Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
> jcenter.bintray.com:443 failed to respond
I tried to use a proxy
and checked proxy settings with the failed url 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'
and it show me success
but when I compile the project, it's still the same error.
this is my gradle.properties file:
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
this is project build.gradle file:
// 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:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
this is app build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.myapplication"
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:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
}
finally, I solved my question
the proxy I use is a sockts5 proxy
the autogenerate gradle.properties file use a http proxy
after I change the gradle.properties it's worked
this is my new gradle.properties:
org.gradle.jvmargs=-Xmx1536m -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1080

Create APK file of automation script using Android Studio

after put appium 'java-client' dependencies in android studio not build .apk what i do please tell me
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
dexOptions {
incremental true
jumboMode = true
// preDexLibraries = false
}
defaultConfig {
applicationId "com.example.ignatiuz.photoboothapplication"
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'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
repositories {
jcenter()
mavenCentral()
}
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 'io.appium:java-client:3.4.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'commons-logging:commons-logging:1.2'
// compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
compile 'org.apache.httpcomponents:httpcore:4.4.6'
testCompile 'junit:junit:4.12'
compile files('libs/commons-logging-1.2.jar')
compile files('libs/httpclient-4.5.3.jar')
compile files('libs/httpcore-4.4.6.jar')
}
and my jar detail
and my error
Error Text
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: net/sf/cglib/beans/BeanCopier$BeanCopierKey.class
You can use gradle to import all the dependencies that you need instead of adding them in /libs folder
These are the dependencies I'm having in build.gradle for connecting and running Appium tests.
compile 'junit:junit:4.12'
compile 'io.appium:java-client:4.1.2'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'commons-lang:commons-lang:2.6'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.http-client:google-http-client:1.21.0'
compile 'com.testdroid:testdroid-api:2.9'
compile 'com.google.http-client:google-http-client-jackson2:1.21.0'

Showing error fix plugin version and sync projects in android studio

i am new in Android Studioand when i create a new project suddenly i just got an error message i.e, Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "9ba5989c7b283b0ec145cc20641f7155619d6148"
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "************"
minSdkVersion 16
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'
}
My build.gradle(project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i have updated my Android studio 2.0 but it always showing Fix plugin version and sync project when open create a project.please anyone can tell me what i should do to rectify this problem.
Thanks in advance...
classpath 'com.android.tools.build:gradle:2.0.0-alpha2' instead of this use
classpath 'com.android.tools.build:gradle:2.2.+' this fixed the same error for me!

Resources