Failed resolution of: Lokhttp3/OkHttpClient$Builder; - java

I'm currently using Android studio 2.3, and having error when deploying py project to Kitkat devices, i did several approach explained from here but the error as bellow still happen.
E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution
of: Lokhttp3/OkHttpClient$Builder;
and..
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.OkHttpClient$Builder" on path: DexPathList[[zip file "/data/app/com.mobile.myapp-2/base.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.mobile.myapp-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.mobile.myapp-2/lib/x86, /vendor/lib, /system/lib]]
here is my build.gradle
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'myappkey'
keyPassword 'myapppass'
storeFile file('D:/myapp.jks')
storePassword 'myapppass'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.my.app.mobile"
minSdkVersion 21
targetSdkVersion 25
versionCode 6
versionName "1.1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true
}
productFlavors {
dev {
minSdkVersion 21
}
prod {
minSdkVersion 21
multiDexEnabled true
}
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
debug {
minifyEnabled false
useProguard true
proguardFile 'proguard-project.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
release {
minifyEnabled false
// useProguard false
// multiDexKeepProguard 'multidex-config.pro'
shrinkResources false
zipAlignEnabled true
debuggable false
proguardFile 'proguard-project.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
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('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.2#aar') {
transitive = true
}
compile('com.github.florent37:materialviewpager:1.2.0#aar') {
transitive = true
}
compile 'com.squareup.okio:okio:1.7.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'com.mikepenz:iconics-core:2.8.1#aar'
compile 'com.mikepenz:crossfadedrawerlayout:1.0.0#aar'
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0#aar'
compile 'com.mikepenz:google-material-typeface:2.2.0.3.original#aar'
compile 'com.mikepenz:fastadapter:2.1.5#aar'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.jpardogo.materialtabstrip:library:1.1.1'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.github.rey5137:material:1.2.4'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.github.ganfra:material-spinner:1.1.1'
compile 'com.splitwise:tokenautocomplete:2.0.8#aar'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'
compile 'com.cjj.materialrefeshlayout:library:1.3.0'
compile 'com.theartofdev.edmodo:android-image-cropper:1.2.6'
compile 'com.afollestad.material-dialogs:core:0.9.2.3'
compile 'com.orhanobut:hawk:2.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-ads:9.0.2'
compile 'com.nononsenseapps:filepicker:4.0.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-crash'

Related

Error while mopub integartion

I am integrating MOPUB ADs in application. I am following MOPUB SDK integration steps from https://www.mopub.com/resources/docs/android-sdk-integration/android-getting-started/
After adding mopub-volley-1.1.0.jar, I got following error.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/mopub/volley/AuthFailureError.class
My build.gradle code is
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
multiDexEnabled true
applicationId "com.mopubdemo.android"
minSdkVersion 16
targetSdkVersion 24
versionCode 27
versionName '2.05'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/plexus/components.xml'
}
}
dependencies {
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/FlurryAnalytics-6.2.0.jar')
compile files('libs/acra-4.6.1.jar')
compile project(':mopub-sdk:mopub-sdk-native-video')
compile project(':mopub-sdk:mopub-sdk-native-static')
compile project(':mopub-sdk:mopub-sdk-banner')
compile project(':mopub-sdk:mopub-sdk-rewardedvideo')
compile project(':mopub-sdk')
compile project(':mopub-sdk:mopub-sdk-interstitial')
androidTestCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.johnkil.android-robototextview:robototextview:2.4.2'
compile 'com.google.code.gson:gson:2.4'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0#aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0#aar'
compile 'org.ocpsoft.prettytime:prettytime:4.0.0.Final'
compile 'com.koushikdutta.ion:ion:2.1.6'
compile 'pub.devrel:easypermissions:0.1.5'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:support-annotations:24.1.1'
compile 'com.google.android.gms:play-services:10.2.1'
compile files('libs/mopub-volley-1.1.0.jar')
}
Remove this line and then sync
compile files('libs/mopub-volley-1.1.0.jar')

Duplicate files copied in APK META-INF/LICENSE error showing while trying to run test case

Errors log are below:
Error:Execution failed for task
':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException:
com.android.builder.packaging.DuplicateFileException: Duplicate files
copied in APK META-INF/LICENSE File1:
C:\Users\MYPC.gradle\caches\modules-2\files-2.1\org.apache.httpcomponents\httpmime\4.5\7bdb321e86724b16af6134a0fd22fec649eda971\httpmime-4.5.jar
File2:
C:\Users\MYPC.gradle\caches\modules-2\files-2.1\xerces\xercesImpl\2.11.0\9bb329db1cfc4e22462c9d6b43a8432f5850e92c\xercesImpl-2.11.0.jar
File3:
C:\Users\MYPC.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.6.0\a0990e2e812ac6639b6ce955c91b13228500476e\jackson-annotations-2.6.0.jar
Dependencies I'm using below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.xyz.testauto"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'junit:junit:4.12'
compile 'io.appium:java-client:3.3.0'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'commons-lang:commons-lang:2.6'
compile 'com.google.code.gson:gson:2.5'
compile 'com.testdroid:testdroid-api:2.9'
testCompile 'org.mockito:mockito-core:1.10.19'
compile 'com.google.dagger:dagger:2.4'
annotationProcessor 'com.google.dagger:dagger-compiler:2.4'
configurations {
all*.exclude group: 'commons-logging', module: 'commons-logging'
}
}
How I can remove this error ?
You should add this in your build.gradle section
META-INF directory are recognized and interpreted by the Java 2
Platform to configure applications, extensions;
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
Then Clean-Rebuild-Run

SQLiteAssetHelper utils not found

I had another post earlier about my project having a class not found exception for IOUtils. I fixed that, and now my project is crashing again.
Previous post: Android class not found when running on some devices but not on others
Giving me this stack trace now:
java.lang.NoClassDefFoundError: com.readystatesoftware.sqliteasset.Utils
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.copyDatabaseFromAssets(SQLiteAssetHelper.java:455)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.createOrOpenDatabase(SQLiteAssetHelper.java:400)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getWritableDatabase(SQLiteAssetHelper.java:176)
at com.testing.data.AppDatabase.<init>(AppDatabase.java:87)
at com.testing.data.AppDatabase.getInstance(AppDatabase.java:70)
It works when I try to run it on my tablet, and it crashes when I try to run it on my phone:
Here is the setup:
Android versions:
`Phone: 4.4.2`
`Tablet: 5.1.1`
SDK Setup:
`compileSdkVersion: 25`
`minSdkVersion: 15`
`targetSdkVersion: 24`
Could there possibly something conflicting? Seems unlikely, but they are both Util classes that are not being found.
Grade as requested:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':volley')
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.maps.android:android-maps-utils:0.3.+'
compile 'com.qozix:tileview:2.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'org.twitter4j:twitter4j-core:4.0.4'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
compile 'info.hoang8f:android-segmented:1.0.5'
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.testing.base"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
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'
}
}
repositories {
mavenCentral()
}

:app:transformClassesWithJarMergingForDebug FAILED (jsonpath not used)

I am getting the below error while compiling my android project for emulator v4.1.1. I am not able to generate an apk as well. Below is the error and my gradle file.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/objectweb/asm/AnnotationVisitor.class
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/BCKEY.DSA'
exclude 'AUTHORS'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'META-INF/BCKEY.SF'
pickFirst 'META-INF/maven/com.google.guava/guava/pom.properties'
pickFirst 'META-INF/maven/com.google.guava/guava/pom.xml'
pickFirst 'META-INF/maven/net.minidev/accessors-smart/pom.properties'
pickFirst 'META-INF/maven/net.minidev/accessors-smart/pom.xml'
}
signingConfigs {
config {
keyAlias '********'
keyPassword '********'
storeFile file('C:/Users/Prasang/Downloads/***/****.jks')
storePassword '********'
}
}
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.**********"
minSdkVersion 15
targetSdkVersion 23
versionCode 7
versionName "7.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()}
dependencies {
// compile 'net.minidev:json-smart:2.2'
testCompile 'junit:junit:4.12'
compile files('libs/red5streaming.jar')
compile files('libs/mina-core-2.0.7.jar')
//compile 'fm.jiecao:jiecaovideoplayer:3.4'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile fileTree(include: ['*.java'], dir: 'libs')
compile fileTree(include: ['*.so'], dir: 'libs')
//compile files('libs/red5pro-1.0.2.jar')
// compile 'me.yifeiyuan.periscopelayout:library:1.0.0'
compile 'com.parse:parse-android:1.10.3'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
//compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.4.0'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.wrapp.floatlabelededittext:library:0.0.6'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.github.orangegangsters:swipy:1.2.1#aar'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.github.afollestad.material-dialogs:core:0.8.5.6#aar'
// compile 'com.android.support:support-v4:24.0.0'
compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'com.github.jd-alexander:LikeButton:0.1.8'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.github.kanytu:android-parallax-recyclerview:v1.7'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:percent:23.2.0'
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.gms:google-services:2.0.0-alpha6'
}
apply plugin: 'com.google.gms.google-services'}
probably confict in google-play-services
remove this
compile 'com.google.android.gms:play-services:9.0.2'
and left only this part
compile 'com.google.android.gms:play-services-ads:9.0.2' compile
'com.google.android.gms:play-services-auth:9.0.2' compile
'com.google.android.gms:play-services-gcm:9.0.2'
Also try to clean/rebuild your project

Using deprecated classes in Android Api 23

I upgraded my com.android.support:support-v4 to 23.2.1 because from Android 6.0 we need to check for and request permissions at runtime.
After I upgraded ,all these error message come up
Error:(48, 31) error: package android.support.v4.view does not exist
android.support.v4.view.PagerAdapter does not exist.
So When I added back old android support jar file to my project libs folder ,
ActivityCompat.requestPermissions cannot be resolved .
compile files('libs/android-support-v4.jar')
I tried several solutions and still not working.Is there any workaround to be able to support all?
Here is my gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId ""
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
versionCode 117
versionName 'P.5.53.4'
}
signingConfigs {
release {
storeFile file("something.keystore")
storePassword "1234"
keyAlias "something"
keyPassword "1234"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/ASL2.0'
}
configurations {
all*.exclude module: 'servlet-api'
all*.exclude group: 'com.google.gson', module: 'gson'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildTypes {
release {
}
}
dexOptions {
javaMaxHeapSize "4g"
}
repositories{
mavenCentral()
}
}
dependencies {
compile files('libs/aspectjrt.jar')
compile files('libs/CWAC-SackOfViewsAdapter.jar')
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.3.3.jar')
compile files('libs/jackson-core-asl-1.6.2.jar')
compile files('libs/jackson-mapper-asl-1.6.2.jar')
compile files('libs/universal-image-loader-1.9.1.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile project(':volley')
compile project(':lib')
compile 'com.google.android.gms:play-services:4.3.23'
compile 'com.newrelic.agent.android:android-agent:5.5.0'
compile 'com.google.zxing:core:3.2.1'
compile 'com.opencsv:opencsv:3.7'
compile "com.android.support:support-v4:23.2.1"
compile "com.android.support:support-v13:23.1.0"
compile "com.android.support:cardview-v7:23.1.0"
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
//compile files('libs/android-support-v4.jar')
}
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}

Categories

Resources