when I use library, image_picker, I have errors Task "'assembleAarRelease' not found in root project 'alert'."
but I remove image_picker in pubspec, the application work well
I need both alert and image_picker
enter image description here
Related
I want my app to be available for the web.
I run this command: flutter create .
I get this error: "Fredi" is not a valid Dart package name.
I know that there shouldn't be any capital letters. However, I do not know how to change the dart package name.
I have already used these packages successfully, but they seem to be changing other things, not the Dart Package Name.
change_app_package_name: ^1.1.0
rename: ^2.0.1
The only thing in my project with the name 'Fredi' is the root folder (original project name). However, I don't know how to change it (file explorer won't let me) and it will probably break things.
What step can I take?
Config Files
app/build.gradle -> applicationId "com.tomasward.fredi"
android manifest -> package="com.tomasward.fredi"
android manifest -> android:label="Fredi"> [I understand this is the name displayed to the user, I've tried changing it but it doesn't fix the error.]
You can run flutter create --project-name "your_valid_package_name" InvalidPackageNameDirectory to create a Flutter project in a directory with a non-valid package name.
In an already existing project, you can change the package name by modifying the name property in the pubspec.yaml at the root of the project (see here for more details on the pubspec).
You can probably rename your package name with the help of some dependency that you can find on pub.dev by typing "rename" in the search bar.
All those dependencies will help you rename your package to a lowercase only package name, then you will be able to use the flutter create . command to create the web folder for your app.
I am writing uber h3 plugin for flutter. I have working source code but I have problems with creating package more precisely I have problems to bundle libh3.so
Quick overview:
there is uber h3 c source code which is downloaded by. download_deps.sh
then android/build.gradle has build commands
externalNativeBuild {
cmake {
path "../ios/CMakeLists.txt"
}
}
then example/lib/main.dart has some initialization code.
initializeH3((String name) => Platform.isAndroid
? DynamicLibrary.open("lib${name}.so")
: DynamicLibrary.process());
but when I try to build it library file can not be found.
-I tried different locations.
It seems that library native .so is not bundled into application
But I don't konw why
According to tutorial https://flutter.dev/docs/development/platform-integration/c-interop
it should be bundled.
Here is the source code https://github.com/fmatuszewski/h3
I have managed to get this running, the pubspec.yaml was incorrectly formatted and required:
flutter:
plugin:
platforms:
android:
package: com.example.h3
pluginClass: H3Plugin
ios:
pluginClass: H3Plugin
Adding in at the end.
In doing this the package was properly attached.
libh3.so needs to be added into android/src/main/jniLibs to naturally be attached however I also moved the code:
final DynamicLibrary h3 = Platform.isAndroid
? DynamicLibrary.open("libh3.so")
: DynamicLibrary.process();
Back into h3.dart and removed main.dart to get this to run.
I think these were the main issues to get the code running. I had issues working out what was wrong as I am new to plugins - so it was a long process to sit and work out all the ins and outs. In doing this I ended up reworking all of the code to understand what was going on. If none of these points work or you wants eyes on the working code let me know and I can upload it to Github.
I have an module with an 'assets' folder located in the same directory as my pubspec.yaml file. In my assets folder I have test.txt, and simpleObject.json.
flutter:
assets:
- assets/test.txt
- assets/simpleObject.json
I believe the following code should then allow me to read it into my app.
var test = await DefaultAssetBundle.of(context).loadString("assets/test.txt");
Sadly I get the following error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Unable to load asset: assets/test.txt
The error comes from the asset_bundle.dart. I have to assume this is my fault, but according to everything I've read I'm doing it correctly. Any thoughts?
Here is my file structure if it helps.
MyModule
|_assets/test.txt
|_lib/
|_pubspec.yaml
I got a solution. Even though my package was trying to load its own asset, it still had to specify itself as the location.
Here is how my_package loads an image asset (specifying the package), uses it in a widget, and that widget is easily used by outside apps.
Image.asset(AssetImage("assets/splash.png").assetName, package: 'my_package',);
This is a bit late, but another solution can be:
Image.asset('packages/<package_name>/assets/splash.png');
I encountered this problem and took a lot of time before it was resolved.
The solution was to downgrade to a previous version (git checkout v1.5.4-hotfix.2)
This might be a duplicate of this question. But it has no answer and I will give some details here.
I have created a module with File->New Module->Android Library inside my Flutter plugin's android project. And now I have a structure like below:
|-my_plugin
|-android
|-settings.gradle
|-build.gradle
|-mylibrary
|-build.gradle
/android/settings.gradle:
rootProject.name = 'my_plugin'
include ':mylibrary'
/android/build.gradle:
...
dependencies {
implementation project(':mylibrary')
}
When I build example plugin project (which is automatically created by Flutter CLI) with flutter build apk or flutter run, I get this error:
Project with path ':mylibrary' could not be found in project ':my_plugin'.
Any suggestions?
For those who are still looking for a solution. You can try this.
Instead of putting the below code in the plugin setting.gradle, place it in example/android/settings.gradle
include ':mylibrary'
when i import mupdf 'lib' project in my app that build error,the log
"Failed to resolve: com.artifex.mupdf:fitz:1.13.0".
But i have already add the maven url in top build.gradle.Please tell why,thanks.
...,i tried to reboot my computer ,then,the compile is successful.It maybe the android studio's bug.I hava tried every way.But it didn't work and it cost me a half of day.