Cannot relocate dependencies using shadow plugin for gradle - android

I have a project wich uses a library which is contained in an aar file. The problem is that my application uses daager 1 for dependency Injection, it uses Dagger 1 because I use a framework that is compatible only with dagger 1. The problem is that the library I need to use uses Dagger 2 for dependency injection so when I add the library and I add the depencies in my application gradle file it doesn't work (as expected because Dagger 1 and Dagger 2 cannot be used at the same time out of the box), so I am trying to relocate the Dagger 2 depencencies using the shadow plugin.
I followed this tutorial on how to do it http://fernandocejas.com/2016/08/03/android-dagger-1-and-2-living-together/
the jar files are generated inside the modules but are empty, they don't contain the renamed files for Dagger 2. I downloaded the project from github https://github.com/android10/two-daggers and it works but I can manage to get it working in my project.
My gradle files from the modules created are an exact copy from those in the tutorial. Can you see what I am doing wrong?
Also the shadow.gradle is an exact copy.
The only difference is my build.gradle from my app which is
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.jakewharton.hugo'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 16
targetSdkVersion 23
versionCode Integer.parseInt("$APP_VERSION_CODE")
versionName "$APP_VERSION_NAME"
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
// Enabling multidex support.
multiDexEnabled true
}
testBuildType "instrumentation"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions{
javaMaxHeapSize "3g"
incremental true
}
testOptions {
unitTests.returnDefaultValues = true
}
//Append version to Apk name
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace('app-', "AccessApp-")
fileName = fileName.replace('.apk', "-" + "$APP_TAG" + ".apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
lintOptions {
abortOnError false
disable 'InvalidPackage'
}
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
classpath "com.neenbedankt.gradle.plugins:android-apt:1.4"
}
}
apply plugin: "com.github.johnrengelman.shadow"
dependencies {
repositories {
maven {
url "http://xxx.xx.xxx:0000/xxx/xxxxxx/"
}
jcenter()
flatDir {
dirs 'libs'
}
}
//Dagger 1
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.dagger:dagger:1.2.2'
//Dagger 2
apt project(path: ':two-daggers-compiler', transitive: false)
compile project(path: ':two-daggers-library', transitive: false)
compile fileTree(dir: 'libs', include: ['*.jar'])
//Unit Tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
testCompile 'joda-time:joda-time:2.3'
testCompile 'com.squareup.okhttp3:mockwebserver:3.2.0'
testCompile('org.robolectric:robolectric:3.0') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
// Android instrumentation test dependencies
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.4.1'
// Set this dependency to use JUnit 4 rules
androidTestCompile 'com.android.support.test:rules:0.4.1'
// Set this dependency to build and run Espresso tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
// Android dependencies
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
//Rosie Framework
compile 'com.karumi.rosie:rosie:2.1.0'
// Connectivity library
compile 'com.xxx.connectivity:connectivity:1.0.0.013#aar'
// Maps
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.3'
// Hockey App
compile 'net.hockeyapp.android:HockeySDK:4.0.2'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:converter-scalars:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
// Images
compile 'com.squareup.picasso:picasso:2.5.2'
// Google Play Billing
compile 'com.anjlab.android.iab.v3:library:1.0.31'
compile 'joda-time:joda-time:2.3'
// View pager indicator
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1#aar'
compile 'me.grantland:autofittextview:0.2.1'
// Event bus
compile 'org.greenrobot:eventbus:3.0.0'
//Roboto font
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
//MixPanel
compile "com.mixpanel.android:mixpanel-android:4.8.7"
//Amazon
compile "com.amazonaws:aws-android-sdk-mobileanalytics:2.2.9"
//AppsFlyer
compile 'com.appsflyer:af-android-sdk:4.5.0#aar'
//Multidex
compile 'com.android.support:multidex:1.0.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
// Smart tab layout
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
// Permissions
compile 'com.karumi:dexter:2.2.2'
// AP Geolocation
compile 'com.fon.analytics:analytics-sdk:0.4.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
// WPA sharing library
compile 'com.google.guava:guava:18.0'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'
//multiDex
compile 'com.android.support:multidex:1.0.1'
}

Related

Multiple dex files define Lcom/getkeepsafe/relinker/SystemLibraryLoader;

I am facing this problem when am trying to build my project -> Multiple dex files define Lcom/getkeepsafe/relinker/SystemLibraryLoader;
I have tried to clean the .gradle, deleting the build folder and reinstalling dependencies but its still not working.
Here is my build.gradle:moduleapp
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
buildToolsVersion '26.0.3'
defaultConfig {
applicationId 'com.taxiapp.passenger'
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()
}
}
/* IMPORTANT :
Be careful when update dependencies, different version library may caused error /
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'
}
// compile('pl.droidsonroids.relinker:1.2.2'){
// exclude module: 'pl.droidsonroids.relinker:1.2.2'
// }
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.3'
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'
}
apply plugin: 'com.google.gms.google-services'
And here is my build.gradle:projectmodule
// 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.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
}
Please advice what i can do to solve this proplem
Add this string inside dependecies{} in build.gradle:moduleapp
dependencies {
compile 'com.getkeepsafe.relinker:relinker:1.3.1' //this string
}
it seems that you are using a very old ready-made script, I advise you to do everything by yourself.
I recommend you to use 'implement' or 'api' instead of 'compile'
Also don't use
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
always use a specific version to avoid other 'Multiple dex files define' issues, for example.
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
don't forget to rebuild the project by following step in toolbar-menu: Build -> Rebuild Project.

You should manually set the same version via DependencyResolution [duplicate]

This question already has answers here:
Android dependency has different version for the compile and runtime
(18 answers)
Closed 3 years ago.
Error:Execution failed for task ':app:preDebugBuild'.
Android dependency 'com.google.android.gms:play-services-ads' has different version for the compile (11.8.0) and runtime (11.0.4) classpath. You should manually set the same version via DependencyResolution
My project gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
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()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My module gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'com.bezets.cityappar'
minSdkVersion 16
targetSdkVersion 25
versionCode 4
versionName '1.3.0'
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2g"
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE-FIREBASE.txt'
}
productFlavors {
}
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
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 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:palette-v7:25.3.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile files('libs/volley.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-storage:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'com.google.firebase:firebase-crash:11.0.4'
compile 'com.google.firebase:firebase-ads:11.0.4'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup:otto:1.3.6'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.paolorotolo:appintro:3.3.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
How can I fix it error?
My error is similar with yours, solved with these way.
Error is shown below :
Android dependency 'com.google.android.gms:play-services-tasks' has different version for thecompile (11.4.2) and runtime (15.0.1) classpath. You should manually set the same version via DependencyResolution
Then in file : android/build.gradle ,
I add this script :
allprojects {
...
configurations.all {
resolutionStrategy.force "com.google.android.gms:play-services-
tasks:15.0.1"
}
}
Please see this answer
You can solve it in one of two ways: Define a resolution strategy or include the offending version in your dependencies.
Hope this helps!
Set all Google/Firebase dependency to Same version 11.8.0

Image-Cropper Gradle issue

I am using this library here and I used it in a project and it works fine now I am using it in another project and in build it fires an error
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
java.io.IOException: Can't write [D:\Work\TeqniaTech\Morstan-Doctor\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\AbdallahGaber.gradle\caches\transforms-1\files-1.1\support-core-ui-27.1.0.aar\d05e3ddb1fe5f53fdf878524820d2b3c\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))
and here is my 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 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.teqnia_tech.morstan_doctor"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "0.0.1"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
//location google play service
compile 'com.google.android.gms:play-services-location:11.0.1'
//picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//Twitter
compile 'com.twitter.sdk.android:twitter:3.1.1'
//Timber
compile 'com.jakewharton.timber:timber:4.1.0'
//Butterknife
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.jakewharton:butterknife:8.8.1'
//Date and time
compile 'joda-time:joda-time:2.9.9'
// network
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:+'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
//Twitter
compile('com.twitter.sdk.android:twitter:2.3.2#aar') {
transitive = true;
}
//Facebook SDK
compile 'com.facebook.android:facebook-android-sdk:4.23.+'
// for cropping and selecting image
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
//Firebase
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
//Multidex
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true;
}
}
//Map
apply plugin: 'com.google.gms.google-services'
and For the project that worked that is the Gradle :
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply from: "${project.rootDir}/QA/quality.gradle"
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.teqnia_tech.morstan"
minSdkVersion 17
targetSdkVersion 26
versionCode 22
versionName "0.5.5"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
// general
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:mediarouter-v7:26.0.2'
compile 'com.android.support:customtabs:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.android.gms:play-services:11.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.jakewharton:butterknife:8.8.1'
compile 'com.jakewharton.timber:timber:4.1.0'
// inspection
compile 'com.facebook.stetho:stetho:1.3.0'
compile 'com.facebook.stetho:stetho-okhttp3:1.3.0'
//Facebook SDK
compile 'com.facebook.android:facebook-android-sdk:4.23.+'
// network
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:+'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
// tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.+'
//Twitter
compile('com.twitter.sdk.android:twitter:2.3.2#aar') {
transitive = true;
}
//location google play service
compile 'com.google.android.gms:play-services-location:11.0.1'
//picasso and rounded image
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.makeramen:roundedimageview:2.3.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
//Date and time
compile 'joda-time:joda-time:2.9.9'
//rtl viewpager
// compile 'klogi.com:rtlviewpager:1.0.0'
//Banner slider
compile 'com.ss.bannerslider:bannerslider:1.8.0'
//font changer
// compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'me.anwarshahriar:calligrapher:1.0'
//Searchable spinner
// compile 'com.github.MdFarhanRaja:SearchableSpinner:1.7'
//Firebase
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
//Multidex
compile 'com.android.support:multidex:1.0.1'
//flexable layout
compile 'com.google.android:flexbox:0.3.2'
// for filter enhancing
compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
// for cropping and selecting image
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
//AppIntro
compile 'com.github.apl-devs:appintro:v4.2.0'
compile project(':Spotlight-library')
compile project(':rtlviewpager')
compile project(':spinerdialog')
}
//Map
apply plugin: 'com.google.gms.google-services'
I spent 2 days and I can't find what is the problem , can anyone help
Edit:
I think the library cause conflict but I can't know what is it, any clue please??
I was facing similar problem. But later on I found out that there is one library which is causing that issue.
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
Yes. Image Cropping library. When I commented that line and run project after sync, it worked for me.
Now, how to solve that thing? I have found out that some users already posted this issue in Git Link. Please go through below link, it might help you.
https://github.com/ArthurHub/Android-Image-Cropper/issues/495
As Described in that post.
Reason
This is due to the fact that this library includes support libraries with 27.+ version. Support library 27.1.0 was released yesterday and is automatically included in your project with another version defined by yourself. The lib must not define dynamic version!
Solution
You should force all of your support libraries to use the same version.
configurations.all {
resolutionStrategy {
eachDependency { details ->
// Force all of the primary support libraries to use the same version.
if (details.requested.group == 'com.android.support'
&& details.requested.name != 'multidex'
&& details.requested.name != 'multidex-instrumentation') {
details.useVersion supportLibraryVersion
}
}
}
}
or, You can downgrade library version from 2.6.+ to 2.5.+
compile 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
I was facing issues with
dependencies {
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
}
I changed to
dependencies {
api 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
}
It compiled successfully

Why do I keep getting `isBoxedPrimitive()` error when building the project?

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > java.lang.NoSuchMethodError: com.squareup.javapoet.TypeName.isBoxedPrimitive()Z
I keep getting the same error when using auto-value-parcel and auto-value-firebase. The project works without adding their dependencies and usages. But when I add them back the problem returns. Please take a look at my app/build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "PACKAGE"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
// Android Support Libraries
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:exifinterface:26.0.1'
// JavaPoet
annotationProcessor 'com.squareup:javapoet:1.8.0'
provided 'com.squareup:javapoet:1.8.0'
// Dagger 2
compile 'com.google.dagger:dagger:2.4'
provided 'javax.annotation:jsr250-api:1.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.4'
// AutoValue
provided 'com.google.auto.value:auto-value:1.5'
annotationProcessor 'com.google.auto.value:auto-value:1.5'
// AutoParcel
annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
// AutoValue Firebase
annotationProcessor 'me.mattlogan.auto.value:auto-value-firebase:1.1.0'
provided 'me.mattlogan.auto.value:auto-value-firebase-annotation:1.1.0'
// Firebase
compile 'com.google.firebase:firebase-database:11.4.0'
compile 'com.google.firebase:firebase-auth:11.4.0'
compile 'com.github.frangsierra:rx2firebase:1.1.3'
// RxJava 2
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'com.akaita.java:rxjava2-debug:1.2.0'
// RxAndroid 2
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
// RxLifecycle 2
compile 'com.trello.rxlifecycle2:rxlifecycle-android:2.0.1'
// RxBinding 2
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
// Simple Stack
compile 'com.github.Zhuinden:simple-stack:1.7.2'
// Butterknife
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
// Timber
compile 'com.jakewharton.timber:timber:4.3.1'
// SwipyRefreshLayout
compile 'com.github.orangegangsters:swipy:1.2.3#aar'
// Glide
compile 'com.github.bumptech.glide:glide:4.1.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
// Glide Transformations
compile 'jp.wasabeef:glide-transformations:2.0.2'
// Calligraphy
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
// Lorem Ipsum Generator
compile 'de.sven-jacobs:loremipsum:1.0'
// Pretty Time
compile 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
// Flexible AdannotationProcessorers
compile 'eu.davidea:flexible-adapter:5.0.0-rc2'
// Animated Checkbox
compile 'com.hanks.animatecheckbox:library:0.1'
// EventBus
compile 'org.greenrobot:eventbus:3.0.0'
// Parceler
compile 'org.parceler:parceler-api:1.1.6'
annotationProcessor 'org.parceler:parceler:1.1.6'
//PhotoView
compile 'com.github.chrisbanes:PhotoView:2.0.0'
// Android Image Cropper
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.4'
// File Chooser
compile 'com.droidninja:filepicker:2.0.8#aar'
// Intl Phone Input
compile 'net.rimoto:intlphoneinput:1.0.1'
}
apply plugin: 'com.google.gms.google-services'

Android NoClassDefFoundError after adding constraint layout

I've started getting java.lang.NoClassDefFoundError: for random class and that class changes on my every teammates machine and it's only happening for 5.x devices, we tested on 6.0 and 7.0 but everything is working fine there.
This started happening after adding 'com.android.support.constraint:constraint-layout:1.0.2'
We decide to start using constraint layout in app and since then we're getting this error
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' }
}
def minSdk = hasProperty ('minSdk') ? minSdk : 19
//for debug builds add username to version as suffix
def username = readVersion()
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
dataBinding {
enabled = true
}
lintOptions {
abortOnError false
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
defaultConfig {
applicationId "xxx.xxxx.xxxxxx"
minSdkVersion minSdk
targetSdkVersion 25
maxSdkVersion 25
versionCode 27
versionName "0.0.00"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a", "x86","armeabi"
}
packagingOptions {
exclude "lib/arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
}
debug {
minifyEnabled false
debuggable true
versionNameSuffix "${username}"
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
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 fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:support-v13:25.2.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-plus:10.2.0'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
compile 'com.squareup.picasso:picasso:2.5.2'
//image picker
compile 'com.soundcloud.android:android-crop:1.0.1#aar'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.mobsandgeeks:android-saripaar:2.0.2'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.google.code.gson:gson:2.7'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true;
}
//expandable textview
compile 'com.ms-square:expandableTextView:0.1.4'
//favourite button
compile 'com.github.ivbaranov:materialfavoritebutton:0.1.2'
compile 'org.osmdroid:osmdroid-mapsforge:5.5:release#aar'
compile 'org.mapsforge:mapsforge-map-android:0.6.1'
// compile 'org.mapsforge:mapsforge-map:0.6.1' //not in use
compile 'com.pubnub:pubnub:4.2.0'
compile 'com.github.fernandodev.easyratingdialog:easyratingdialog:+'
compile 'com.zopim.android:sdk:1.3.2.1'
compile 'com.zendesk:sdk:1.7.3.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.zopim.android:sdk:1.3.2.1'
compile 'com.zendesk:sdk:1.7.3.1'
// Android SDK
compile 'com.facebook.android:facebook-android-sdk:4.+'
/*// Audience Network SDK. Only versions 4.6.0 and above are available
compile 'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
compile 'com.facebook.android:account-kit-sdk:4.+'*/
// compile 'net.ypresto.androidtranscoder:android-transcoder:0.2.0'
// compile 'com.github.arimorty:floatingsearchview:1.1.2'
compile 'com.flurry.android:analytics:6.4.2'
//Webview dependancy
compile 'com.thefinestartist:finestwebview:1.2.7'
//autofit textview
compile 'me.grantland:autofittextview:0.2.+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
//compile 'com.facebook.android:facebook-android-sdk:3.21.1'
//video compression
compile project(':ffmpeg4android_lib')
compile files('libs/SCTNotifier.jar')
compile "com.mixpanel.android:mixpanel-android:5.+"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.maps.android:android-maps-utils:0.5+'
}
String readVersion() {
def version = "whoami".execute().text.trim()
version = version.replace("\\", ".")
version = version.replace(" ", ".")
return "_reboot_" + version
}
Update:
I've removed constraint layout from xml's and removed this line:
compile 'com.android.support.constraint:constraint-layout:1.0.2'
And now app is working fine.
Four reasons are generate NoClassDefFoundError in android:
1) The class is not available in Java Classpath.
2) You might be running your program using jar command and class was not defined in manifest file's ClassPath attribute.
3) Any start-up script is overriding Classpath environment variable.
4) Because NoClassDefFoundError is a subclass of java.lang.LinkageError it can also come if one of it dependency like native library may not available.
Before build apk clean your project.

Categories

Resources