using android libraries for desktop, compose desktop - kotlin

In the example for the compose-desktop it got
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
fun main() = application {
var isOpen by remember { mutableStateOf(true) }
var isAskingToClose by remember { mutableStateOf(false) }
it has androidx import.
Would it be possible to run other android libraries like for example Exoplayer and Google Accompanist to the compose desktop that can be used for other desktop environments?

No, it's just a name.
Compose was originally created by the Android team, and later they collaborated with JetBrains to create a multiplatform version. But the Android team decided not to change the name of the package (for example, by removing the prefix androix), and JetBrains had to use the same package name for compatibility.
You cannot run any Android-specific libraries - an application created with Compose for Desktop runs as a normal JVM application.
Depending on how much these libraries depend on Android primitives, it may be easier or harder to port them to Desktop. For example, Coil is literally built around Android framework classes, such as Bitmap, BitmapFactory, ImageDecoder, so porting it would be very difficult.
Many of Google Accompanist libraries only makes sense on Android platform. If you need to use some of them on Desktop, you can try copy-pasting the source code to see if it can be run on Desktop.

Related

Conditionally import Capacitor plugins with Vite?

I'm creating a Vue-app that runs in the browser, but that can also be packed into a Capacitor app. I use Vite as bundler.
I use the #capacitor/camera plugin, which needs the following import in a component that uses the camera:
import { Camera, CameraResultType } from '#capacitor/camera';
The project is a Quasar framework app, which uses a separate src-capacitor folder for the Capacitor setup. Since the camera plugin is only installed in src-capacitor (not in package.json in the root of the project), this gives an error when running the app in a browser.
Is there any way to make the import conditional?

Video Calling in Expo React Native Application

I am building a React Native Application using Expo and I want to integrate a 1:1 video calling functionality in the app.
From what I have researched so far on the topic is that I can use SDKs of various libraries like Twilio, Videosdk, VoxImplant etc to implement that feature or I have to use WebRtc in native project alongwith some mechanism to create rooms using socket.io and node and then join users in that room (not completely sure about it but something like this)
But both of these solutions require me to make changes in native files which are not present in expo app by default for which I think I have to run expo run:android and then make require changes in files (correct me if I am wrong)
Although on web I think its relatively easy to implement video calling using vanilla js or react js.
My question is if I implement a webpage that has video calling function and try to open it in webview in my expo react native app will the functionality work on app or not? has someone tried this before.
As I was exploring options I came BigBlueButton APIs and another question on Stackoverflow that is using Webview to connect to BigBlueButton APIs. Can I use this logic to implement something in expo app without ejecting or using any sdks? Will it work
What would be the best way to implement video calling in my expo app
Thanks
Utilizing Expo, you are essentially using 'React Native for Web', and with the new functionality of Expo config-plugins, almost all packages for React Native with auto-linking can be made to work with your Expo app, or more-or-less can have Config Plugins created for them.
For your case, good news for you, you can make it all work on Expo managed workflow, just utilize expo-dev-client and the following library:
react-native-webrtc
There's an Expo config plugin for this package. So now all you have to do is just utilize the Web-based functionality of WebRTC, such as calling:
navigator.mediaDevices.getUserMedia()..
navigator.mediaDevices.enumerateDevices()..
navigator.*
And ensure it works properly on Web. Then, just make a platform hook at your App.js / First loaded module / before having these WebRTC based functionalities calling the aforementioned library's initializer. e.g:
import React, { useEffect } from "react";
import { Platform } from "react-native";
import { registerGlobals } from "react-native-webrtc";
...
Platform.OS !== "web" && useEffect(() => {
registerGlobals();
}, []);
...
One more thing you'd have to do is that for Web, have the <video> element and for native apps, resolve it to <RTCView>, so essentially you could also make a platform specific component/module that resolves to either the web-only <video> tag or the native <RTCView> based on platform, like the example above. Perhaps even have the imports be resolved based on dependencies if you face any errors importing 'registerGlobals' at Web, for example.

add third party library to kotlin multiplatform mobile shared module

Am writing a KMM mobile app that will be calling an AppSync API, my intention was to implement all the API calls in the shared module so that I don't have to write that code twice (i.e for iOS and Android separately)
Secondly, I want to use the Amplify libraries in the shared module to implement the API calls, am hoping this would allow me to take advantage of lots of features such as offline storage.
What I am noticing however is that even though I have successfully added the amplify libraries in the commonMain sourceSet, the libraries are not visible on the classpath so i can not import any class from the libraries
Here is my commonMain sourceSet dependencies in the build.gradle
val commonMain by getting {
dependencies {
implementation("com.amplifyframework:core:1.35.2")
implementation("com.amplifyframework:aws-api:1.35.2")
}
}
This builds successfully and installs the dependencies but i can't import anything
My question here is,
Does this mean that I can not add any third party that is not a kotlin multiplatform library at all?
I feel like the only option this leaves me is to implement the API calls twice in a platform-specific way which kind of defeats the purpose of using KMM completely, is there an alternative solution that could allow me to use these libraries and write the API calls as shared code that is imported to both iOS and Android apps?
Thank you
I have decided to use https://www.apollographql.com/docs/kotlin/v2/essentials/get-started-multiplatform.
This seems to work well with the KMM, I can build the API calls once and re-use for both platforms.

Can I use DJI Mobile SDK with any cross platform framework?

Has anyone tried to use DJI mobile SKD together with any cross-platform development framework? Ionic, React-Native or Flutter?
Is it possible?
If they don't have a Cordova plugin available, it won't work out of the box. At least not in Ionic.
In order for it to work, you need to expose the API of the plugin to its JavaScript counterpart so that Cordova knows how to call certain functions.
We are currently working on a react native wrapper for the DJI MSDK. Feel free to check out our repo
A Flutter plugin in 2022
This is a library that you can use to develop cross-platform DJI iOS & Android apps.
The library is still under development, read more from the following:
https://github.com/DragonX-cloud/dji_flutter_plugin
https://pub.dev/packages/dji/install
Yes you can use React Native. You will need to build your own custom native modules for every feature/class in the DJI SDK separately for iOS and Android that you want to implement. So you need a good understanding of how those work.
For example an objective C stub is below. You can build native modules in ObjC/Swift, Java/Kotlin and more info on how that works can be found in the RN docs.
#implementation RCTDJIWaypointMission
RCT_EXPORT_MODULE(DJIWaypointMission)
RCT_REMAP_METHOD(loadMission, loadMission:(NSDictionary*)mission resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) {
// method body
}
import { NativeModules } from 'react-native'
const { DJIWaypointMission } = NativeModules
DJIWaypointMission.loadMission(mission)

How can I fix Android import settings after adding your SDK as a module?

Copied from the old forum:
I am trying to access the Jawbone API for the first time so I am following your Android Github steps. I downloaded your SDK and have it added as a module to my project but it is still telling me that it can't find any of the following import settings:
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
import com.jawbone.upplatformsdk.api.ApiManager;
import com.jawbone.upplatformsdk.api.response.OauthAccessTokenResponse;
import com.jawbone.upplatformsdk.oauth.OauthUtils;
import com.jawbone.upplatformsdk.oauth.OauthWebViewActivity;
import com.jawbone.upplatformsdk.utils.UpPlatformSdkConstants;
I also loaded your UpPlatform_Android_SDK-1.0.0 project and HelloUp and they both seem to have the same problem even though one of your suggested ways to get started is to just build off of your HelloUp example.
Any suggestions would be greatly appreciated!
I updated the project with the latest gradle version and buildtools. It should work now.
Reimport or do a gradle sync after you get the latest source.