I believe it has something to do with me importing a project of the same name (working from different computers), but I really don't know. Within the bin folder of my project is another res folder, containing AndroidManifest, classes.dex, jarlist.cache, R.txt, resource.ap_ and the apk of my application.
Incidentally, or not, when trying to update my application icon, it only worked when changing the manifest in this version as well.
One of the res folder is auto generated. To check which one is auto generated, click on the res folder and press Alt + Enter. Then select resource on left side of the pop up and on the right side, you will see the location. If it's
YourProject\res
then it's your original res file and if it's
YourProject\bin\res
then it's the auto generated res file.
Related
Iam working on a quiz project in flutter. I stored my quiz text files in folders according to the quiz category. And all these folders are stored in one root folder. So I should be able to list all the folders in this root folder ( which are categories ). And when category folder is opened the files in that corresponding folder should be listed.
The goal is to make buttons with each folder's name and the button will hold the path to open that folder.
ie, if the user clicks a button for folder, a list will be made containing the names of folders inside the clicked folder and according to this list a listview of buttons will be made.and finally when you open folder containing quiz files same will happen but button will contain the corresponding file path.
I have made the folder tree and functions to make buttons according to the names stored in list. But I have no idea where to put this folder inside the project.
I have tried puttin in the root of project, in Lib folder, in asset folder but flutter is failing to detect this directory.
I really need this to work for my project to go forward. Any help of pointers will be appreciated.
For this to work you need multiple things:
Viewing you folders and text files within flutter
Listing your folders and text files
Reading your text files
1 - Viewing you folders and text files within flutter
Since the assets notations doesn't support recursion, you have to either:
Write everything by hand
Use a plugin to generate the assets for you
Since you have many file I suppose the second option is the best for you. I did struggle to find one that worked but FlutterAssetSync is working like a charm according to my tests. The only constrain is that you have to put everything inside the "assets" folder (which is not really a constraint tbh).
Once you put you file in the assets folder, execute the plugin (under Tools > FlutterAssetSync). This will automatically add everything to your pubspec.yaml
2 - Listing your folders and text files
In order to get the name of your folders and your text files you can use the answers to this stackoverflow question. Basically here is the implementation:
Future<List> _getImages(String folderName) async {
final manifestContent = await rootBundle.loadString('AssetManifest.json');
final Map<String, dynamic> manifestMap = json.decode(manifestContent);
return manifestMap.keys
.where((String key) => key.contains(folderPath))
.toList();
}
3 - Reading your text files
To read the content of a text file asset you must use loadString (as we did in _getImages btw). Here is a quick implementation:
Future<String> _getQuizzText(String quizzTextPath) async {
return await rootBundle.loadString(quizzTextPath);
}
Putting everything together you should be able to make it work!
I am unable to create a folder in the same location with the same name just after deleting the folder with the same name(manually,deletion is manually,not programmatically). I am trying to create folder using
mediaStorageDir.mkdirs()
I dont know why this happens, also some times I see a junk file of size 0KB with the same name after I have deleted the file, I assume this is preventing the new folder creation. Those who have an insight into folder structure, pleas throw some light into this topic.
Below is the image of the dummy file that is created after the deletion.
I have the next problem:
When I add a new folder called "values-en" and I move the strings.xml file from the default folder "values" to that "values-en", I always get the next error:
Couldn't resolve resource #string/my_string
I have cleaned the project and refresh and the warning is always there.
Is there any restriction where I must always have a strings.xml in the device folder "values"?
Someone has experimented the same?
Thanks in advance
You must have the values folder. To support multiple languages you can add the other values folders (values-en, values-fr, etc).
In the default values folder you declare your strings in your app's default language and in values-en the same strings but with their english translation.
I have 2 different functionality to be implemented as part of a single application.
They have different screen flows and BL to be implemented but a single apk,so it is transparent to the end user.
I have 100 screens for each of the flow,so can I have custom folder names in the resources directory for easy maintenance and loose coupling.
eg: res
-layout
-layout_savings
-layout_checking
-drawable
-drawable_savings
-drawable_cheking
currently we have only the following structure
res
-layout
-layout-land
-drawable
-values
Will there be any problem while generating the R.java file.
Any help would be appreciated.
for what you need , i suggest you to use the assets directory instead of res. in assets dir you can sort your files anyway you like (dir name/filename) . You access them with AssetManager.
this require a little change in code but i think this is the only way if you want to sort your file like that , res folder doesn't allow custom directory names.
(Or of course you can store files in the sdcard)
This one puzzles me since my first android project. Consider multi-language string resources with 'en' as the default:
res/values/strings.xml <--- The default language 'en'
res/values-de/strings.xml <--- de
res/values-fr/strings.xml <--- fr
res/values-it/strings.xml <--- it
With that folder structure the Android Market entry for this app shows language support for "default, german, french and italian only". Yes, english is missing in that list.
Is it possible to "include" the complete default strings resource from the "values" folder in an additional "values-en" folder. And yes, I don't want to maintain that file in that new folder because everything is declared in the default string resource already.
Many thanks in advance.
Harald
I don't quite understand where the problem is. Just create a values-en directory and copy'n paste the XMLs from your default directory to the new one.
If you just want to have a kind of symbolic link to that default values directory so that when you change something inside the default directory the files i the linked directory represent the same changes then you just go to File -> New -> Folder select where the new folder should be created (in your case the res directory) and then hit on Advanced >> and there select Link to alternate location (Linked Folder) then browse to the directory you want to link to (in your case the values directory) and your done.
Now whenever you change something inside the values directory all your changes apply to the new linked directory.