Flutter: AndroidManifest.xml various issues - android

Just trying to get my app ready for publishing and the resources online are absolutely awful.
In my AndroidManifest.xml file I have my
<application
android:name="io.flutter.app.FlutterApplication"
android:label="My App"
android:icon="#mipmap/ic_launcher">
The compiler is having a tantrum because it doesn't understand "#mipmap/ic_launcher". I have followed all the documentation for this and my ic_launcher.png file is in every one of the mipmap folders under android\app\src\main\res. I even created a new folder just called mipmap, but nothing works.
There is no other information about this so I am at a loss. Can anyone assist?

What you did is fine, when you use the #mipmap/ path it means all folders for the Android buckets sizes. So, unless you use "svg" assets, that's the way to go for the icon (and other bitmap assets).
Maybe by accident you removed a line from the xml, or delete a file...
My advise: start a new project, and use a tool like appicon to generate those files for you.
Run the default Flutter project (to check that it works), replace the files with the ones from the exported zip, and test this default app in --profile or --release mode to see if it compiles and shows the correct icons/splashes.
Then, if you made a lot of work in your current (broken) project, put back the pubspec.yaml, lib/ and assets folder in this new project.
Good luck!

Related

Android/Cordova: Where to add files?

I have successfully created a project with the cordova command line tool and I am able to import this project in the Android Development Toolkit as well as run it in the emulator.
Now, I see the example files in the folder "/www". When I change these files, build the project (using CIT) and run it in the emulator, I do not see the changes I made. I assume that I need to change other files or put them in another folder. The assets folder is empty besides a file that says that I need to delete the exclusion filters to see the files. Do I need to change the files in there?
???
Thanks for any hint!
Once a cordova project has been created. It has a root /www folder where all resources are eligible to be shared on the added platforms (which you intends to add)
You should modify here. though its possible to modify resources per platform. (read more API)
Once any shared resource i.e. inside the main www folder are modified then you have to issue cordova build in order to reflect the changes in the corresponding platforms (which you have added)
You are unable to see the assets folder resources. Because by default it is hidden. Just select the project and go in properties and then remove the checks.
Import existing Android project --> select project --> right click select properties --> Resource --> Resource filters.
From the Exclude All , remove both items. This will show you resources inside assets folder.

How to create an android library project with no resources

I want to create a library project with just java/Android classes - but no resources. Basically it will contain helpers for IO etc. I have manually deleted the resources etc - the project is here - but I wonder if this can be done out of the box - or is my way not proper
NB: I need Android classes - so creating a regular java project is not an option (?)
Edit : if there is no out of the box way is there any catch in deleting the (edit: contents of the) res/ folder and the support library ? I would appreciate a 1-2-3 procedure
You need to keep project structure, incl. having res/ foder with drawable/ etc, but these folders can be empty. There's no requirement for your library to reference any drawable.
Others suggest it's mandatory for "app icon" but your library does not need any <application> entry in manifest, so it does not need any icon. The same applies to values/ and layout/ folders. Your library project have to have these folders (as required by build process), but having no file in them (so basically keeping them empty) is perfectly fine and valid and meets your requirements.
I believe you should keep all the required folders (including res) but you can leave them empty. Here is a guide for it.
http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
I believe you cannot delete the res folder completely since the app icon is contained in it. However you can delete the default layout if you do not need it and any other content that is required for the app to work.
If you would like to access the Android classes you will have to create an Android project.
I hope this helps.
I have created a git repository to illustrate - I created a vanilla eclipse android library project (screens) added a git ignore (bin/) and then proceeded to delete unneeded resources (all the contents of the res/ folder) along with libs/ and assets/ and edit the manifest. The changes are in this commit for reference. Cleaning the project removed R.java along.
Will be adding more (.gitattributes and eclipse settings for android) but this is for now.

I changed a resource in Eclipse and the app displays the old resource

In my app, I decided to change a resource (a PNG file). So, I delete the old one and add the new one with the same name. However, when I run my app in both my phone and the emulator, I still see the old picture !!
I tried all these options:
Cleaning the project.
Refreshing the project folder.
Closing the project then opening it again.
Exiting Eclipse and launch it again.
Uninstalling the old version of the app from the phone before run it again.
For those who may ask about how I use this resource (PNG file), I assign a XML selector file as an ImageButton's drawable. My resource is referenced in that XML file.
Any ideas will be appreciated.
You should change the Modified Date of the file to later. I did it.
Use this http://www.nirsoft.net/utils/filedatech.html
Look through your project's folders for other png files. Many mobile platforms use pngcrush to optimize pngs for mobile, and it is caching them somewhere. When you replaced the file, the IDE didn't notice and hasn't recrushed the new file. The old files will be somewhere in either the workspace's folder, or less likely, Eclipse's application support folders.
Are you on Windows, Mac, or Linux?
Changing an image resource file won't cause Eclipse to build a new version. Try modifying a source file by adding a new line, deleting the line, then saving the file. Eclipse should then rebuild your app when you launch it.
You just need to clean the project before rebuilding it, this removes all previous states and should update resource files if you've changed them in anyway.
Eclipse has a bad habit of compiling all your code to a structure within it's .metadata directory. Not sure if this is the case for your mobile app though.
Try searching the .metadata directory for the original png and modifying/deleting it there. We've had the same issue with deploying to web servers previously and Eclipse not picking up the changes.
I solved it.
The trick was to choose a different name for my image, modify my xml selector file and re-build the project.
Thanks

Making subfolders in a resource folder

Is it possible to make subfolders in the resource folders in the Android project? I have about 200 images (thumbnails) that I need in my project and I could add them in the drawable-mdpi, but it would be better to not mix these images with the other ones. Something like drawable-mdpi --> thumbs --> all images here.
No this is not allowed. You are only allowed to make folders specified by the android documentation.
The allowed sub folder names are specified in the link. Android generates the R.java based on these structures and putting sub folders can cause errors.
actually, there are mechanisms in place that allow the R.java file to be generated when there are folders with non-standard names in the res folder.
(i ran into this wanting to share a git repo as a submodule of both an iOS and Android project, but not wantint the Android project to pick up files that resided in a folder i designated.)
aapt is the tool that creates the R.java file, and it can be invoked with the --ignore-assets argument. there is a set of defaults for this found in the google source documentation, or a less verbose description simply by invoking aapt from the command-line without any arguments (or --help, which isn't a valid argument, but presents help nevertheless). using the line aapt.ignore.assets=xxx in an ant.properties file in your Android project will accomplish pretty much the same thing, depending upon your needs or preferences.
if you do not have a build.xml or other mechanism that forces usage of ant (which i do not), one of the aapt --ignore-assets defaults is <dir>_*, which means ignore any folders starting with _.
this was my fallback: i created a directory called _iOS_retina and placed all of my #2x files in there. (in Xcode, i can simply pull in resources from wherever they reside). the default invocation of aapt simply ignores it. to further streamline my project, i also updated my .project file to contain a resource filter that ignores this folder, and thus it doesn't take any space in my eclipse environment, either.
<filteredResources>
<filter>
<id>1371429105277</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-true-false-_iOS_retina</arguments>
</matcher>
</filter>
</filteredResources>

Uploading MonoDroid app to Android Market

I am trying to load an app to the Android Market. Below are the instructions I am using from the following website to prepare my application for submission:
http://android.xamarin.com/Documentation/Guides/Preparing_Package_for_Android_Marketplace
This following message is at the beginning of the instructions. But no instructions on how to add this to the AndroidManifest.xml file.
In order for the Android Market to accept your application, it must
define an application level icon. Ensure a line like this
exists in your AndroidManifest.xml:
<application android:label="MyApplication" android:icon="#drawable/icon">
A future release will provide better support for setting this.
The very first item has me stumped because I am getting the following error when I try to upload my application to the Market.
"The icon path specified by the manifest is not in the apk."
My question is, how do I add the application level icon statement to the manifest file?
Thanks.
p.s. The app deploys to both the emulator and local Android device in debug and release modes with no errors.
You can add a manifest file to your project by bringing up the property pages for your project, going to the Android Manifest tab, and doing the 'add AndroidManifest.xml' link.
Now there should be a file called "AndroidManifest.xml" in the Properties folder in your project.
Add the line specified to this file, replacing any existing element.
I had the same issue and it had nothing to do with the icon. I had an application class (GlobalVars extends Applications) and this was defined in the manifest as different: <application android:name=".GlobalVars" /> I deleted this and added android:name="com.example.myapp.GlobalVars" to the application declaration.
If it is the icon you may have drawable-hdpi, -ldpi, -mdpi folders, and no drawable folder. Or have a drawable folder but the icon is not in it.
Can you post the relevant snippet from your AndroidManifest.xml file? Whatever you have as the android:icon attribute ("#drawable/icon" in the example) is what the apk will be looking for. You can set this manually in the xml file, or by using the wizard in the ADT plugin for Eclipse. If this is set correctly, this means you should have a file called icon.png in one of your drawable folders. If you don't have an icon.png, can you post your folder structure?
In an app I've uploaded to the market, I have the same attribute - #drawable/icon - in my manifest, and therefore I am required to have a file called icon.png in my project. In my case, I have three different icon.png files in my various density-based drawable folders (res/drawable-hdpi, res/drawable-mdpi, res/drawable-ldpi). In your case, you need to at least have res/drawable/icon.png.
This error can also be generated if the manifest xml includes more than one < application > node.

Categories

Resources