Cannot resolve symbol AndroidSchedulers - java

I'm using version 2.0.0 of RxJava, and it seems like I have no access to AndroidSchedulers. I'm unable to get access to mainthread through RxJava

AndroidSchedulers class is a part of RxAndroid library. Add it to your app's build.gradle:
before Gradle v3.0:
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
since Gradle v3.0:
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

Go back to Old Versions:
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
Then to the Newer Version:
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.1.1'
Sounds Weird but it works

I had same problem. You cannot call AndroidSchedulers with RxJava3. I think this is a bug. They need to fix it.
You need to add they on your dependencies of gradle:
//RxAndroid
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'

def rxJavaVersion = '2.1.1'
//Add to dependencies the following libraries
dependencies {
implementation "io.reactivex.rxjava2:rxandroid:$rxJavaVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
}

Now you can use RX 3 by adding the below dependency
implementation "io.reactivex.rxjava3:rxandroid:$version"
get the version from this link : https://github.com/ReactiveX/RxAndroid

Related

'android.useAndroidX' property is not enabled

okay, so this is the first time I'm working with SDKs,
I'm using the zoom SDK from here https://marketplace.zoom.us/docs/sdk/native-sdks/android/getting-started
and I'm trying to run the sample APK as mentioned in the documentation and it returns the error
"This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled"
https://i.stack.imgur.com/taM6c.png
and I have searched and found a solution to this where I turn the android project into an androidX project by using the following in the Gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
HERE IS WHERE THE ISSUE LIES
the SDK doesn't have any Gradle.properties file, and hence i don't know where to insert the above code
for now, I have inserted the above code in the following files: https://i.stack.imgur.com/Ktj4j.png
and yet the issue still exists, can I please get some help on this? thanks in advance!
Added this into gradle.properties files solve my problem.
android.useAndroidX=true
android.enableJetifier=true
Create new project that time no need to convert AndroidX. Add this in gradle, hopefully working.
Application level
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation files('libs/commonlib.aar')
implementation files('libs/mobilertc.aar')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.3.0-alpha02'
}
Project Level
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
The gradle.properties file's name should be lowercase and you can place it multiple location, see the official documentation here.
In this case, I guess you have to put it to your project root directory.
Added this into gradle.properties files
android.useAndroidX=true
android.enableJetifier=true
if you did not find this file write in the terminal flutter create . to recreate your project after that you are going to see gradle.properties file with the same properties that I mintioned before.

java.lang.NoSuchMethodError: No virtual method toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super classe

I'm using retrofit (2.7.2) and OkHttp version (4.4.0) in an Android project and I'm facing a crash on a request.
Dependencies:
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.2")
implementation 'com.squareup.moshi:moshi:1.9.2'
implementation 'com.squareup.retrofit2:retrofit:2.7.2'
implementation 'com.squareup.retrofit2:converter-moshi:2.7.2'
implementation("com.squareup.okhttp3:okhttp:4.4.0")
implementation("com.squareup.okhttp3:okhttp-tls:4.4.0")
implementation "com.squareup.okhttp3:logging-interceptor:4.4.0"
Crash:
java.lang.NoSuchMethodError: No virtual method
toString(Z)Ljava/lang/String; in class Lokhttp3/Cookie; or its super
classes (declaration of 'okhttp3.Cookie' appears in
/data/app/com.package-1/base.apk:classes3.dex)
at okhttp3.JavaNetCookieJar.saveFromResponse(JavaNetCookieJar.java:45)
at com.facebook.react.modules.network.ReactCookieJarContainer.saveFromResponse(ReactCookieJarContainer.java:36)
at okhttp3.internal.http.HttpHeaders.receiveHeaders(HttpHeaders.kt:207)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:85)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
You're pulling in an old version of okhttp-urlconnection, and it is incompatible with the current version of the OkHttp core library.
You can fix by adding an explicit dependency on okhttp-urlconnection:
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.4.1")
Or by adopting OkHttp’s new BOM for versions:
dependencies {
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.4.1"))
implementation("com.squareup.okhttp3:okhttp") // No version!
implementation("com.squareup.okhttp3:okhttp-urlconnection") // No version!
}
I used following okhttp3 versions and woked fine for me...
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
implementation 'com.squareup.okhttp3:logging-interceptor:4.4.1'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.4.1'
Please make sure that build.gradle file hase a same version for belowed dependencies and if you have this below version and getting above error than change version for them and your issue has been solved.:
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
Change the version with below :
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
I wanted to add that this error was showing up after ejecting from Expo in React Native.
The solution was to go to add the following to android/app/build.gradle (inside dependencies):
compile "com.squareup.okhttp3:okhttp:4.2.1"
compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
They would look like this:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
// you can insert it here
compile "com.squareup.okhttp3:okhttp:4.2.1"
compile "com.squareup.okhttp3:logging-interceptor:4.2.1"
compile "com.squareup.okhttp3:okhttp-urlconnection:4.2.1"
}
(Note: Check the versions in the Maven Repository

Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar

I got errors
Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar (com.google.guava:guava:26.0-android) and jetified-listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)
Go to the documentation to learn how to Fix dependency resolution errors.
After update
classpath 'com.android.tools.build:gradle:3.5.3'
to
classpath 'com.android.tools.build:gradle:3.6.1'
and gradle 5.4.1 to 5.6.4
Problem solved when downgrade
implementation 'com.google.firebase:firebase-firestore:21.4.1'
to
implementation 'com.google.firebase:firebase-firestore:21.4.0'
Is this a bug of firebase/firestore?
After updating Firebase, I encountered this issue as well.
Fix the conflict by adding the following package to your build.gradle
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
I am using latest version of firebase firestore i.e.
implementation 'com.google.firebase:firebase-firestore:21.4.3'
and adding this line worked for me:
implementation 'com.google.guava:guava:27.0.1-android'
I think part of the issue is that Android Studio (or maybe the Gradle Plugin, however that is handled) is recommending to update the version of the Firestore dependency to 21.4.1 (likely depends on the order of repositories in your build.gradle - not sure on that). And yes, it seems that 21.4.1 causes the issue.
So yeah, just ignore that recommendation and leave it at 21.4.0. Also...
Firebase Docs show 21.4.0 as the correct version.
MVN Repository shows 21.4.1 as the latest release.
Google Maven Repo also lists 21.4.1 as the latest release.
For the one who does not find a solution, this helped me.
Add this dependency in your app/build.gradle file.
implementation "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"
Source:
https://github.com/firebase/firebase-android-sdk/issues/1320#issuecomment-601159166
The latest version of firestore is:
implementation 'com.google.firebase:firebase-firestore:21.4.0'
If you have not added firestore as a dependency and still getting this error add below dependency to gradle
implementation group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
implementation 'com.google.guava:guava:28.2-android'
add this to your gradle and you're good to go
I just added
implementation group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
into my dependencies.

Error [duplicateplatformclasses] while building app in release mode

After updating Android Studio and updated GDAA to Google Drive REST API as GDAA is deprecated, but now I can not build my app in release mode which had no issues before. Here is the complete error message:
org.gradle.api.GradleException: Lint found fatal errors while assembling a release target. To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
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
}
}
And in the lint-results-release-fatal.xml file I get these messages:
'commons-logging' defines classes that conflict with classes now
provided by Android. Solutions include finding newer versions or
alternative libraries that don't have the same problem (for example,
for httpclient use HttpUrlConnection or okhttp instead), or
repackaging the library using something like jarjar.
'httpclient' defines classes that conflict with classes now provided
by Android. Solutions include finding newer versions or alternative
libraries that don't have the same problem (for example, for
httpclient use HttpUrlConnection or okhttp instead), or repackaging
the library using something like jarjar.
Here is my gradle dependencies:
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-core-utils:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:17.1.3'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
implementation('com.google.api-client:google-api-client-android:1.26.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
exclude group: 'org.apache.httpcomponents'
}
}
I tried this and this but no luck.
After trying all other solutions with no luck, I suddenly discovered that this version of Android Studio 3.3.2 does not detect libraries which are out of date and found that the library causing the problem was this:
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
As this is the suspected library from this question.
I simply updated this library to the latest version which is this at the moment:
implementation 'com.google.http-client:google-http-client-gson:1.28.0'
And the problem was solved.
I post this question and give answer just because I could not find the right answer and for those struggling with the same problem could be the right solution.

Exclude Package From Gradle Dependency

I'm experiencing an issue where multiple versions of the same class are showing up in my classpath. The class in question is javax.ws.rs.core.UriBuilder. The version I want to use is brought in by javax.ws.rs:javax.ws.rs-api:2.0.1. However, we also use the Jira rest client library which has a dependency on the older version of jersey (com.sun.jersey:jersey-core) which has included the java.ws packages bundled in it's jar.
Here is an example snippet from the build file:
dependencies {
compile 'com.atlassian.jira:jira-rest-java-client-core:2.0.0-m31'
compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
compile 'org.glassfish.jersey.core:jersey-client:2.17'
}
I can't remove com.sun.jersey:jersey-core as it uses different package name from the new version and would cause class def not found exceptions in the Jira client.
As far as I can tell, my options at this point are:
Revert to using Jersey 1.x and it's implementation of jsr311
Somehow have gradle exclude the javax.ws package from the old jersey client.
I'd like to keep using the newer version of jersey so #2 would be my ideal solution but I'm not sure if it's even possible. Does anyone know how to go about this? If that's not possible, I'm open to other suggestions.
You can exclude an transitive dependency module like this:
compile ('org.glassfish.jersey.core:jersey-client:2.17') {
exclude group: 'javax.ws.rs'
exclude module: 'javax.ws.rs-api'
}
ref: 50.4.7 here
I found out that com.sun.jersey:jersey-core:1.19 doesn't bundle the javax.ws.rs class files and instead lists them as a compile-time dependency. Adding this snippet to my build.gradle fixed the issue.
configurations.all {
resolutionStrategy {
// For a version that doesn't package javax.ws
force 'com.sun.jersey:jersey-core:1.19'
}
}
exclude the group and module as below.
Ex :
implementation('org.apache.httpcomponents:httpclient:4.5.13') {
exclude group: 'commons-codec', module: 'commons-codec'
}

Categories

Resources