Lambda method reference to Function<F,T> throws NoClassDefFoundError - android

I am using Retrolambda for Android with Java 8 and I ran into a runtime fatal exception when saving a lambda method reference into Android's Function<F,T> interface throwing a java.lang.NoClassDefFoundError.
After wasting some time checking my own code, I actually realized that this interface is using javax.annotation.Nullable which has been moved to another dependency, causing it to not display any compilation errors, but throwing the mentioned exception at runtime.

My solution was just to create my own copy of the Function interface with the right Nullable import.

Related

Issues running obfuscated DEX modules - AbstractMethodError

I'm developing an Android application based on a main APK installed on the mobile device, and some android modules that are compiled to a .dex file. These files are loaded at runtime by the main application and the classes inside the .dex files are instantiated via Dynamic Dex Loading.
I'm facing some issues related to proguard, as even if I use the #Keep annotation on exposed methods in the modules and the main APK and I tell to proguard to keep interfaces methods, when I call one of the methods implemented in a module i get:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.myproject, PID: 13893
java.lang.AbstractMethodError: abstract method "z.a com.android.myproject.MyClass.mymethod()"
at com.android.myproject.MainService.H(:784)
at com.android.myproject.MainService.M(:258)
at com.android.myproject.MainService.a0(:198)
at com.android.myproject.MainService.U(:148)
at com.android.myproject.MainService.C(:133)
at com.android.myproject.MainService.onServiceConnected(:90)...
If i try to debug, and i place a breakpoint right on the method call, using the "Evaluate Expression" tool in Android Studio I'm able to call the method with success, but if I let it execute on its own it crashes with the previous exception.
Can someone help me please? Thank you very much

Android Studio C++ inline compiler doesn't understand smart pointer upcasting

My Android Studio inline compiler shows me an error when passing an unique_ptr of a derived class to a function expecting an unique_ptr of a parent class. But the code compiles as I was expecting.
The error message from the code snippet above:
Parameter type mismatch: Class 'std::unique_ptr<B>' is not compatible with class 'std::unique_ptr<A>'
I guess is this a bug, related to Android Studio ? I was wondering if there was an options for this error checker, couldn't find anything
EDIT: Note that this code compiles with no errors from the compiler (the error I quoted is from the Android Studio's real time error checker). You can check the code here: https://ideone.com/xlUsKs

C++ Exception in 'nativeRequireModuleConfig', What is Landroid?

C++ Exception in 'nativeRequireModuleConfig':
java.lang.NoSuchMethodError: No static method getNoBackupFilesDir(Landroid/content/Context;)Ljava/io/File; in class Lcom/google/android/gms/common/util/zzx; or its super classes (decleration of 'com.google.android.gms.common.util.zzx' appears in /data/app/com.kotac-2/base.apk)
To avoid this error you can modify the project into a working state, for example if your project is on git and versioned, reset it into an older commit which it is working well.
I was able to get over this issue by getting the app working however and updating the code again.

#hide class not found

The ContentResolver class has a hidden method called getSyncStatus(...).
To make it public visible I try to add a wrapper method in ContentResolverCompat from support v4 lib.
This works so far in Eclipse but when I call make it fails with the following errors:
ERROR: /development/android/frameworks/support/v4/java/android/support/v4/content/SyncStatusInfo.java:91: android.content.SyncStatusInfo cannot be resolved to a type
ERROR: /development/android/frameworks/support/v4/java/android/support/v4/content/ContentResolverCompat.java:19: The import android.accounts cannot be resolved
ERROR: /development/android/frameworks/support/v4/java/android/support/v4/content/ContentResolverCompat.java:137: Account cannot be resolved to a type
ERROR: /development/android/frameworks/support/v4/java/android/support/v4/content/ContentResolverCompat.java:138: android.content.SyncStatusInfo cannot be resolved to a type
ERROR: /development/android/frameworks/support/v4/java/android/support/v4/content/ContentResolverCompat.java:146: Account cannot be resolved to a type
ERROR: /development/android/frameworks/support/v4/java/android/support/v4/content/ContentResolverCompat.java:148: android.content.SyncStatusInfo cannot be resolved to a type
My thought was that #hide is a documentation thing only and I can access it from within AOSP classes. But why I can't build my changes when I want to access hidden classes / methods?
Note: I don't want to build an Android app, I want to change / build the Android source code itself.
Edit: This isn't a duplicate of #hide class not found because #hide means that it is removed from JavaDoc but it is still accessible from Android source code itself.

The type 'System.ComponentModel.INotifyPropertyChanged' is defined in an assembly that is not referenced

I get the following errors for the same file: LocationToLatLngValueConverter.cs
Reference:
https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/tree/master/N-41-Maps
The type `System.ComponentModel.INotifyPropertyChanged` is defined in an assembly that is not referenced. You must add a reference to assembly `System.ObjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a`.
`D:\MVVMCross\MVVMCrossApps\MAP\Map\Map.Droid\Views\LocationToLatLngValueConverter.cs`
`Map.Droid.Views.LocationToLatLngValueConverter.Convert(Map.Core.ViewModels.Location, System.Type, object, System.Globalization.CultureInfo)': no suitable method found to override`
`D:\MVVMCross\MVVMCrossApps\MAP\Map\Map.Droid\Views\LocationToLatLngValueConverter.cs`
`Map.Droid.Views.LocationToLatLngValueConverter.ConvertBack(Android.Gms.Maps.Model.LatLng, System.Type, object, System.Globalization.CultureInfo)': no suitable method found to override D:\MVVMCross\MVVMCrossApps\MAP\Map\Map.Droid\Views\LocationToLatLngValueConverter.cs`
According to the demo everything of the application is provided.
I am still unable to get rid of the problems.
I just had this error in a Unit Test project referencing a PCL.
It was complaining that I hadn't referenced System.Object. The problem seemed to have been due to me referencing System.Runtime - Resharper seems to want to add it.
Removing the reference to System.Runtime fixed the issue for me.
I have looked into the code, and there is actually nothing wrong with that converter. The reason it is failing is that you have references to System.ObjectModel and System.Runtime that point to wrong versions of those classes. You can see that because there is a "red X" behind their names in Xamarin studio.
Also very specific versions of .net and other packages are referenced, which is not advised for normal purposes.
I managed to solve this issue by removing all using statements at the beginning of the file and then adding them back one by one.
Resharper eventually suggested me to reference System.ObjectModel

Categories

Resources