Compatibility with different version of Android

Hello everybody,
I develop an application With Ionic 2 like ionic-conference.
When I test the application with différent version of android. I notice an error in a design application.
Test on Android 4.1.2


Test on Android 5.1.1

You can see a full code here

Install Crosswalk.

ionic plugin add cordova-plugin-crosswalk-webview

Hello thank you for your response.
After having entered this command. I had this probleme:

C:\mylab\TechForum2016>ionic plugin add cordova-plugin-crosswalk-webview
Fetching plugin "cordova-plugin-crosswalk-webview" via npm
Installing "cordova-plugin-crosswalk-webview" for android
Installing "cordova-plugin-crosswalk-webview" for ios
Running command: "C:\Program Files\nodejs\node.exe" C:\mylab\TechForum2016\hooks\after_plugin_add\010_register_plugin.js C:\mylab\TechForum2
016
Saving plugin to package.json file

C:\mylab\TechForum2016>ionic run android

Running 'run:before' gulp task before run
[15:01:35] Starting 'sass'...
[15:01:35] Starting 'html'...
[15:01:35] Starting 'fonts'...
[15:01:36] Finished 'html' after 863 ms
[15:01:36] Finished 'fonts' after 1.24 s
[15:01:40] Finished 'sass' after 4.4 s
[15:01:40] Starting 'build'...
Hash: b57c9b48e17d8c2cbdb8
Version: webpack 1.12.14
Time: 26023ms
        Asset    Size  Chunks             Chunk Names
app.bundle.js  2.9 MB       0  [emitted]  main
[15:02:07] Finished 'build' after 28 s
[15:02:07] Starting 'run:before'...
[15:02:07] Finished 'run:before' after 74 µs

Running command: "C:\Program Files\nodejs\node.exe" C:\mylab\TechForum2016\hooks\after_prepare\010_add_platform_class.js C:\mylab\TechForum2
016
add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe" C:\mylab\TechForum2016\hooks\after_prepare\020_remove_sass_from_platforms.js C:\mylab\Te
chForum2016
ANDROID_HOME=C:\Utilisateurs\A627290\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
No target specified, deploying to device '0146B5681401101C'.
null
embedded
org.xwalk:xwalk_core_library:17+


BUILD FAILED

Total time: 2 mins 47.589 secs
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugCompile'.
   > Could not resolve org.xwalk:xwalk_core_library:17+.
     Required by:
         :android:unspecified
      > Failed to list versions for org.xwalk:xwalk_core_library.
         > Unable to load Maven meta-data from https://repo1.maven.org/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml.
            > Could not GET 'https://repo1.maven.org/maven2/org/xwalk/xwalk_core_library/maven-metadata.xml'.
               > Connection to https://repo1.maven.org refused
      > Failed to list versions for org.xwalk:xwalk_core_library.
         > Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_libr
ary/maven-metadata.xml.
            > Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/maven-metadata
.xml'.
               > Connection to https://download.01.org refused

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
ERROR running one or more of the platforms: Error code 1 for command: cmd with args: /s,/c,"C:\mylab\TechForum2016\platforms\android\gradlew
 cdvBuildDebug -b C:\mylab\TechForum2016\platforms\android\build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true -Pandroid.useDeprecatedN
dk=true"
You may not have the required environment or OS to run this project

Remove the platform and add it back again?

The same probleme. But the commande ionic serve works.

A response please …

1 Like

ionic serve does not use Cordova plugins as it just runs in a web browser.

Read up about what Crosswalk is and why you should use it here.

The build process needs to download the Crosswalk library, which is what it looks like it is trying to do in your case but is failing.

thank you for your response. But I don’t want to have an apk with size ~ 20 MB. I just want to know why my application can worked with a version of android and the design change with other version

Older Android webviews are notorious for not rendering things properly. Which is why you use Crosswalk to ensure a consistent experience across all Android versions.

Different browser’s engine.

Hi there!

So there’s been a few comments already, but I thought I’d chime in an just give an official response.

While the app my “work” on android 4.1, not all the features may function as expected. Because the older android uses an older browser, they most likely do not support these new features in the framework. While it may sound disappointing, it’s important to look to the future and let these older OS fade away. The market share for 4.1 and 4.2 are starting to show this.

http://developer.android.com/about/dashboards/index.html

But if you still want to target the older device, which I can understand, the way going forward is to use crosswalk. While the app size increase may not be ideal, it’s necessary to make the older device work with the new web features.

2 Likes

hi ,
even for android kitkat , somethings are break , sometimes you have to click 2 times for a button (device test), or tabs navigation bar not showing up (device test and genymotion ) etc. many little things like this, especially when you start with tabs. can we consider kikat as an older version too? (27% of my app category use kikat)

app look great on android 5 and greater , thank guys for the jobs

2 Likes

Based on my experimentation, I found out that if you are deploying to any platform < 5.0 (sdk version 21), using x-walk is safer. I too did not want to use x-walk by default as it pumps up the app size to 30+MB

I use a script to build android in 3 modes:
a) An x86 build for < 5.0 phones (25+MB)
b) An ARM build for < 5.0 phones 25+MB)
c) A unified build for > 5.0 phones (9MB)
(I could have split part c into arm and x86, but the size was small enough not to bother)

Based on download stats, more than 80% of the users are on 5+ and are downloading the lighter build. So in my opinion, no need to mandatorily bundle x-walk while the native in-phone version may be more optimized for that platform.

I’m not a gulp/grunt expert, so I just wrote a shell script that builds all variants here https://github.com/pliablepixels/zmNinja/blob/master/build_android.sh

image

2 Likes

Is there a way to restrict downloads to only allow 5.0+?

Update

You can add <preference name="android-minSdkVersion" value="19" /> to the config.xml file. This should allow 4.4 and up.

Ref: https://developer.android.com/about/versions/android-4.4.html