Flutter app which uses huawei_push rejected by Google Play Store - flutter

I want to use huawei_push kit in my flutter app but Google Play Store rejected my app because of PendingIntent issues (security rules). I want to use the same source code for Google Play Store and Huawei App Gallery. I was thinking of:
building APK based on flavor (huawei push kit dependencies won't be used in built APK),
using different pubspec.yaml files to avoid huawei push kit dependencies in the whole project.
Question:
How can I use huawei_push kit just for Huawei App Gallery still using the same source code for different stores?

Update:
The problem has been reported to R&D Team. And it's expected to be fixed in the next version.
At the same time, we provide a workaround solution. You may refer to this before next version release.(The Flutter plug-in is open source, so you can modify it directly)
Here's how to modify:
1.Open the pubspec.xml file in the root directory and find the plug-in.Like following:
dependencies:
flutter:
sdk: flutter
huawei_location: 5.0.0+301
You need to find the cache directory of the Flutter, for example:
Find the plug-in directory, for example:
If the plug-in points to a directory, for example:
dependencies:
huawei_location:
path: {library path}
directly access the directory.
2.Modify the build.gradle file in the android directory to modify the SDK version on which the file depends.
For example:
implementation 'com.huawei.hms:location:5.1.0.303'
P.S. The PendingIntent issue has been resolved in Push kit 5.3.0.304. So you can directly use this version.
After the modification, run the following command to trigger compilation:
flutter run

Related

I get this error in my flutter app. migrate this app to the V2 embedding

I get this error in my Flutter Project,
C:\src\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in source_code... 34.3s
This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
The plugin firebase_core requires your app to be migrated to the Android embedding v2. Follow the steps on https://flutter.dev/go/android-project-migration and re-run this command.
Process finished with exit code 1
Flutter Embedding Error
Since Flutter 1.12 the way how Flutter plugins communicate with the native Android side has been improved. Allowing plugins to better integrate with the native Android lifecycle.
Some plugins support both the new and the old structure, however many plugins (like firebase_core) dropped support for the legacy structure to ensure optimal integration with the Android system.
Apps created using Flutter 1.12 and higher automatically generate the correct Android integration logic, however Flutter applications created with an earlier version of Flutter need to be manually migrated. There are two options to fix this for your app:
The easiest solution is to delete the android folder in your project and let Flutter (using Flutter 1.12 or higher) recreate it for you by running the following command in the root folder of the Flutter project: flutter create --platform=android . (don't forget the . at the end of the command). You should only do this if you haven't made any custom changes to the Android code and of course make sure to make a backup first.
The more safe option is to manually migrate the Android project using the instructions provided on the GitHub Wiki page mentioned in the error message.
When following the instructions on the GitHub Wiki page make sure to keep an eye on all the details. Personally I forgot to update the <application android:name="MyApp" to the recommended <application android:name="${applicationName}" which resulted in the same error you are reporting.
What helped me was to create a new "dummy" application with the latest version of Flutter (for example flutter create --platforms=android test_app) and compare the files in the Android folder with the files of my current App and make changes where necessary.

How to use both Flutter stable and dev SDK on the same machine?

I'm working with Flutter to make a Mobile App using the stable Flutter SDK release. But I also want to try Flutter Desktop and Flutter Web that are not part of the Flutter stable channel yet, but are present on the Flutter dev channel.
My question is... How can I try Flutter Desktop and Flutter Web without override the Flutter stable release on my machine?
You'll need to setup alias to switch between different environments easily.
See here a detailed article for that.
I found this Dart package called Flutter Version Management that does exactly what I want.
As the docs says:
Flutter Version Management: A simple cli to manage Flutter SDK versions.
Features:
Configure and use Flutter SDK version per project
Ability to install and cache multiple Flutter SDK Versions
Fast switch between Flutter channels & versions
Dynamic SDK paths for IDE debugging support.
Version FVM config with a project for consistency across teams and CI environments.
Set global Flutter version across projects
https://github.com/leoafarias/fvm
Now I just need to add FVM_HOME/default/bin to the PATH and FVM will take care of everything...
Two solutions
Put the installation files in two different directories one with stable and the other dev and add one of them to the path then you can change the path variable when needed to use the other channel.
Put the flutter repository file in two different directories one with stable and the other with dev then,
add the first installation to the path then add an alias to point to the second installation directory.

Web capability with flutter package: mapbox_gl

The mapbox gl package page lists it as suitable for web applications (mapbox_gl).
I tried running the example as a web application, but I encounter the error Error creating mapbox_gl_example|lib/move_camera.ddc.dill
Error creating kernel summary for module:mapbox_gl_example|lib/move_camera.ddc.dill
.
So, my question is, is the flutter package mapbox_gl actually able to be run as a web application as the tags "FLUTTER ANDROID IOS WEB" suggest (is there something I must configure), or is it really not web capable as may be indicated by the fact that the actual description mentions nothing of web capability?
Update: The mapbox_gl flutter plugin now has web support merged into master on Github. If you don't want to wait until web support is released to pub.dev, you can depend on the Github repo directly with this dependency in pubspec.yaml:
mapbox_gl:
git:
url: git://github.com/tobrun/flutter-mapbox-gl.git
Outdated answer: Unfortunately, it doesn't support web yet (although PRs are welcome if you want to contribute). The reason it was listed as supporting web (like many other plugins) was that flutter changed the way plugins declare their supported platforms in the pubspec.yaml file. The mapbox_gl package has since been updated on pub.dev and now correctly shows that it only supports Android and iOS.

How can I import dependencies in flutter web?

I'm setting up a new flutter-web application but I can't add dependencies that I could do in flutter.
for example I want to add font-awesome-flutter to the project but get this error!
font_awesome_flutter: 8.5.0
Because font_awesome_flutter >=8.0.0 depends on flutter any from sdk which is forbidden, font_awesome_flutter >=8.0.0 is forbidden.
So, because salema depends on font_awesome_flutter 8.5.0, version solving failed.
since flutter-web is not still stable and its in technical stage, a simple way for using library in flutter-web which has been working for me is to add the library resources manually. you just need to copy everything inside the lib folder of the library in your own project.
in order to access the library's resources go to https://pub.dev/flutter and search for the library you want and then find the library's github repo in the about section.
flutter_web does not have a plugin system yet. Temporarily, we provide
access to dart:html, dart:js, dart:svg, dart:indexed_db and other web
libraries that give you access to the vast majority of browser APIs.
However, expect that these libraries will be replaced by a different
plugin API.
Source:
https://github.com/flutter/flutter_web/blob/master/README.md
In short, Flutter dependencies are not supported by Flutter Web at this time.

Add flutter web and desktop to existing flutter (android/ios) project in android studio

I know it maybe still early but I want to try and use full flutter existing cross-platform support in one project. Stability is not my main concern.
I have started a flutter project in android studio. Naturally I have (android/Ios) going smoothly. But I would love to add Web and desktop to the same project.
Please help me with and direction, or if there is solution any one has created however much experimental.
There is a migration guide for web here. I got it up and running on a very basic existing app.
Best way is to do it in a separate branch since it requires changing packages and I even deleted .packages and pubspec.lock files first. Then I ran pub get (not flutter packages get) to download the required packages and run some precompilers.