app works fine in iOS but Android error: unfortunately app has stopped before it loads

  • 1
  • Question
  • Updated 4 years ago
I've tested my app on iOS devices and works fine. I am now testing on Android. I downloaded the app to my device and it installs fine but when I try to open I get an immediate error - unfortunately (name of app) has stopped. I have no idea what could be causing this - Android version 5.0.1, LG G Pad F 7.0
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. Remove the 'feature' elements from your config
2. Don't use the old, deprecated plugins from the pgb repo. Instead, use the latest versions from npm. Be aware that they are named differently, mostly something like 'cordova-plugin-xxxx'
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
I have made the changes suggested but still receive the error message
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
If your zip file is publicly available somewhere, please post its url and I'll be happy to have a look.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
You can download the zip here: http://kjrwebdesigns.com/GCPC/GCPC.zip
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Here's some feedback:

1. You are attempting to include plugins from the pgb repo, which don't exist under that name. Make sure you use npm as plugin source. In your case, the easiest way is to use the plugin element from the default namespace, not from the gap: namespace.

2. You should have both index.html and config.xml in the root ("/") of your zip file, not in some directory called /GCPC. In your case, it would be easiest to simply zip up the CONTENTS of that directory, not the directory itself.

3. If the above still doesn't solve the problem, you may have to isolate the issue by removing suspect parts for test purposes (like the WOW slider, or the script part that adds the iOS7 class)

4. The 'access origin' rule in your config won't be of any use without the whitelist plugin from npm. You need to include that plugin (cordova-plugin-whitelist) and apply its documentation.
Side note: I haven't seen any functionality that requires whitelisting, though.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
I am working on your suggestions. I would like to clarify a few things

1. my config is now set up as per the instructions found on the Phonegap Blog post titled: config.xml gets an update - part 2 !!!!!!
by @brettrudd | 19 Nov 2015 | PhoneGap Build Blog

Plugins in config.xml are set up as such:

(all plugins are listed on the npm site)

according to the blog it states: source attribute, if present, will always be obeyed, but default to the npmjs.org repository. This attribute is ignored in the Cordova cli and npm will always be the default.

I had no errors when I changed the config to the above in phonegap build.
However, the app still does not load in Android. Is there is there something else I should be doing to make sure it is defaulting to npm?

2. I'm working on this

3. Haven't eliminated the above, yet.

4. Since you saw no functionality that requires white listing, should I delete the access origin rule?

New questions

I see a lot of info referencing android manifest xml - which I do not have. Does Phonegap Build provide that int he build?

Is phonegap.js sufficient or do I also need to inlcude cordova.js on html pages?
Phonegap Build states they are interchangeable.

Thanks

Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. Is there is there something else I should be doing to make sure it is defaulting to npm?
No. This should do. You can always check at the plugins tab of your PGB app page.

2. I'm working on this
There is nothing to work on. Just zip up the contents of your main directory. It's the most likely cause of your trouble.

3. Haven't eliminated the above, yet.
Ah. %-/

4. Since you saw no functionality that requires white listing, should I delete the access origin rule?
I haven't checked your full app, because it's a large package. Maybe you do have some functionality that requires whitelisting. You should know, because you're the app's programmer.
I would leave it as is, and also add
<allow-navigation href="*" />
(You may want to restrict this to sources you retrieve code from)

N1. android manifest xml
You are apparently reading the wrong documentation. Developers who are using PGB don't include an androidManifest.xml or info.plist
It's generated by PGB.

N2. Is phonegap.js sufficient or do I also need to inlcude cordova.js on html pages? Phonegap Build states they are interchangeable.
You need eiher one.
Whatever Phonegap says, or other people claim, phonegap.js and cordova.js are NOT identical. The difference shows when you have multiple html files that have references to this file, of which some are in subdirectories. In such cases, only cordova.js will find the generated plugins.xml file. Phonegap.js won't find it.
I recommend to always reference cordova.js exclusively.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
2. evidently there is something more to it. I have zipped only the files and sub-folders and get the same result.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Do you at least get to see the splashscreen? Or not even that?
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
Nope - no splash. It downloads, installs and immediately shows the error. The icon loads on apps but that's it.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Could you please give me a link to your latest zip? I'll be happy to have another look (although I'll be on the road in 20 minutes).
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
By any chance is a signing key required before it will work directly on device? I'm running out of ideas.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
For an Android debug version, no. For a release version, yes.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
No problem, I posted it to my server again. You can download the zip here: http://kjrwebdesigns.com/GCPC/gcpc.zip
I also posted the apk file if you wan't to try it out.
http://kjrwebdesigns.com/GCPC/GraceCo... (2).apk
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
1. You have res/icon/android/icon-144-xxhdpi.png as splash for xxhdpi. Is that correct?

2. If you correct that, and it still doesn't start, just make a very simple app (index.html with just a text 'Hello', nothing else) and retry. That way, you can check if it is something in your index or if the error is to be found somewhere else.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
I didn't catch that - good eye - I'll give that a try.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
I started removing items from the config file one by one with no different result, so I switched to an older version of phonegap (3.3.0) and it now works. Do you know what the major difference between the two versions that would cause this problem? Or would it be something to do with the device itself? Again iOS devices worked fine with both versions.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I started removing items from the config file one by one
Your latest config was fine, so this step is not very useful.
I suggested you make a very simple HelloWorld index.html without all fancy scripts you have in your real index.html in order to see if the index is indeed where to look for the trouble.

Do you know what the major difference between the two versions...
Well, PGB3.3.0 is old, doesn't pick up the new npm plugins, and it's insecure, so Google won't accept apps built with PGB3.3.0 anymore.
Trying PGB3.3.0 is really a waste of time.

It would probably be more useful to try cli-6.0.0 instead, especially if you are using the plugins from npm without setting the plugin version (defaulting to the latest version).
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
Follow up on what I just posted. I am now adding the plugins, etc. back into the build and I get an error only on Android build which states:

Error - Some official plugins have to be updated if using PhoneGap >= 4.0.0. Please upgrade the version of any plugins that may include the following file: InAppBrowser.java - You can fix this here

As far as I know, I was using the most recent version of the plugins. Which was found on this page: https://www.npmjs.com/package/cordova...
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Do you still have the spec attributes in your config?
If so, you might not have the latest version with
<plugin name="cordova-plugin-inappbrowser" spec="~1"/>

Before you do, please check at your app's page plugin tab if you have the inappbrowser plugin with status 1.3.0
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
yes that LP is the app that is version 1.3.0
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
FYI, before I changed the config file I did try the parred down version - removed the slider, only uploaded the index file but still included the jquery mobile files and didn't work. I don't know what is considered "fancy scripts" please elucidate...
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
This is still an unresolved problem for me. Again iOS works like a dream no matter what I do but Android still has major problems. I have tested by removing pages, javascript, all plugins, splash screens (Android only) and slowly added them back in. I Have also tested different phonegap versions - starting with 3.0.0 - I have gotten the app to work on my Android devices - all pages, all "fancy scripts", all images all splash pages up to version 3.5.0. When I try version 3.6.3 and higher to the current 6.0.0 the app installs but immediately gives the message the app has stopped. Switch it back to 3.5.0 works fine. I now am adding back plugins to the config.xml file - I think I can get by with just geolocation and inapp browser plugins. Geolocation plugin works fine. inapp browser gets the same error mentioned above about about 4.0.0. Please upgrade the version of any plugins that may include the following file: InAppBrowser.java

I have tried all of the suggested configurations from the phonegap blog:

I have also included the full version 1.3.0.

I am at a loss on this one. I have read the different boards on the subject and nothing works for this plugin.

Is there any insight on why an app would work fine on older version of PGB and not the newer ones? And why the inapp browser plugin doesn't work for Android?
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Kathy
I try not to break in when Petra has started to respond to a thread. Petra gets testy. I do too at times.

I can see part of you problem of your issue is you are using an outdate boilerplate or template. This have given you the wrong reference. Unfortunately, several people on this forum try to fix the that issue and not tell a person they have the wrong reference. In short, they assume the other person is as smart as them and has read the same things as them. I am guilty of the same bad judgement.

YOUR NEW START
Read the bold sentences in this FAQ. Then come back.

This FAQ should also help.
Top Mistakes by Developers new to Cordova/Phonegap

Jesse
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
Yes, I understand I am not as "smart" as you on the subject, as this is my first app and this is a learning process for me. I have already noticed the condescending tone in some posts. The docs I have been reading are on the Adobe Phonegap Build site - or that's where the links are.
I'm not sure what you mean by outdated boilerplate or template as I have not downloaded and had not visited the link in the FAQ to them on github. Does this refer to the config.xml file? Again, I used the instructions on the Adobe Phonegap Build site and the Blog with the new config.xml instructions. Please clarify- template/boilerplate.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
Also the config file at top is outdated.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
In your index.html you have further errors:

1. <link rel="stylesheet" type="text/css" href="themes/GCPC-new.min.css"> is coded twice

2. <link href="gracetheme.min.css" rel="stylesheet" type="text/css" >
File doesn't exist in your assets at the root

3. <link href="GCPC2.min.css" rel="stylesheet" type="text/css" >
File doesn't exist in your assets at the root

4. After loading jQuery 1.8.3 first, you later load
<script type="text/javascript" src="engine1/jquery.js"></script>
which is jQuery 1.11.2
You can't have two jQuery versions loaded, and certainly not two versions that far apart.
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
I do not have two jquery versions loaded - if you take a closer look - it is jquery and jquery.mobile - not the same.
I did see that the style sheets were incorrectly directed - I moved them into a folder and Dreamweaver did not update the change. Don't know why.
Even with these problems corrected, builds using anything higher than 3.5.0 do not work on Android (downloads, installs, but on open it immediately gets the stopped error). I have not added back the inapp browser to the config file since I can't get it to work with the lower versions of pgb. So, in other words, the above is not the problem.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I do not have two jquery versions loaded - if you take a closer look - it is jquery and jquery.mobile - not the same.
No. You have several jQM versions in your assets. Of them, you reference jQM1.4.5

However, you really use two versions of jQuery in your index.html. Take a closer look!
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
I do see that there is a newer version in the engine1 folder - however, I did test the app without the Wow Slider and the engine1 data1 folders almost three weeks ago, which I mentioned in a much earlier post and found the app still had the same problem. This is clearly not the issue causing the app to stop. Another question, what is the lowest PGB version Google Play accepts ?- I cannot find it mentioned anywhere.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
That's PGB3.6.1 now (perhaps even PGB3.5.0, but not 100% sure), and PGBcli-5.2.0 starting May 9, 2016.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Kathy
Yes, the website has quite a few templates. "Hello World" is one template. Often the new material gets mixed with the old material and it becomes confusing for people. There is no clear path through the documentation.

Another stumbling block for developers is that Phonegap alludes that "if you can build a webpage, you can build an app". That is not so true. It is true those skills are need and nececsary, but other factors come into play.

If you have ever created a website, then the process is similar - except there is no webserver. This means that files are only loaded from the webpage - there are no server services, perse. So think like a website and your index.html will load correctly.

On the config.xml, start with the least number of items you can, then add. This has two side effects. 1) it is easier to see things and fix things 2) you will add those things you removed later.

One note on config.xml - you can remove all references to icons and splash pages until you are ready. When you build, Phonegap will add it's own icons. This will allow you to develop without being distracted by why this thing (icons) is in the way.

Here is the boilerplate I show people. It builds without issues. Your are free to use it. The Tutorial is included:
An HTML Boilerplate for Phonegap

Lastly, my hope is that this will help you on your path to create your app.

FWIW: I've been guilty of "condescending tone".

Jesse
Photo of Kathy Roberts

Kathy Roberts

  • 33 Posts
  • 0 Reply Likes
OK. I'm about to give up on this. Truly frustrated. Is there not some way to test the app to see if there are errors on my device. Is this a device specific problem or an overall Android problem?
I get no errors on build if I use the most recent version of PGB but the app immediately stops on Android. If I use the older version of PGB and remove the inappbrowser plugin the app works on Android devices. If I add the plugin back in I get the annoying Error - Some official plugins have to be updated if using PhoneGap >= 4.0.0. Please upgrade the version of any plugins that may include the following file: InAppBrowser.java - You can fix this here
Yes, I am using the most recent version. Yes, I have read the blogs and included the latest version from NPM. Same error. So, I can either have the build work and the app not or have the app work but the plugin not work. And there is no answer for why it works on older versions of PGB and not the new one. I have validated my config.xml file and it passes. The app is still fully functional on iOS devices no matter what version of pgb is used. Is it possible to clarify in config.xml to use one version of a plugin for android and another for iOS? Or only use it for iOS? This is not an ideal work around but at least the app would function to a point. FYI, I have already specified different pgb version in config.xml for iOS and Android.