Even after adding the dependencies and importing the class I am getting java.lang.NoClassDefFoundError: com.squareup.okhttp.logging.HttpLoggingInterceptor.
Can anyone please help?
Gradle Build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xyz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
}
}
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:support-v4:23.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
}
In my case, I found that the versions of the okhttp3 and okhttp3:logging-interceptor dependencies needed to exactly match. So for example:
...
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
...
Could be a compatibility problem with retrofit.
Try with :
implementation 'com.squareup.okhttp:logging-interceptor:2.5.0'
This post could be help
App crash on HttpLoggingInterceptor
Also it can be connected with multidex true option in your build.gradle (yes, seems like some devices have problems with multidex apps (read, Samsung))
If this is your case, switch this flag off and rebuild your project. Consider using
minifyEnabled true
shrinkResources true
to reduce your apk size. If it is still too large, that's really weird and bad news, but there are some techniques to put your apk on diet.
Related
I searched alot but not found any solution of my problem, i tried to run my app on any device and i got this error:
it's throwing an error with com.github.bumptech.glide:glide:3.5.2 ,but it's used only single time how the classes of it got duplicate i run this app before with the same dependencies with out any trouble but suddenly this error appear while i run the app.
app.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "info.androidhive.firebase"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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:25.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.android.support:design:25.1.0'
compile 'com.firebaseui:firebase-ui-database:1.1.1'
compile 'com.firebaseui:firebase-ui-storage:1.1.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.crystal:crystalrangeseekbar:1.1.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Browse to your project's "libs" directory and remove redundant "glide.x.x" which is causing the error due to redundancy.
Try putting this line :
enforceUniquePackageName false
after buildtoolVersion in your gradle
compile 'com.google.firebase:firebase-database:10.2.0'
After I added this dependency, the problem occurs. Before that, the GoogleApiClient works fine. I remove that dependency, the problem is solved. Do GoogleApiClient and Firebase have conflict about each other? Please help.
EDIT: Gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "application.id"
minSdkVersion 16
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.firebase:firebase-database:10.2.0'
}
GoogleApiClient and firebase-database will work, if you add below dependencies,
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
firebase-database dependency will not affect GoogleApiClient
Please keep same versions for firebase & Google Play Services API(10.2.0)
Please re-check you have set up everything as below guidance,
https://firebase.google.com/docs/android/setup
I am currently having some trouble running my project.
duplicate entry: com/google/android/gms/internal/zzai$zza.class
The error is saying that I have a duplicate dependency, but I can't see a duplicate anywhere!
The error appears on this line of code:
compile 'com.google.android.gms:play-services-ads:8.4.0'
It says that it has found versions 9.8 and 8.4. I only see version 8.4 though.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.tedrasoft.templategoogle"
minSdkVersion 15
targetSdkVersion 23
versionCode=7
versionName="1.6"
multiDexEnabled true
manifestPlaceholders = [manifestApplicationId : "${applicationId}",
onesignal_app_id : "ed282ffa-1e9e-4dd8-9edc-cfdcbe8376bd",
onesignal_google_project_number: "3902815545"]
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/chartboost.jar')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.facebook.android:audience-network-sdk:4.+'
compile 'com.onesignal:OneSignal:2.+#aar'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-analytics:+'
compile 'com.google.android.gms:play-services-location:+'
compile files('libs/jackson-annotations-2.1.0.jar')
compile files('libs/jackson-core-2.1.0.jar')
compile files('libs/jackson-databind-2.1.0.jar')
}
In my case, it's because of the
compile 'com.facebook.android:audience-network-sdk:4.+'
I change it to this:
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group:"com.google.android.gms"
}
No more problem!
Make these versions match... so 8.4.0, not + which pulls the latest 9.8 I think, now?
compile 'com.google.android.gms:play-services-analytics:+'
compile 'com.google.android.gms:play-services-location:+'
Also, these are 1) unneccessary lines (because of compile fileTree), and 2) you should make them like the others and not use jar files.
compile files('libs/jackson-annotations-2.1.0.jar')
compile files('libs/jackson-core-2.1.0.jar')
compile files('libs/jackson-databind-2.1.0.jar')
Upgrade google play services (maps, location and gcm) from 9.0.0 to 9.2.0
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
Then add this dependency:
compile 'com.google.android.gms:play-services-places:9.2.0'
My Android app is working perfectly up to Lollipop. But it is hanging in Marshmallow.
When I open the app,back to home button,again open the app. It hangs. I have used all these libraries:
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.google.android.gms:play-services-analytics:9.0.2'
compile "com.google.android.gms:play-services:9.0.2"
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.android.support:multidex:1.0.0'
And i use :
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.appid"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
What time of exception are you getting?
Check to see if you're requesting any of these permissions: https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
If you are, then you will have to specifically request them using requestPermissions
I have found the solution.
I have just updated libraries to the latest libraries ie
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.mcxiaoke.volley:library:1.0.1'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile "com.google.android.gms:play-services:9.2.0"
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.android.support:multidex:1.0.1'
Since i haven't use dangerous permission i dont need to handle on runtime.
My all other dependencies are successfully being resolved except-:
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'com.parse:parse-android:1.+'
My build.gradle is -:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.transenigma.iskconapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'com.parse:parse-android:1.+'
compile 'joda-time:joda-time:2.9.1'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.makeramen:roundedimageview:1.5.0'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.nineoldandroids:library:2.4.0'
}
There is no problem in other libraries. Actually I made this project using internet without proxy and now I have changed Internet to that of proxy. although I have made changes in the settings but still these 2 dependencies are not being resolved. All other dependencies are successfully being resolved meaning that the internet is working properly. What is the issue.
You can use buildToolsVersion "23.0.1"
Use compile 'com.parse:parse-android:1.12.0' instead of yours .
Actually compile 'com.parse:parse-android:1.+' is not suitable (old ) for your dependencies & It's a Exact Version .