I am using retrofit 2.9.0 in my project which still depends on okhttp 3.14.9
https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit/2.9.0
The library I have to include uses okhttp version 4.9.1.
Gradle always uses the highest version of okhttp which breaks my project.
If I force gradle to use okhttp version 3.14.9 like below it breaks the library.
configurations.all {
resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.19'
}
Is it possible to use both versions of the library in one project?
Also some of the errors are kind of wired.
BuildOutput shows for example the following error:
Using 'uri(): URI' is an error. moved to toUri()
But AndroidStudio does not highlight it.
Screenshoot of the error
mAuthenticator.getApiClient().adapterBuilder.build().baseUrl().uri().toString()
Some more errors that appeared
Using 'uri(): URI' is an error. moved to toUri()
Using 'method(): String' is an error. moved to val
Using 'body(): RequestBody?' is an error. moved to val
Using 'headers(): Headers' is an error. moved to val
Using 'cacheControl(): CacheControl' is an error. moved to val
Using 'body(): ResponseBody?' is an error. moved to val
Using 'code(): Int' is an error. moved to val
Using 'code(): Int' is an error. moved to val
Using 'parse(String): MediaType?' is an error. moved to extension function
Using 'parse(String): MediaType?' is an error. moved to extension function
Using 'request(): Request' is an error. moved to val
Using 'method(): String' is an error. moved to val
Using 'body(): RequestBody?' is an error. moved to val
Using 'headers(): Headers' is an error. moved to val
Using 'cacheControl(): CacheControl' is an error. moved to val
Using 'body(): ResponseBody?' is an error. moved to val
Using 'code(): Int' is an error. moved to val
Using 'code(): Int' is an error. moved to val
Using 'parse(String): MediaType?' is an error. moved to extension function
Using 'parse(String): MediaType?' is an error. moved to extension function
Using 'request(): Request' is an error. moved to val
Using 'networkResponse(): Response?' is an error. moved to val
Using 'request(): Request' is an error. moved to val
Using 'headers(): Headers' is an error. moved to val
Using 'size(): Int' is an error. moved to val
Using 'networkResponse(): Response?' is an error. moved to val
Using 'request(): Request' is an error. moved to val
Using 'headers(): Headers' is an error. moved to val
Using 'size(): Int' is an error. moved to val
Using 'request(): Request' is an error. moved to val
Using 'headers(): Headers' is an error. moved to val
Using 'size(): Int' is an error. moved to val
Using 'request(): Request' is an error. moved to val
https://square.github.io/okhttp/upgrading_to_okhttp_4/
With a few small exceptions (below), OkHttp 4.x is both binary- and Java source-compatible with OkHttp 3.x. You can use an OkHttp 4.x .jar file with applications or libraries built for OkHttp 3.x.
OkHttp is not source-compatible for Kotlin callers, but upgrading should be automatic thanks to Kotlin’s powerful deprecation features. Most developers should be able to use IntelliJ’s Code Cleanup for a safe and fast upgrade.
Ideally you should just upgrade your source code to fix these issues using the automatic fixes suggested by Android Studio or Intellij.
Related
I am reading a dataset and printing schema. It worked.
When I tried to find the dataset count, I am getting ClassCastException
as
java.lang.ClassCastException: org.apache.hadoop.fs.FsUrlConnection cannot be cast to java.net.HttpURLConnection
The same code works on Mac OS though.
The exception is thrown in cloud vm running Linux_4.14.48
Please let me know if there is a fix. There is topic discuss about the fix
in Hadoop-14598 but that was for older version and I think Spark 2.3.2 might already has that patch.
There isn't much line of code and pasting it below though. The error happens when df.count() is called
val df = spark.read.format("own.format.dataset").load(sys.env("DATASET_ID"))
val count = df.count()
I just struggled with this exact issue. I was able to fix it by overriding the hadoop-client version (spark-core uses hadoop-client 2.6.5). I added the following to my build.sbt:
dependencyOverrides += "org.apache.hadoop" % "hadoop-client" % "2.9.2"
The issue is linked to hadoop-client 2.7, which is not linked to a specific spark version, so as suggested by #marteljn, you should bump your hadoop version.
If you cannot bump your hadoop client, then you can use this workaround :
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory(sc.hadoopConfiguration()) {
#Override
public URLStreamHandler createURLStreamHandler(String protocol) {
if (protocol.equals("http") || protocol.equals("https")) {
return null;
}
return super.createURLStreamHandler(protocol);
}
});
As suggested from https://issues.apache.org/jira/browse/SPARK-25694
I had the same issue and as #Gregoire indicated it, it was linked to a bug in Spark.
But I did not add a fix in my code, just updated Spark to version 2.4.8 (bug fixed from version 2.4.6 and 3.0.0)
Moreover, the fix is not self activate, you need to set this property as indicated in this pull request :
spark.sql.defaultUrlStreamHandlerFactory.enabled=false
It worked like a charm for me.
This issue was resolved after updating spark version to 2.3.0 recommend to use higher version to get this issue resolved
Use this after the Spark Context.
SparkConf sparkConf = new SparkConf().setMaster("local").setAppName("Application Name");
JavaSparkContext sparkContext = new JavaSparkContext(sparkConf);
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory(sparkContext.hadoopConfiguration()) {
#Override
public URLStreamHandler createURLStreamHandler(String protocol) {
if (protocol.equals("http") || protocol.equals("https")) {
return null;
}
return super.createURLStreamHandler(protocol);
}
});
I was facing the MissingMethodExeption while using the reflection method in Xamarin.iOS. My code works fine when Linker Behavior is set to Don't Link. But i am getting the above exception when Linker behavior is set to Link SDK assemblies. I have tried the workaround to set the --linkskip=System.Core but exception raised. Can you please let me know if you have any answer for this problem.
I am getting the error while performing the following operation. Activator.CreateInstance(resultType) as ScriptObject. Here resultType is a Type and ScriptObject is a class which perform some operations for me.
A quick and dirty way to avoid some methods/types to be linked out is to reference them in unused code:
if (false) {
var a = new TypeToPreserve();
a.MethodToPreserve();
}
We have been building our application using groovy 2.3.6. Now because of some platform level issues we are advised to downgrade our groovy version to 2.2.1. I am facing no. of issues regarding this downgrade.
groovy is not able to infer the type of it variable in ver 2.2.1 so if i have code something like this
names.any { sliceName.endsWith(it) }
it gives me exception
[Static type checking] - Cannot find matching method java.lang.String#endsWith(java.lang.Object)
Secondly all the default method that i had used in collections no longer seem to exist
positions.any { it.primary }
groovy is unable to find the any method on list.
One way would be turn off static type checking, which will expose the code to a lot more runtime errors.
Is there any way to resolve these errors, without turning off static type checking. Also are these features only added in groovy 2.3.6 like default groovy methods and type inference for it variable
If you go back to an old version, old bugs will bite you.
Try giving the static compiler more of a hint
names.any { String it -> sliceName.endsWith(it) }
Following this post http://obviam.net/index.php/libgdx-and-kotlin/ I
created a project, and edited using Atom. It compiles, and runs on an android device. I want to convert to AndroidStudio for better tooling.
I'm using AndroidStudio 1.5.1, and it says I have the latest version of the kotlin plugin. I created a new project using the LibGDX setup program, imported into AdroidStudio, converted the main class to kotlin, everything works. Then I pasted in my existing my code, and when I build, this line:
val bullets:MutableList<NewBullet> = linkedListOf()
gets this error:
Error:(19, 42) Unresolved reference: linkedListOf
When I select Tools -> Kotlin -> Configure it says 'All modules with Kotlin files are configured'.
I've also tried importing the existing project into AndroidStudio, and the result is the same issue.
As said in the change log of Kotlin 1.0 RC, linkedListOf has been deprecated and is not available now. The article you referenced uses Kotlin 1.0 Beta, which is older.
To create a LinkedList<T> from varargs, you can pass a listOf(...) to the constructor:
val bullets: MutableList<SomeType> = LinkedList(listOf(item1, item2))
or write your own linkedListOf:
fun <T> linkedListOf(vararg items: T) = LinkedList<T>().apply {
for (i in items) { add(i) }
}
With a skeleton project with FirstView from HotTuna package, and with Build linker behavior set to "Link all assemblies", I get the following error:
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
Using NuGet package v3.1.1 for all MvvmCross (4 packages)
LinkerPleaseInclude file does have the line
[MonoTouch.Foundation.Preserve(AllMembers = true)]
Using the latest stable build:
On PC:
Xamarin for VS 1.12.278
Xamarin.iOS 1.12.278
Mac:
Xamarin.iOS 7.2.2.2
Of course with Linker behavior of SDK only, it runs fine. Any suggestions anyone?
Solved; So, with the basic project, there were three consecutive errors in the following order:
System.MissingMethodException: Default constructor not found for type Cirrious.CrossCore.IoC.MvxPropertyInjector
can be resolved either by --linkskip=Cirrious.Core (ugly), or by including the following in LinkerPleaseInclude.cs
public void Include(MvxPropertyInjector injector){
injector = new MvxPropertyInjector ();
}
Next error is:
Cirrious.CrossCore.Exceptions.MvxException: Failed to construct and initialize ViewModel for type {0} from locator MvxDefaultViewModelLocator - check MvxTrace for more information
This one is difficult; Simple fix is to ofcourse to do a --linkskip=portableLibrary, or to crate an instance of the ViewModel somewhere (perhaps in LinkerPleaseInclude.cs); problem with the second approach at-least in my case is, most of my VM doesn't have a parameter less constructor, and obviously using IOC in this case wouldn't help.
Final Error:
System.ArgumentNullException: missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo
Either use --linkskip=System (ugly), or add the following to LinkerPleaseInclude.cs
public void Include(INotifyPropertyChanged changed)
{
changed.PropertyChanged += (sender, e) => {
var test = e.PropertyName;
};
}
This was enough for my basic project to run with LinkAllAssemblies, Using LLVM optimizer, and Use SGen collector.
Hope this will help anyone looking for a solution.
I hit this when my XCode was out of sync with the latest Xamarin on my Mac. Upgrading XCode to the latest resolved the problem.