transformClassesWithJarMergingForDebug TransformException - build-dependencies

After updating to android studio 2.1 and while i tried to use new gradle my project started crashing with kinda that:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException: java.util.zip.ZipException: >duplicate entry: org/objectweb/asm/tree/AbstractInsnNode.class
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "application.id.is.here"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding
{
enabled = true
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = true
}
}
repositories {
mavenCentral()
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.mikepenz:materialdrawer:4.6.4#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1+'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:design:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.vk:androidsdk:+'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.tools.build:gradle:2.1.0+'
compile ('com.google.android.gms:play-services-maps:8.3.0'){
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.7.2+'
}
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
}
and Top-level build:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha1'
}
}
allprojects {
repositories {
jcenter()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If you have any ideas - please help. None of solvations i found for this problem worked out for me.

Igor's answer worked for me. I had the exact same issue (after getting all those exclusions in there). Kind of a pain getting Android Studio 2.1 running.
Quit Android Studio then clear caches:
cd ~/.gradle/caches
rm -r *
Restart Android Studio and now it should work.

Related

Android dependency 'com.google.firebase:firebase-iid' has different version for the compile (16.0.0) and runtime (18.0.0) classpath

In my react native application i am integrating react-native-push-notification and getting this error.
app/build.gradle
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "xxxxxxx"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-push-notification')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
Project build.gradle
// 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.0.1'
classpath 'com.google.gms:google-services:4.0.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.0.2"
}
}
}
}
I tried various solutions like changing from "implementaion" to "api" , in configuration.all adding check to fetch particular version of firebase-core, but nothing worked.
React Native version is 0.55.4
I found the solution.
In my project's build.gradle buildscript->dependencies i replaced version of the google-services gradle plugin from "4.0.2" to "4.2.0" and it worked.
classpath 'com.google.gms:google-services:4.2.0'
The library react-native-push-notification has a dependency declared as '+' for the com.google.firebase:firebase-messaging in it's build.gradle. This will fetch the latest version of the library from maven repo.
This is clashing with your version declaration in your android/app/build.gradle file, which is 16.0.1.
Add this to your project level build.gradle
ext {
googlePlayServicesVersion = "[your_desired_version]"
firebaseVersion = "[your_desired_version]"
}

after install of react-native-camera accured this error. tried to change versions and sdk tools as suggested in some answers on git but no sollution

Error:Could not find com.android.tools.build:gradle:3.1.2.
Searched in the following locations:
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.jar
Required by:
project :react-native-push-notification
Open File
my gradle-wrapper.properties-
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
my android/build.gradle-
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 26
def DEFAULT_BUILD_TOOLS_VERSION = "26.0.1"
def DEFAULT_TARGET_SDK_VERSION = 26
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "12.0.1"
def DEFAULT_SUPPORT_LIBRARY_VERSION = "27.1.0"
android {
compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 1
versionName "1.0.0"
}
lintOptions {
abortOnError false
warning 'InvalidPackage'
}
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com'
}
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
dependencies {
def googlePlayServicesVersion = rootProject.hasProperty('googlePlayServicesVersion') ? rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
def supportLibVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIBRARY_VERSION
compileOnly 'com.facebook.react:react-native:+'
compileOnly 'com.facebook.infer.annotation:infer-annotation:+'
implementation "com.google.zxing:core:3.2.1"
implementation "com.drewnoakes:metadata-extractor:2.9.1"
implementation "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"
implementation "com.android.support:exifinterface:$supportLibVersion"
implementation "com.android.support:support-annotations:$supportLibVersion"
implementation "com.android.support:support-v4:$supportLibVersion"
}
my app file-
apply plugin: "com.android.application"
import com.android.build.OutputFile
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.myappname"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-camera')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-push-notification')
compile project(':react-native-maps')
compile project(':react-native-i18n')
// compile project(':react-native-vector-icons')
// compile project(':react-native-restart')
// compile project(':react-native-push-notification')
// compile project(':react-native-maps')
// compile project(':react-native-i18n')
compile project(':react-native-vector-icons')
compile project(':react-native-restart')
compile project(':react-native-push-notification')
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile 'com.google.android.gms:play-services-base:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile project(':react-native-i18n')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:23.4.1"
compile ("com.facebook.react:react-native:0.53.3") { force = true } // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
def task = task(copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
})
task
myAppname 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.1.2 '
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
jcenter()
google()
}
}
This has something to do with versions only.
Try with the changes mentioned below and this might help.
gradle-wrapper.properties -
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
android/build.gradle -
buildscript {
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

Fabric / Crashlytics : gradle needs to run twice

I am working on an app, and when building it using gradle in command line ("clean build" or even "clean installRelease"), I am facing the issue where Crashlytics fails to start :
java.lang.RuntimeException: Unable to create application XXXXXXXX: io.fabric.sdk.android.services.concurrency.UnmetDependencyException: com.crashlytics.android.core.CrashlyticsMissingDependencyException:
This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.
After trying many things presented on SO, I found out that if I ran :
./gradlew clean installRelease
./gradlew installRelease
my application starts without any issue.
It's a bit of a pain, as I have to build the app twice before publishing it (and if I ever forget to do it, I am publishing an unusable app :/
My gradle file is set up correctly (at least, the plugin does not complain about it), and gradle is up to date (gradle 2.9, android plugin 1.5.0, crashlytics 2.5.4, ...)
Here are a few lines from my build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.20.1'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'io.fabric'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
std {
}
}
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "XXXXXXXXXXX"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.std
}
debug {
signingConfig signingConfigs.std
}
}
productFlavors {
stubbed {
buildConfigField "boolean", "STUBBED", "true"
}
real {
buildConfigField "boolean", "STUBBED", "false"
}
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
dataBinding {
enabled = true
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.4#aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.jakewharton:butterknife:7.0.1'
}
If anyone has ever faced and fixed this kind of problem, I'd love to hear about it :)
Thanks !

Gradle Failed to resolve: commons-io:commons-io:+

When syncing Android project with gradle in android studio , it fails resolving
the packages shown in the screeshot below .
here's my build.gradle :
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.dmbteam.cityguide"
minSdkVersion 10
targetSdkVersion 22
versionCode 4
versionName '4.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'commons-io:commons-io:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:cardview-v7:+'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile('org.simpleframework:simple-xml:2.7.+') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile project(':pinterest_lib')
compile('com.crashlytics.sdk.android:crashlytics:2.4.0#aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services-maps:7+'
compile 'com.google.android.gms:play-services-location:7+'
compile 'com.google.android.gms:play-services:7+'
}
under repositories, I usually find that I end up having to have a chain something like this:
repositories {
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
In other words, it 1st tries to use your local maven repo, then the specific maven repo/mirror, and then falls back to jcenter as a last resort.

Error in Android Studio Build (version 1.2.1.1) and Gradle (version 1.2.3)

Since upgrading to AS 1.2.x I cannot build my project.
Every time I build (or clean or Invalidate Caches/Restart) I get the following error message:
My gradle build files are as follows:
// 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.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android
{
signingConfigs {
config { keyAlias 'ScoularAndroidKey'
keyPassword 'password'
storeFile file('C:/Users/bschmiedeler/.AndroidStudio/scoularkeystore.jks')
storePassword 'password'
}
}
name="Scoular"
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.scoular.scoular"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug{
debuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/commons-lang-2.3.jar')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile files('src/main/assets/library-1.0.10.jar')
}
Any help would be greatly greatly appreciated.