App work in ios but doesn't work in android

Hi, i created 2 new projects this month, and everything is fine in ios, it works like a charm, but today when i tried to emulate the app in android studio, the app crash, right on the start i can’t even see the splashscreen. than i create a new project, and i didn’t change a thing, i did the build android command and launch the app on android studio, and everything was fine.
i tested with android 4.1, 4.4.4 and 5.0

right now i can ensure that the problem is not in the folder www of the ionic project

i’m gonna leave some information, if you need more please ask.

Cordova CLI: 5.4.1
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v4.2.4
Xcode version: Xcode 7.2.1 Build version 7C1002

android studio logs:
02-24 15:02:43.809 1882-1882/? I/dalvikvm: Could not find method android.webkit.CookieManager.flush, referenced from method org.apache.cordova.engine.SystemCookieManager.flush
02-24 15:02:43.809 1882-1882/? W/dalvikvm: VFY: unable to resolve virtual method 10534: Landroid/webkit/CookieManager;.flush ()V
02-24 15:02:43.809 1882-1882/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
02-24 15:02:43.809 1882-1882/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/ClientCertRequest;)
02-24 15:02:43.809 1882-1882/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/ClientCertRequest;)
02-24 15:02:43.809 1882-1882/? I/dalvikvm: Could not find method android.webkit.WebViewClient.onReceivedClientCertRequest, referenced from method org.apache.cordova.engine.SystemWebViewClient.onReceivedClientCertRequest
02-24 15:02:43.809 1882-1882/? W/dalvikvm: VFY: unable to resolve virtual method 10610: Landroid/webkit/WebViewClient;.onReceivedClientCertRequest (Landroid/webkit/WebView;Landroid/webkit/ClientCertRequest;)V
02-24 15:02:43.809 1882-1882/? D/dalvikvm: VFY: replacing opcode 0x6f at 0x001a
02-24 15:02:43.813 1882-1882/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/webkit/PermissionRequest;)
02-24 15:02:43.813 1882-1882/? I/dalvikvm: Could not find method android.webkit.PermissionRequest.getResources, referenced from method org.apache.cordova.engine.SystemWebChromeClient.onPermissionRequest
02-24 15:02:43.813 1882-1882/? W/dalvikvm: VFY: unable to resolve virtual method 10554: Landroid/webkit/PermissionRequest;.getResources ()[Ljava/lang/String;
02-24 15:02:43.813 1882-1882/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x000d
02-24 15:02:43.813 1882-1882/? I/dalvikvm: Could not find method android.webkit.WebChromeClient$FileChooserParams.createIntent, referenced from method org.apache.cordova.engine.SystemWebChromeClient.onShowFileChooser
02-24 15:02:43.813 1882-1882/? W/dalvikvm: VFY: unable to resolve virtual method 10559: Landroid/webkit/WebChromeClient$FileChooserParams;.createIntent ()Landroid/content/Intent;
02-24 15:02:43.813 1882-1882/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0000
02-24 15:02:43.813 1882-1882/? D/SystemWebViewEngine: CordovaWebView is running on device made by: Genymotion
02-24 15:02:43.813 1882-1882/? D/AndroidRuntime: Shutting down VM
02-24 15:02:43.813 1882-1882/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d3fb20)
02-24 15:02:43.813 1882-1882/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dogmasis.anteroChaves, PID: 1882
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dogmasis.anteroChaves/com.dogmasis.anteroChaves.MainActivity}: java.lang.NumberFormatException: Invalid long: "1.0"
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException: Invalid long: "1.0"
at java.lang.Long.invalidLong(Long.java:124)
at java.lang.Long.parse(Long.java:361)
at java.lang.Long.decode(Long.java:175)
at org.apache.cordova.CordovaPreferences.getInteger(CordovaPreferences.java:78)
at org.apache.cordova.splashscreen.SplashScreen.getFadeDuration(SplashScreen.java:120)
at org.apache.cordova.splashscreen.SplashScreen.showSplashScreen(SplashScreen.java:260)
at org.apache.cordova.splashscreen.SplashScreen.pluginInitialize(SplashScreen.java:103)
at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:55)
at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:95)
at org.apache.cordova.PluginManager.init(PluginManager.java:84)
at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:116)
at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:150)
at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:220)
at com.dogmasis.anteroChaves.MainActivity.onCreate(MainActivity.java:32)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
02-24 15:02:43.813 565-577/system_process W/ActivityManager: Force finishing activity com.dogmasis.anteroChaves/.MainActivity

Did you install android SDK

Yes, and i have everything installed from api 4.1 to 6,and the tools of course.

It seems to me the Ionic CLI can’t find the Android SDK. Please google about Android SDK and how to install it properly. You have to edit the PATH en ANDROID_HOME in your batch-environment.

ok i will do that, but can you tell me how did you get to that conclusion ?
i would like to understand that
and how it’s possible, that i removed android platform from the project that works, and then installed again using the commands platform add android and rm , and after this it still works, and the other 2 doesn’t and i did the same procedure ?

My first reply was based on the title of this topic. Your last suggestion seems to say you had it working. So you did have a porperly installed Android SDK.
Another thing, after reading your message: How do you emulate an Ionic app in Android Studio.
IMHO you cannot run an Ionic app in Android Studio.
As far as I know to emulate an Ionic App your emulate or run it from the terminal with:

sudo ionic emulate/run android

For emulate you need an Android simulator.
For run you need a real device connected to your PC.

ok, i think i’m not explaining myself the right way, let’s start over :slight_smile:
to keep it simple i have two projects, project A and B .
Project A it’s and old project.
Project B is a new project.
Both of them in browser and iOS works fine.
but in android studio project A works, but project B doesn’t.
Project B gives me an error that it’s written above, but the strange thing, is if i start a new project(Project C ) and open with android studio, it works.
i don’t believe that CLI is not finding Android SDK path, because if it was that, i couldn’t compile any project.

PS: thanks for the reply :slightly_smiling:

for me it is unusual to develop and run an Ionic project in Android Studio. As far as I know if you run it in Android Studio the app run in a browser. Thats is a nice feature of Ionic because so you have a quick way from develop to run in browser.
Running an Ionic app in a browser has nothing to do with Android SDK.
You need Android SDK to compile an Ionic app to build a package that can be run in a real Android Phone or Tablet. Or if you dont have a real device run in a simulator.

Maye you run, in Android Studio, the app with a wrong URL to the index.html file in your app.

Did you tried to run the Ionic app in the webserver from Ionic. In terminal got to your app folder and type: sudo ionic serve

thanks for the reply.
yes i can run the app in the browser by using ionic serve -l , no bugs found.
the process that i usually do is, create the project, develop the project in the browser using ionic serve -l and after that, i test in the real device, and for that i run the command ionic build android, and after i go to android studio and open the ionic project (with this i mean, i go to the folder “platform” and choose android and i open it with the android studio to test in an real device).

Found the bug. the bug was in config.xml file of ionic project.

The problema was in the value, it seems cordova-plugin-splashscreen 3.2.0 doesn’t accept a double value.
but cordova-plugin-splashscreen 3.0.0 accept .

and in project A i had cordova-plugin-splashscreen 3.0.0 and in the B i had cordova-plugin-splashscreen 3.2.0

Thanks for all the answers :slight_smile:

6 Likes

thanks you <3 <3 <3 <3

OMG! you saved my life with your answer!!! I was looking for solution during many hours!!

You save my day, thanks for this! 2019 :sweat_smile: