There are 3rd party libraries that I use in my own library.
When I try to output as AAR and use it, I get the following error:
[![The following classes could not be found:
- androidx.emoji2.R
- androidx.camera.view.PreviewView (Fix Build Path, Edit XML, Create Class)][1]][1]
Related
I'm trying to use OpenCv 4 on Xamarin.Android by Java Binding Template. These are the steps that i've done:
0) I've compiled opencv binaries through cmake and mingw64 to get .jar and .a
I've put the .jar and the static libraries (.a) in Jars forlder of Xamarin Java Binding Template and i've compiled the template.
1.a) .jar Build Action is EmbeddedJar
1.b) libs Build Action is EmbeddedNativeLibrary
I've added a reference to that template in my Xamarin.Android project: the opencv methods were recognized correctly!
But, when i try to execute:
Mat Source = Imgcodecs.Imread(ImagePath, Imgcodecs.ImreadGrayscale);
i get an error:
Java.Lang.UnsatisfiedLinkError: 'No implementation found for long org.opencv.imgcodecs.Imgcodecs.imread_0(java.lang.String, int) (tried Java_org_opencv_imgcodecs_Imgcodecs_imread_10 and Java_org_opencv_imgcodecs_Imgcodecs_imread_10__Ljava_lang_String_2I)'
I think that there could be a missmatch of method name, maybe due to a wrong java parsing.
I've also tried to use shared libries (.so) by loading them through JavaSystem.LoadLibrary("LibraryNameWithoutInitialLib"), but i have the same error :/
Do you know why?
You cannot link static libraries with Xamarin.Android as the Xamarin/Mono NDK-based runtime is a static main entry executable and does not dynamically get built per project. If you do not need to use a .jar/.aar high-level wrapper, then you will need to use runtime shared libraries and define DllImportAttribute entries for the exported functions that you need to call.
Xamarin.Android supports the use of native libraries via the standard PInvoke mechanism.
Using Native Libraries
Use C/C++ libraries with Xamarin
Note: There are numerous OpenCV C# wrappers / DllImport files in open source ( i.e. a github search away 😁)
Note: If you are using a 3rd-party .jar/.aar , make sure that they are using OpenCV shared libraries and thus not requiring a gradle script to link them into an NDK-based Android app.
I'm working on an Android project that extends chromium project.
I want to add a third party library (www.intercom.com). The problem is that the intercom documentation is just for gradle projects, and chromium is not using gradle so I have to add the library manual.
I've tried to copy all the .aar and .jar files in third_party/intercom and create a gn file, but I get an error:
Class "kotlin/coroutines/Continuation" not found on any classpath. Used by class "io/intercom/retrofit2/RequestFactory$Builder"
I've include org_jetbrains_kotlin_kotlin_stdlib_java, but still get the same error.
Questions:
Should I include anything else to get rid of this error?
Is there any automated tool/script, that generates a gn file for a library?
Thanks!
I'm using joint compilation (having .java files in the groovy src directory) so that java and groovy can reference each other.
However, when using google's data-binding lib, the compiler fails to find the classes referenced in the layout.xml file.
I always get a 'Cannot resolve type for user'
Is there a workaround this ?
Databinding requires annotation processing that Google hides in Android Studio. See this example of how to get it setup for a groovy application https://github.com/pieces029/groovy-android-data-binding
I am using a library project in my app.It has custom xml attributes.Now i want to include this library project as a jar.When i include it as jar,in xml am not able to use the custom attributes.It throws an error : "No resource found in the given package".I tried including custom namespace : "http://schemas.android.com/apk/res-auto".But it still throws the same error.I also tried adding the library project package name instead of "res-auto" in the namespace.But still it did not work.
Can you please tell me how to solve the above error.
I am using a library project in my app.It has custom xml attributes. Now i want to include this library project as a jar
That is not possible. Your Android library project needs resources; a JAR does not contain Android resources.
Can you please tell me how to solve the above error.
Do not use the custom attributes, and pray that the library project does not need any other resources.
Or, stick with your original current Android library project setup.
Or, if you are using Android Studio and/or Gradle for Android, you could package the library project as an AAR and use that from your app.
I am using my own custom java library to read response from the server by hitting urls. I have written a standalone java program to check whether the library is working or not and I am getting the positive responses for all the urls. But when I am trying to use the same java library with my android code it is throwing me an exception.
Exception:
Could not find class 'org.apache.http.impl.conn.PoolingClientConnectionManager', referenced from method com.nq.client.comm.HttpClientHelper.<init>.
java.lang.NoClassDefFoundError: org.apache.http.impl.conn.PoolingClientConnectionManager
You probably want to export the library in your Java Build Path:
See Android - Unable to instantiate activity - Class not found exception after upgrading to ADT 22
EDIT
In your custom library project, make sure you are exporting in the Java Build path the Apache library (org.apache.http.impl.conn.PoolingClientConnectionManager). The error message is telling you that there is a reference to this library, but it cannot be found. This means that it's not being packaged with the library that is referencing it. So, go to your custom library project and make sure that the Apache library is getting exported. If it is, raise it up in the list in order of export.