This may be obvious, but can someone please tell me how I can locate my Hive Box file after initialising Hive in a Flutter application, using Android Studio?
I have followed the documentation here - https://docs.hivedb.dev/#/README - and my basic implementation works o.k, but I cannot find where the Box file, or any Hive files for that matter, are stored.
I want to be able to locate where my Box (database) is within my Project in Android Studio, so that I can see the contents of the database and confirm it exists in the right place
This is my code where I'm initialising Hive and opening a box
void main() async {
// Initialise Hive
await Hive.initFlutter('hiveusersfolder');
runApp(MyApp());
var box = await Hive.openBox('hiveusersfolder');
box.put('name', 'MyName');
print('Name: ${box.get('MyName')}');
}
The above code is present in my main.dart file
I am using Android Studio on Ubuntu.
*Edit update
I have located the supposed path of where the Box is stored, but when using Android Studio Navigate > Search Everywhere - there is nothing found within this folder/path. After initialising my database and adding a user to the box, I should be able to see a box file and view the users like with any other kind of db no?
This is the path /data/user/0/myappv1.myappv1/app_flutter
I tried Invalidate Cache + Restart, but still nothing
If the problem is with Android Studio search, how can I access the above path on Ubuntu file explorer? Or using the command line?
It is clearly stated in the documentation
/// Initializes Hive with the path from [getApplicationDocumentsDirectory].
///
/// You can provide a [subDir] where the boxes should be stored.
Future<void> initFlutter([String? subDir]) async {
Solved this by selecting a Project SDK from File > Project Structure
I then had to make sure I was using an Android Virtual Device with a system image that did not support Google Play store (Pixel 2XL with Android 8 I think, just picked anything without Play).
There is an issue where if you're using an AVD with Google Play loaded you won't be able to access the default folder where Hive puts your .hive files
Your Hive files by default, at least on Android with Flutter, seem to go into this path - /data/user/0/yourapplicationv1.yourapplicationv1/app_flutter
Hopefully this helps anyone experiencing the same issue
In the case of iOS, you can check it by following the steps below.
First, check the identifier of the simulator you are using in the application you are developing, which can be found in xcode under Window → Devices and Simulators. The identifier is usually formatted something like B8D6964E-01BD-4D90-96CA-746F87AF3F48.
2. run $ cd ~/Library/Developer/CoreSimulator
3. run $ cd YOUR-SIMULATOR-IDENTIFIER
4. run $ find . -name "*.hive" -ls
This will probably find the .hive file. However, in order to see the contents of this file, you will need to install Hadoop and Hive.
I haven't tried it because it seems a bit time-consuming, but I'll post a link that might be useful.
how-to-install-hive-on-mac-with-homebrew
In my case, I am implementing a macos application, the hive folder was:
/Users/me/Library/Containers/com.developerId.applicationId/Data/Documents/
Put a breakpoint on the await Hive.initFlutter('hiveusersfolder');, and step into it. Keep stepping in until you get to the getApplicationDocumentsDirectory(), and you will see what path that function returns.
Related
Whenever I try to run a dart tool like Dart Migrate I get the following error and I am unable to run that tool. Is there a way to solve this problem or I have to reinstall Flutter?
Btw every thing is okay with Flutter Doctor
After a lot of effort and wasting a lot of time on this issue I have been able to solve this problem. I have installed dart-sdk separately in the past and place the path of that dart-sdk at the top (before flutter one) in environment variables PATH. So I deleted that old dart-sdk path and deleted the respective folder this solved my problem.
In VS Code, if you get "Can't Load Kernel binary: Invalid SDK Hash" in Flutter or Dart, update dart.sdkPath setting
If you get this in VS Code, in addition to re-downloading the dart-sdk, make sure the "dart.sdkPath" setting in user/workspace settings is pointing to the new SDK. In my case, even though I had it in my path as in Junaid's answer, VS Code was still looking to the old dart-sdk folder and giving me the kernel hash error. I updated the dart.sdkPath to the correct path and restarted VS Code:
For example, in Windows:
Download dart sdk
Unzip it to c:\tools\dart-sdk or any other folder (make sure you rename or delete the existing dart-sdk folder)
ctrl-shift-p, type 'user settings (JSON)', open the json settings, and add:
"dart.sdkPath": "C:\\tools\\dart-sdk",
Update your system PATH environmental variable to point to the new dart-sdk and delete the reference to the old location.
Restart VS Code.
Note that Instead of This "dart.sdkPath": "D:\Dart\dart-sdk\bin" work well for me.
path should be included '\bin' also. It work for me
Flutter seems to have a very strict/rigid structure for plugins with example folder and all contents inside that folder.
I want to provide multiple examples with my plugin. Something like examples folder and then examples/demo1 and examples/demo2 as two different app examples.
I tried doing this but flutter run or pub get command breaks with this change. it's gets stuck with below error which wasn't thrown with exact same code in previous structure before change. Also my app actually follow embedding v2 code so this error is completely false too.
The plugin `<MY PLUGIN>` 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.
Somehow is it expecting that there should be only one example and that too with example folder only ?
Can someone help, and if possible point me to a plugin project where it's using multiple examples ?
After trying multiple ways to deal with the situation,
I ended up with a good enough solution.
I moved entire flutter repo inside an sdk directory, and then Introduced a samples folder at root level which can contain multiple sample applications.
sdk itself has a default sample app under example folder which I kept so sdk can ship with one example project.
Final structure look like below,
- Root
- sdk
- Flutter plugin project (like android/example/ios/lib directory etc.)
- samples
- sampleOne
- sampleTwo
I then mentioned relative path to sdk for sampleOne or sampleTwo inside their pubspec.yaml like path: ../../sdk/
When I want to open sampleOne in AndroidStudio, I import sampleOne directory and it works like charm. Make sure you don't import entire samples directory or sampleOne/Android.
For any regular Flutter commands for plugin, I run them inside sdk directory and everything works fine as expected. So I would run publish or pub get inside root/sdk directory
I want to bundle a native console program for macos written in Rust, into a Flutter app.
The Flutter app needs to call this program from Dart with something like this:
Process.runSync("./myconsoleapp", ["argument1", "argument2"]);
The Flutter app can't seem to find myconsoleapp.
Is there a way to embed myconsoleapp into the Flutter app, and make it executable? I tried manually adding and it didn't work.
Steve
Flutter for windows simply bundle project.exe along with a bunch of other files into a directory in (build\windows\runner\debug\). No one can stops you from adding your files to that directory.
In your dart code, simply start a new process from the newly added file:
var exePath =
p.join(p.dirname(Platform.resolvedExecutable), 'myFile.exe');
var result = await Process.run(exePath);
It can't find your executable because there is no relationship between ./--which is the current directory in the environment your app was launched from--and your application's location. If you want to access something bundled in your application you should be using NSBundle's pathForResource:ofType: to get the path to it (either via a method channel, or FFI).
Is there a way to embed myconsoleapp into the Flutter app,
You would add it as a bundled resource via Xcode. (There's nothing Flutter-specific about this step.)
and make it executable?
Presumably the product of your Rust build process is already executable.
I have a Flutter app and a package folder loaded in VS code at the same time within a workspace. What entry do I need to make to my app's pubspec.yaml file to ensure that changes I've made to the package are compiled and included whenever I hot reload or restart the app? What would be an alternate strategy if this is not possible?
If your pubspec.yaml refers to your package with a path then I would expect this to happen automatically. If not, I would consider it a bug. Please file an issue at https://github.com/Dart-Code/Dart-Code and include a log file generated by running the Dart: Capture Logs command and as much info about your project layout as possible (a clonable repo to repro would be perfect).
We tried to Implement two types of scenarios on Monkey Talk
One is recording through Source Code and Converting Eclipse Project to Aspect J project-Its working fine.
Second scenario we tried to use the .APK file for same project we are unable to record the apk formatted set up
Clarifications needed for Below points:
Can we record .APK file setups in Monkey talk or not
As per My Observation from Web we can use .APK file but I am
Unable to Find out the Solution for my Problem.
Looking forward to assist with you if you have any concerns & Waiting or your Informative reply..
Best Regards,
Uday Reddy.S
I was able to record using .apk when the device was connected by the option Android Device(USB). You will have to wait for 10-15 secs for the record button to be enabled.
You first have to make your app source code compatible with Monkeytalk by below steps and after than you can automate it
steps are :
1)Download MonkeyTalk for gorilla logic website and unzip it.
2)Open Eclipse and convert your project on "Aspectj" (need a plugin aspectj - for eclipse)- Once it get downloaded right click on your app,configure,Convert to aspectj.
3)Then under your project folder structure search for "libs" folder if it's exist then ok else create it.
4)Once it get done go to monkeytalk,agents,android,Monkeytalkjar file. Copy it and paste it under libs folder.
5)Once it done click on "jar" file and right click on it,Aspectjtools,Add to aspectpath.
6)Then go to Androidmanifest.xml file where we have to add some permissions;
<Uses-permissions android:name="android.Permission.INTERNET/>
<Uses-permissions android:name="android.Permission.Get_TASKS/>
and save it.
7)Go to project click on it,Right click,properties,JavaBuild Path,Check the "Aspectj Runtime Library,Ok.
8)Run your application as a Android application.
9) Open monkey talk.
10) Create new project,Create new script.
11)Then set the android sdk path under prefences; MonkeyTalk,MonketTalkPrefences,Android SDK path,ok.
12) Connect to emulator on monkeytalk.
Now you will be able to record and play in MonkeyTalk.
Some start up code for your reference eg; if we have two textfield username and password and one button submit.
app.input("username").entertext("aakash");
app.input("password").entertext("jaiswal");
app.button("submit").tap();