Why HMS Analytics kit in react native can not migrate to androidx? - huawei-mobile-services

While implementing HMS Analytics kit in react native, can not migrate to androidx because it breaks the build with below error
node_modules\react-native-ha-interface\android\src\main\java\com\huawei\hianalytics\HaInterfaceModule.java:37: error:
cannot find symbol
import androidx.annotation.NonNull;

Test it on Native java project without androidx support by adding below in the gradle.build.
implementation 'com.huawei.hms:hianalytics:4.0.3.300'

Related

Undefined symbol: _OBJC_CLASS_$_FlurryMessaging

I recently upgrade Xcode to 14.X, and I'm getting the following error when building
Undefined symbol: _OBJC_CLASS_$_FlurryMessaging
Seems like Flurry package doesn't support Xcode. What should I do?
I am an engineer on Flurry's SDK team. Based on your description you are using Swift Package Manager?
Make sure you have imported Flurry analytics and messaging:
Add a import statement for messaging:
import Flurry_iOS_SDK
import Flurry_Messaging
Note Flurry Messaging is only supported on iOS and tvOS
For Cocoapods you need have the following in your Podfile:
pod 'Flurry-iOS-SDK/FlurryMessaging'
You should see the frameworks here:
Otherwise the instructions are the same as the above.
I have sample code for Flurry Messaging implementation here:
https://github.com/flurrydev/iOS-Push-notification-sample-swift
If this doesn't clear up the issue for you reach out to me at support#flurry.com

How to compile the source code based on the platform in Flutter?

I have implemented a plugin in Flutter. And it is running good with android and ios. Later added web platform support. It also working good in web version. After adding web platform support, I tried to execute the mobile version android from android studio.
Code is not compiling and giving the below error messages.
/lib/native_video_view_web.dart:5:8: Error: Not found: 'dart:html'
import 'dart:html';
^
/lib/src/navigation/js_url_strategy.dart:9:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
I understood this is due to 'dart:html' package, which is ONLY available for web and NOT for the mobile version. Here is some discussion about the same Reference Link. Nobody mentioned how to compile the code based on the platform to avoid this issue.
Later I have observed, video_player flutter plugin source code. They are also supporting web version. And noticed that they are also using 'dart:html' in their web implementation. And i tried to execute mobile and web build. All are working fine with any problem. I am not understanding how they have managed to compiled code based on the platform. So 'dart:html' will not create problem for mobile builds.
Does anybody have any idea, how to deal with this issue.

How to use cloud_firestore in flutter for web and android?

I have a Flutter app which works on Android as expected but if I want to compile it for Web I get an error.
It has to do something with the dependency cloud_firestore. If I use the dependency firebase it works fine on the web but on android now not..
This is the error message I get using cloud_firestore (compiling for web):
Skipping compiling pay_balance|lib/main_web_entrypoint.dart with ddc because some of its
transitive libraries have sdk dependencies that not supported on this platform:
firebase_core|lib/firebase_core.dart
https://github.com/dart-lang/build/blob/master/docs/faq.md#how-can-i-resolve-skipped-compiling-warnings
Can anybody help me? Maybe with another dependency for firestore (I did not find others which are working on web and android)..
Edit: I have used the firebase-dart plugin for web!! -> Only works on the web but not in android for me -> I need something for both at the same time!!
Or is there a Way I can use both packages without getting a compling error for the web when I import cloud_firestore?
If you want to use Firebase on Web and Mobile you have to get creative. I created the fb_auth plugin that uses the Mobile SDK firebase_auth on iOS and Android and the firebase package on web. This will give you a single plugin for auth.
https://pub.dev/packages/fb_auth
Im working on firstore and storage but they are not ready yet.
I have also created an article on how to do this with flutter:
https://medium.com/#rody.davis.jr/how-to-build-a-native-cross-platform-project-with-flutter-372b9e4b504f
You have to use dynamic imports so that at compile time it tree shakes what it doesn't need and will not throw an error.
Currently this is the only way to officially use both plugins in the same project.
EDIT: cloud_firestore now added
Two of the FutterFire plugins are now supported for web. FlutterFire plugins supporting web firebase_auth and firebase_core
cloud_firestore is now also supported

In flutter when I am trying to run project it is giving error

Pease help me!, I am new to flutter I am importing a project and when I try to run it is giving exception
/simple_permissions-0.1.9/android/src/main/java/com/ethras/simplepermissions/SimplePermissionsPlugin.java:9: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
My project is already compatible with androidX, I have tried package get and upgrade package but nothing happens, I have got the similar problem
When you migrate a flutter app to AndroidX, all the plugins the app depends on should also support AndroidX else your app build will fail and this is what is happening here.
Even though you have migrated your project to AndroidX, the simple-permissions plugin has not been migrated to AndroidX yet and this is what is causing the issue.
Below are the options you have in this case -
1. User the permission_handler plugin instead of simple-permissions.
The permission_handler plugin is a much more frequently updated plugin which has already been migrated to AndroidX. Here is the link to the plugin.
2. Migrate simple-permissions to AndroidX yourself
If you strictly want to use simple-permissions, you can clone the git repo and manually migrate the plugin to AndroidX and use the plugin via git url inside your pubspec.yaml. Details for migrating plugins to AndroidX can be found here.
You can use the plugin from git url in the following way inside you pubspec.yaml
dependencies:
plugin1:
git:
url: git://github.com/flutter/plugin1.git
//Your repo url goes in place of this url
3. Avoid using AndroidX altogether in you app.
You can force your app to use the older support libraries if you do not wish to perform the above two steps, but by doing this you will need to downgrade all your plugins to versions which do not use AndroidX, which is not the ideal solution.
More about this here.
Hope this helps!

How to import iOS native framework into Flutter?

I want to contribute in this Flutter_blue plugin project adding the functionalities for native iOS using Objective C framework CoreBluetooth. How do I import the framework in to the library so I can start using its APIs?
Update:
CoreBluetooth is not suitable for Flutter project, because it's not a cocoapod dependency. So what I did what, go to cocopods website and look for other bluetooth dependencies from there. You can also find instructions of how to install a dependency there. For me, I made added pod <depdencyname> to <plugin-project>/example/ios/Podfile in the plugin project. Then added dependency: <dependencyname> to the in <plugin-project>/ios/pubspec
I had the same problem for a few time and found a solution by adding this lines to your podspec file at your iOS/ folder in your plugin dir:
s.preserve_paths = 'yourframework.framework'
s.xcconfig = { 'OTHER_LDFLAGS' => '-framework yourframework' }
s.vendored_frameworks = 'yourframework.framework'
Then, on your Flutter project, in the iOS folder, just run pod update on terminal so it can fetch the new dependencies.
You can find the full issue open by me with this problem here.
If you're looking to add a CocoaPod dependency to the iOS "half" of a Flutter plugin, I believe the correct way to do so is to update the podspec file in the /ios folder of the plugin source. I recently did some work on the AdMob plugin, for example, and its podspec lists the SDKs for Firebase and Google Mobile Ads:
https://github.com/flutter/plugins/blob/master/packages/firebase_admob/ios/firebase_admob.podspec
And that's how they get included in the build.