I got a warning, but I don't know what to do.
Builder.setMaxResolution can only be called from within the same library group (referenced groupId=androidx.camera from groupId=sample)
Related
i have a main app named App_1 then a custom library Lib_1
Project View
how can i callback or run a method from the app_1 Main Activity when i clicked a button in lib_1? tia.
From what you have described, there is one main concept you need to learn first:
the library is the dependency of the app
To set it up, add library to in build.gradle file of your app (find it in your app folder) in dependencies section - it may look like that:
dependencies {
implementation project( ':library' )
//other dependencies below (order doesn't really matter)
(...)
}
Then there are a few things which needs a little bit more explanation - what do you mean by "button from library"? Have you created a custom button (check official documentation to check what it is)? Or do you mean that clicking a button in your app will run a function from library?
Create an interface in lib_1, then in app_1 create implementation of that interface and pass it to lib_1, whenever a button in lib_1 is clicked call a method form that interface.
Your app_1 can access lib_1's code(if you have setup the right relationship for the 2 modules), so you can define a callback method in your lib_1.
e.g. public void onLibButtonClick(OnClickListener listenerFromApp). When you click the button on lib_1, you can call listenerFromApp.onClick(View) to transfer click event.
You can also use LocalBroadcastManager related api to transfer event between modules(in one application). This should be reasonable sometime.
I'm trying to bind an android SDK for voice chat (zoom sdk).
They have two .aar files (zoomcoomonlib.aar and zoomsdk.aar)
I know I have to create separate binding project for each .aar and then reference them.
While binding zoomsdk.aar I'm getting the below error
The type `Com.Zipow.Videobox.Onedrive.ErrorEventArgs' already contains a definition for `P0' (CS0102) (B14)
In the .aar file I navigated to the package com.zipow.videobox.onedrive; to the interface IODFoldLoaderListener
And below are the contents of it
So it seems parameter String var1 of method onError is causing the issue.
And xamarin studio generated obj/debug/api.xml confirms it (below screenshot) that onError will have first parameter named p0:
So in this scenario I change the metadata.xml to give this parameter a meaningful name.
Like below screenshot:
But even after doing that I am getting same error. That error didn't resolve.
Moreover now if I see the obj/debug/api/.xml file I see the contents for the class IODFoldLoaderListener remains the same.
So changing the metadata.xml has no effect it seems.
Your definition needs to be changed quite a bit. Here is an example that solves the same problem:
<attr path="/api/package[#name='com.emarsys.mobileengage.inbox']/interface[#name='ResetBadgeCountResultListener']/method[#name='onError' and count(parameter)=1 and parameter[1][#type='java.lang.Exception']]" name="argsType">ResetBadgeCountResultListenerOnErrorArgs</attr>
Please note the /interface and argsType items here as your initial definition is incorrect. You would then change the parameters to strings instead of java.lang.Exception from my example.
I have 2 NDK libraries (.so files ) in my android project and there is a method in the first library that is also called (used) in the first library and I want the second library to override the called (used) method found in the first library. Is it possible to just have the same name and parameters and load the second library after the first like
System.load(first);
System.load(second);
Will this override the first method or do I have to do something else? If so, please specify.
Thanks in advance for your time.
Once a symbol has been resolved (by System.load) it will not be changed. The definition loaded from first will be used.
I'm interested in understanding how a dex file (classesN.dex) references methods in another classesN.dex file.
In a standard dex layout, you have all of the class, method, type, etc... definitions in different tables. Things that are dynamically linked (such as those from the Android framework) simply have their method prototypes included, but no code data. Is it true that in a multidex setup, each classesN.dex contains a set of class implementations, and methods that are implemented in other dex files are merely included in the same way as dynamically linked calls?
In other words, if classes.dex needs to reference a method classes1.dex, it will include that method as a prototype within classes.dex, and then include its implementation in classes1.dex?
I ended up solving this question: it turns out that in a multidex layout the relevant method and class definitions are included in each dex file. For example, if classes.dex references methods foo() from classes1.dex, it will include a relevant entry in the method table for foo() within classes.dex's method table. But the implementation of foo() will appear in classes1.dex. This works because foo() is usually something like the entry of a library used by the app. The entry points of that library can be used without all of the methods called by foo. In classes.dex, foo will be defined without a corresponding code item, just as if it were a part of the dynamically linked Android standard library.
I made a c++ main aplication that loads a so library also made by me.
Both sources shares a common header (TestFlags.h).
Inside TestFlags.h I have an class and a pointer declaration of it which is intended to be global to the whole application, that is define a instance in the main app and use it inside a library function.
class TestFlags {
public:
TestFlags() : behaviour(1)
{}
int behaviour;
};
extern __attribute__ ((visibility("default"))) TestFlags * gpTestFlags;
then a sequence of execution steps followed to reach the named goal are:
main application creates a new instance of TestFlags ---> gpTestFlags = new TestFlags();
main application load the library ---> dlopen(library.so, RTLD_LAZY|RTLD_GLOBAL)
invoke a function that resides inside the library which uses previous instance declared ---> gpTestFlags->behaviour = 2;
Received a SIGSEGV: Segmentation fault because gpTestFlags is NULL
It seems that inside the library gpTestFlags instance is not seen for some reason.
Same thing also happens with other static class I have, values which are configured on the main application not seen inside the library.
As far I can research it seems that the library manages a totally different memory space for those declarations like if it was duplicated.
This is the expected way dlopen() would work.
The two modules have independent global symbols called gpTestFlags. If you try to link them together, the linker would scream about duplicates.
You can declare the pointer in library as weak, or you can use dlsym() to resolve the linkage programmatically.