No virtual methods newJsonReader(Ljava/io/Reader;) issue when generating build - android

I have been using retrofit2 along with Gson convertor in many applications. But currently I'm contributing to an existing project and i have used both dependencies. While running the project directly, it works perfectly. But whenever I generate a debug or release build, This error appears in Toast and Api content is not parsed.
Proguard is disabled. Here is the error:
No virtual method
newJsonReader(Ljava/io/Reader;)Lcom/google/gson/stream/JsonReader; in
class Lcom/google/gson/Gson; or its super classes (declaration of
'com.google.gson.Gson' appears in
/data/app/com."packagename"/base.apk:classes2.dex)
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.medris.medrisemt.medrishcemt"
minSdkVersion 22
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'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a'
universalApk true
}
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':zoomsdk')
implementation project(':zoomcommonlib')
implementation project(':redirectionalgorithm');
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'io.jsonwebtoken:jjwt:0.9.0'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'commons-codec:commons-codec:1.9'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'org.apache.httpcomponents:httpcore:4.4.1'
testImplementation 'junit:junit:4.12'
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'io.nlopez.smartlocation:library:3.3.3'
implementation 'com.google.android.gms:play-services:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
I have searched for relevant answers but no satisfactory results. I have tried to downgrade the gson & retrofit dependencies but no success.
Update
I have updated the Gson & retrofit-convertor dependencies in the gradle code above to the one I was actually using initially. I mistakenly posted the downgraded ones that I tried for testing.

Try this,
I started using the newer versions:
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
And the error disappeared.
After adding this dependencies in your gradle file, please clean and
rebuild your project.

write this in build.gradle > these are newer versions
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'

Related

App is not running on Android 4.4 and 5.1

My application works on Android 6 and above, but I tested it on Android 4.4 and 5.1 it is installed normally but when running it crushes
this is my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.gogrocer.tcc"
minSdkVersion 19
targetSdkVersion 28
versionCode 3
versionName "1.2"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
dexOptions {
preDexLibraries = false
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven {
url "https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleDynamicVersion,GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
implementation 'com.android.support:design:28.+'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.squareup.retrofit2:retrofit:2.2.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.5'
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.5'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.5'
implementation 'com.daimajia.swipelayout:library:1.2.0#aar'
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.koushikdutta.ion:ion:2.2.1'
implementation files('libs/PGSDK_v1.0.jar')
implementation 'com.github.franmontiel:LocaleChanger:0.9.2'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.shamanland:fonticon:0.1.8'
implementation('com.nispok:snackbar:2.11.+') {
// exclusion is not necessary, but generally a good idea.
exclude group: 'com.google.android', module: 'support-v4'
}
implementation 'com.google.guava:guava:19.0'
implementation 'org.bouncycastle:bcprov-jdk16:1.46'
implementation 'com.razorpay:checkout:1.5.2'
implementation 'commons-codec:commons-codec:1.10'
implementation 'com.google.android.gms:play-services-appindexing:9.8.0'
implementation files('libs/httpmime-4.2.5-sources.jar')
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Device compatibility overview
Android is designed to run on many different types of devices, from phones to tablets and televisions. As a developer, the range of devices provides a huge potential audience for your app. In order for your app to be successful on all these devices, it should tolerate some feature variability and provide a flexible user interface that adapts to different screen configurations.
The device your app can run on, depends on the minimum API level you selected when creating the project. For your app to run on lower android versions, you need to select a low API (I usually go with API 19 : android 4.4) when creating your project
edit your minSdkVersion to 15 instead of 19
That was because you wanted it to work for android 6.0 and above in your code
When setting I believe you set its configuration for higher versions. check if this is the case

Cannot resolve symbol 'CalligraphyContextWrapper'

Till yesterday everything was working fine but today i have updated my Android studio from 2.3 to 3.1 and i am getting this error now. But even i am getting Cannot resolve symbol CalligraphyContextWrapper, still project is successfully clean and build and the font is changing fine. I am surprised if everything is working fine then why this error appears. You can see the error in image and also i am adding my gradle code below. Please let me know if i am doing something wrong.
build.grade:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.package"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:27.0.0'
implementation 'com.android.support:cardview-v7:27.0.0'
/* Retrofit */
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.squareup.okhttp3:okhttp:3.4.2'
//multi dex
implementation 'com.android.support:multidex:1.0.1'
//Picasso
implementation 'com.squareup.picasso:picasso:2.5.2'
//Buimplementationtter knife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//planet payment gateway
implementation 'com.google.android.gms:play-services-wallet:11.0.4'
//font
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'io.card:android-sdk:5.5.1'
}
I have also raised the issue in github but there is no response from Calligraphy team.
https://github.com/chrisjenx/Calligraphy/issues/449#issuecomment-386390551
Any help or clue will be appreciated.
You can Downgrade version. Use 2.2.0 instead of 2.3.0.
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
Then Clean-Rebuild-Run.
I am not sure if it is related but I've resolved a similar issue by doing the following;
Remove the dependency from gradle build file
Sync the gradle file
Put the same dependency and sync it again.

Android Error while merging dex archives

After updating my android studio and build tool version get this error.I have tried all the solution available for this problem over internet , but not successful
don't know why this is happening ??
Android studio version: 3.1
Gradle version": 4.4
Gradle plugin : 3.1
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
My build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.abc.abc"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true //Tryed this but not worked
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
maven {
url 'https://github.com/jitsi/jitsi-maven-repository/raw/master/releases'
}
// maven { url "https://dl.bintray.com/michelelacorte/maven/" }
mavenCentral()
}
configurations {
all*.exclude module: 'support-v4'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:support-fragment:27.1.0'
// multipart entity
implementation('org.apache.httpcomponents:httpmime:4.+') {
exclude module: "httpclient"
}
implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
// implementation 'com.wonderkiln:camerakit:0.13.0'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'org.jitsi.react:jitsi-meet-sdk:1.9.0'
// compile 'com.google.code.gson:gson:2.2.4'
// compile 'com.android.support:support-emoji:26.0.1'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.yalantis:ucrop:2.2.0-native'
implementation 'com.pnikosis:materialish-progress:1.7'
implementation 'org.igniterealtime.smack:smack-android-extensions:4.2.0'
implementation 'org.igniterealtime.smack:smack-experimental:4.2.0'
implementation 'org.igniterealtime.smack:smack-tcp:4.2.0'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.googlecode.libphonenumber:libphonenumber:7.0.4'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.google.android.gms:play-services-places:11.8.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.eyalbira.loadingdots:loading-dots:1.0.2'
implementation 'de.hdodenhof:circleimageview:2.1.0'
// implementation 'com.google.android.exoplayer:exoplayer:2.7.1'
// compile 'it.michelelacorte.swipeablecard:library:2.3.0#aar'{
// exclude module: 'appcompat-v7'
// exclude group: 'com.android.support'
// }
// BUTTER KNIFE
implementation('com.jakewharton:butterknife:8.5.1') {
exclude module: 'appcompat-v7'
exclude group: 'com.android.support'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
// implementation project(':libemoji')
implementation 'com.android.support:support-v13:27.1.0'
}
It's waste almost my 10 days...
most confusing error ever encounter..
This error happens if your code has two different modules of google-play-services or support-v4 which are using different versions of these libraries.
Check the dependencies of the libraries you are using in your project or use
gradle app:dependencies
to see dependency tree of your project and then when you find out which libraries is used with different version, add it to your dependencies with correct version. For example if google-play-services:location:11.2.0 appeared in your dependencies, replace it with google-play-services:location:11.8.0
Usually you will see a warning or error message in your build.gradle file (i.e. one dependency will be marked with red underline showing it cause version mismatch) in such cases.
In my case, project and module's package name is same. When running in debug mode, everything is okey. But when i want to build release mode. I got this error. Renaming package name is the solution for me.

Unable to merge dex this error keeps getting everytime

The error is Error
:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. >
java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have tried all the solutions given on stackoverflow but none of them worked for me.
This is app level gradle file. I think I am using all the latest dependencies.
app level build.gradle file is uploaded here. help me to solve this problem
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId"com.example.pratikrathi.registerapp"
minSdkVersion 20
targetSdkVersion 26
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraintlayout:1.0.2'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-firestore:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
apply plugin: 'com.google.gms.google-services'
You are mixing old firebase dependencies with the new firebase dependencies.
You need to remove the following from your root build.gradle dependencies:
classpath 'com.firebase:firebase-client-android:2.3.1'
Then check and remove old firebase depedencies from your module build.gradle. Please read https://firebase.google.com/support/guides/google-android
UPDATE
You also have a duplicated support library.
'com.theartofdev.edmodo:android-image-cropper:2.6.+' library implicitly using support library version 27+, which you can check from its root build.gradle.
You can fix it by exclude support library from image-cropper like this:
implementation ("com.theartofdev.edmodo:android-image-cropper:2.6.+") {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
Or updating all of your support library to version 27.1.0.

Error:Execution failed for task ':processDebugResources'. > Failed to execute aapt

I know there are very similar questions asked previously but before I make any drastic changes I thought I would post the question here first.
This is the error I'm getting.
My build.gradle is like this
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.microsoft.graph.helpdesk"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}
configurations {
all {
resolutionStrategy.force 'com.android.support:support-annotations:23.4.0'
}
}
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
dependencies {
// Azure AD
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.android.support:support-vector-drawable:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.github.baoyachi:StepView:1.9'
implementation 'com.github.vipulasri:timelineview:1.0.6'
compile(project(':o365-auth'))
// Dagger compiler for DI annotation support
annotationProcessor 'com.squareup.dagger:dagger-compiler:1.2.5'
provided('com.squareup.dagger:dagger-compiler:1.2.5')
// Butterknife
annotationProcessor 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.microsoft.graph:msgraph-sdk-android:1.1.0'
compile 'joda-time:joda-time:2.9.4'
compile 'com.google.guava:guava:19.0'
compile 'com.android.volley:volley:1.1.0-rc2'
compile 'com.android.support:design:27.0.2'
// Test libraries
androidTestCompile 'com.android.support:support-annotations:23.4.0'
//noinspection GradleCompatible
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
apply plugin: 'com.google.gms.google-services'
I have tried all the other solutions I could find but nothing has worked so far.
If anyone has any help at all it would be much appreciated
[EDIT] I have actually tried to run three other projects using API 27 and I am getting the same error.
at project ':o365-auth' that helped me to compile it;
try adal latest version or design instead appcompat etc
dependencies {
// compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
// Dependency injection
compile 'com.squareup.dagger:dagger:1.2.5'
provided 'com.squareup.dagger:dagger-compiler:1.2.5'
// Azure AD
compile 'com.microsoft.aad:adal:1.12.0'
}
compile(project(':o365-auth'))
have similar issues;
prev on 23 and 23.0.3 all work good
tried upper gradle but same issues on 25 too

Categories

Resources