some ionicons not showing - android

I have noticed that some of the icons I am using in my cordova project are not displaying on any of my devices. The ones that aren't working seem to have the word ios or android in the icon name (eg: ion-android-list or ion-ios-book-outline). Any ideas why they are just showing up blank? So far any icon I have used with a generic name works fine (eg ion-clock, ion-card). The icon names I am fetching from here: ionicons
I have included this in my index.html file:
<link href="lib/ionic/css/ionic.css" rel="stylesheet">

Apparently the latest version of ionic when building an ionic app using ionic start from CMD loads an outdated icon library v1.5.2 (latest is v2.0.0).
To update the fonts go to the latest ionicons site and download.
Unzip and navigate to the /fonts dir and copy these 4 files to the www/lib/ionic/fonts dir of your app (overwrite).
Do the same for the scss folder and paste to www/lib/ionic/scss/ionicons (overwrite).
Lastly open the ionicons.css file from your extracted zip file /css/ionicicons.css and copy the contents of that file to www/lib/ionic/css/ionicons.css (NOTE: Make sure you edit and only replace the existing font version takes up about the first 1500 - 2000 lines, you will see the comments indicating)

Looks like you're using Ionic, rather than just Cordova.
You could do a partial upgrade to the forthcoming release of Ionic, which includes Ionicons v2:
Download /config/lib/fonts and /scss/ionicons from the latest nightly into the corresponding places in your /www/lib folder
Make sure you have gulp installed locally: npm install gulp
Run ionic setup sass (NOTE: backup your ionic.project file first as this makes some changes)
Replace the files in /www/lib/ionic/css with the new ones in /www/css (requires some renaming).
Fix the relative paths in these copied files: replace ../lib/ionic/fonts with ../fonts
I'm sure there's an easier way, but this worked for me. Someone's made a feature suggestion for always keeping ionicons up to date.
Update:
Animated icons aren't supported with Ionicons v2 yet (ion-spinner will be the replacement). Here's a hack to get them back:
https://github.com/driftyco/ionicons/issues/111#issuecomment-65788526
You need to add display:inline-block to the animation class to work on Android.

For newer versions just use:
<ion-spinner></ion-spinner>
more: ion-spinner

I had the same issue. The easiest way to resolve:
Delete www/ionic/fonts and www/ionic/scss/ionicons directory.
Then run ionic lib update from your project root directory.

i guess it might be about the used version of ionic if it's V5 or if #ionic/angular's version is V5 you need then to use ionicons from version 5 not 4 (they have different names).

Related

How to embed an Android library (AAR file) into a capacitor plugin?

The issue is already answered for iOS:
How to embed framework in capacitor plugin for iOS
For Android, I get issues when I add an aar file to the capacitor plugin by creating a new module. After publishing my capacitor plugin via npm and integrating it into an ionic app, the aar library cannot be found anymore.
As done on iOs, we do practically the same thing here. But, using Android Studio and gradle instead of xcode and cocoapods.
Ok, but first things first.
When the command npx #capacitor/cli plugin:generate is issued, what the CLI does is to start a folder containing a cocoa pod for iOs and a gradle plugin for Android. You can see this on the image below.
With the above command issued, there will be a ios and android folders inside you generated plugin folder. If this checks, open you android studio and select the option to open a android studio project, selecting the android folder to fulfil this procedure. You can select this option on the initial screen, like showed on the next image.
With the project opened, if all went well you'll se your android studio showing a screen like this
Now, lets add the plugin files. To do this, right click the android java module and select the "Open Module settings" option, as shown on the next image.
With the following screen opened, we need to add a module here that contains our jar/aar dependencies. To do that, just click on the + sign that is showed above.
On the new module screen, if you scroll down there will be a "Import .JAR/.AAR package", like shown above.
After that, locate you aar package. The result will be the following.
Click finish and the next screen will appear. If not, hit the apply button in this same screen.
Since my module has a dependency, I'll repeat this part of the tutorial.
Next, we need to add our recently added modules as dependencies of the android module. On the same screen, click on the dependencies option and on the plus sign of the "declared dependencies" pane.
The following screen will show. We need to select the 3rd option, since what we did early was adding a module.
Now, lets select our module. Its simple, just mark it and click ok. Since I have to, as said before, I'll check both of them.
If this step went well, you should have now you android module with one more dependency (or two in my case). The image bellow show that.
Hit apply and close this window. Gradle will rebuild your plugin project on the background and after that,since I know kotlin better, I'll convert my project to kotlin. If you wish, this can be done as shown on the next image, but is not mandatory.
With all the above done correctly, you can now import your lib on the TestPlugin.kt (or .java if you didnt use kotlin). For reference, the image bellow show the minimum implementation for my plugin.
In the plugin folder, we are done. Pack it using npm and install on you app.
Next, to the plugin works properly, we need to add its class on the MainActivity of the app that you'll be using it.
Now, to make it work, i'm not 100% sure that this is the correct way to do it, but since it works I do this way. The way I do is to add the plugin modules on the android module of the app via script. I think i am missing something on the gradle plugin implementation, but since it works.....
To do this, access, on your app, the android/settings.gradle file and append this:
Please note that depending on the changes that you do, the settings.gradle file will be rewritten. Do a script to keep the info always there or check it before build.
Thats it, please comment if you know another way to this next step or in any another if there is a better approach. And, if this answer is useful, please thumbs it up, since this implementation, when finished and working, made me cry a little (of happiness, of course).

Custom RES SCREENS and RES ICONS get replaced with default Cordova screen and icon

I'm using Visual Studio tools for Apache Cordova.
I've tested the CLI 6.4.0 and unfortunately there is a bug with the RES SCREENS and RES ICONS. If I use CLI 6.3.1 this issue disappears. To demonstrate it I've created a new project from scratch, added only the cordova-plugin-splashscreen (ver 4.0.0) and replaced the original screen images with custom ones.
The issue happens when I try to debug with a physical android device connected via USB.
On build the system automatically creates some extra folders/files (one new folder/file for each splash configuration I have in my config.xml), so in my case I get these new folders/files:
res/drawable-land-hdpi/screen.png
res/drawable-land-ldpi/screen.png
res/drawable-land-mdpi/screen.png
res/drawable-land-xdpi/screen.png
res/drawable-port-hdpi/screen.png
res/drawable-port-ldpi/screen.png
res/drawable-port-mdpi/screen.png
res/drawable-port-xdpi/screen.png
The PNG files reflects what I have in my RES/SCREENS/ANDROID folders.
At the same time the build copies these new folders (described above) to the PLATFORMS/ANDROID/RES folder. The issue is the images inside those folders are not the original ones I have chosen in my project, but they are the Cordova Logo (the one that is added by default when a new project is created).
Thanks Elvis for pointing it out! Your bug report has been closed because it's a duplicate issue.
Here is the link to the official bug report: https://issues.apache.org/jira/browse/CB-12077
And here is the GitHub Pull Request:
https://github.com/apache/cordova-android/pull/343

monaca dosen't load www/index.html

I'm using monaca(onsenui-react) to create cordova app.
After type monaca preview I have checked app on browser like this.
But the index.html wasn't one I expected.
I mean have edited the www/index.html, but it's not loaded on browser.(I don't know what index.html was loaded)
Of course I typed monaca preview after edit www/index.html.
Does anyone can help me?
You need to run monaca transpile to transpile (kind of a compilation) your code into the www folder.
Using monaca preview will use the "webpack.dev.config.js" configuration to generate a compilation to a temporary folder. Using the "transpile" command will use the "webpack.prod.config.js" to compile your code into the www folder.
One more thing: monaca uses a strage combination of folders and package versions (most of them deprecated) to transpile, so I recommend you to do this manually if you are not using the monaca tools (the online paid stuff).
Recently I made a repo with everything already set up (using Onsen UI and React, also Redux - which is easily removable), using the latest version for every npm package (Webpack 2 being the most important, instead of the version 1 used by monaca) and keeping everything in your project folder (in your package.json, like it should be). You can find it here.

CordovaResourceApi import unresolved phonegap

I am using phonegap-2.9.0 with file plugin. When I build project for android platform it creates two packages within the src/ folder:
org.apache.cordova.file
org.apache.cordova.filetransfer
I get below errors within these two packages:
1 - org.apache.cordova.file.FileUtils
Method testSaveLocationExists() from the type DirectoryManager is not visible
Method getFreeDiskSpace() from the type DirectoryManager is not visible
Method testFileExists() from the type DirectoryManager is not visible
2 - org.apache.cordova.filetransfer.FileTransfer
import org.apache.cordova.CordovaResourceApi unresolved
import org.apache.cordova.CordovaResourceApi.OpenForReadResult unresolved
Could someone please tell me what I should do to resolve these?
Thanks.
You have two problems.
1) Version of Phonegap is outdated
2) The way to install a plugin is:
-> phonegap plugin add "urlofplugin" or "/path""
-> phonegap platform add android
-> phonegap prepare
-> phonegap build
sometimes the plugin has a different default installation, the files need to change the platform.
Well, I dont know if I can help you, but I had similar problems. When I installed exactly those two plugins I got an error too. A different one, which I dont perticularly remember, something to do with a missing file that I can easily find in the file manager. Anyway, what helped me was:
I updated to a more recent version, if you are able to I advice for it.
After installing the plugins through cordova cmd api (.nodejs command prompt ... you know what I mean) I was forgetting to build in the api itself. It sounds stupid but I was using wp8 and thus using a template for visual studio. The studio gave me the error, the building process (in cmd) also gave errors, but it was fixed by updating to the newer version.
You need to configure you build path and then add library from external source and select the library then it will resolve or u can make copy and paste cordova library .jar file in your lib folder. then it will remove, if not happen then tell me .......
I am not sure if that will work but first uninstall these plugins using phonegap/cordova CLI and than reinstall it in the root of application folder using the CLI only like this:
phonegap local plugin add <required plugin>
This worked for me after reinstallation.

How to add javadoc for android to Netbeans

I just started using Net Beans. I am wanting to try my hand at developing android apps. I got the android sdk downloaded and everything is working well. I can create little apps and run them in the emulator. However, the intelisense popup for the android methods says that the Javadoc isn't found. Is there a way to add it?
The best way as below steps in NetBeans 7:
Tools --> Ant Libraries.
New library --> Name it Android.
Classpath --> Add JAR/Folder --> {SDK Folder}\platforms\android-16\android.jar
(in short find android.jar and use it's path, for me I'm using 16 version).
Javadoc --> Add ZIP/Folder --> {SDK Folder}\docs\references
(important note: you may get error in above step, so search will not work. To solve it, copy the file index.html inside [references folder] to a new file and called index-all.html. Then re-add the path in step 4).
Source: Here
Take a look at the Android Sources provided by adt-addons. This eclipse plugin will download all of the sources and attach them automatically.
If you aren't using Eclipse, you can still download the source zips from the jar at http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/plugins/
Extract the jar file and inside you'll find source zips for each platform revision. Attach these to your IDE.
Otherwise, you can check out the sources manually from git but this is a rather lengthy and arduous process to achieve the above.
You can download various javadocs from
http://www.jarvana.com/jarvana/browse/com/google/android/android/2.3.3/
Just drop the javadocs jar files to android-sdk-{macosx,windows,linux}/docs
Not sure what your setup is like, but the JavaDoc is stored in /docs/reference
For my setup I had to create a zip of that folder and add it as JavaDoc to the Android library.
If you use the nbandroidsupport plugin you can download the javadoc from Android SDK Manager, you can found the package in the latest android's API (in my case Android 5.1.1) the name of package is "Documentation for Android SDK".
Once you have installed the package restart your netbeans. In my case the javadoc is not showing sometimes pressing ctrl+space on the method therefore you can show the javadoc pressing ctrl+shift+space.
Note: this method applies to any API version.

Categories

Resources