Software Archive
Read-only legacy content
17061 Discussions

Build Failed - using Android API 19 when Target is 22

Noah_S_
Beginner
2,124 Views

My project's Android target API version is 22, but my builds are failing because they are being built against API 19. Why is this? I'm somewhat new to Cordova, so am I missing something?

One of my third-party plugins requires Lollipop.

-pre-build:

-check-env:
 [checkenv] Android SDK Tools Revision 22.3.0
 [checkenv] Installed at /Developer/android-sdk-linux

-setup:
     [echo] Project Name: CordovaApp
  [gettype] Project Type: Application

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
     [echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target:   Android 4.4
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-build
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-build/res
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-build/rsObj
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-build/rsLibs
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-gen
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-build/classes
    [mkdir] Created dir: .../WebToAppMB/platforms/android/ant-build/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for CordovaApp...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'release'...

nodeps:

-set-mode-check:

-set-release-mode:

-release-obfuscation-check:
     [echo] proguard.config is ${proguard.config}

-pre-build:

-check-env:
 [checkenv] Android SDK Tools Revision 22.3.0
 [checkenv] Installed at /Developer/android-sdk-linux

-setup:
     [echo] Project Name: CordovaApp
  [gettype] Project Type: Android Library

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
     [echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target:   Android 4.4
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/res
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/libs
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-build
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-build/res
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-build/rsObj
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-build/rsLibs
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-gen
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-build/classes
    [mkdir] Created dir: .../WebToAppMB/platforms/android/CordovaLib/ant-build/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for CordovaApp...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------

 

0 Kudos
1 Solution
PaulF_IntelCorp
Employee
2,124 Views

Now I understand, that makes much more sense. A few questions:

  • Are you setting the desired target sdk level in the Build settings panel on the Projects tab? (your previous messages imply that is the case, but just want to be sure)
  • Are you building for Android or for Crosswalk? (I'm guessing Androd) If only one, have you tried the other and do you get similar results?
  • Which CLI version are you using? (I'm assuming you're using 4.1.2)

I was discussing this issue with one of the build engineers just last week, but we were concentrating on the Crosswalk builds and confirmed (or at least we believe we confirmed) that the Crosswalk build system honors that target SDK level. My test was against API level 21 on Crosswalk, which I confirmed by inspecting the resulting APK manifest, not by inspecting the build log...

---- EDIT ----

I just spoke with the build engineer and he confirmed that the maximum API level for the Android build system is currently 19 (we will get it updated, but it won't be pushed to production immediately, there are some other issues that still need testing and verification before the next push to production can happen). The current maximum API level for the Crosswalk build system is 21. Try your test using Crosswalk.

View solution in original post

0 Kudos
7 Replies
PaulF_IntelCorp
Employee
2,124 Views

I'll have to check with the build engineer to see if he has any insight.

BTW -- I'm assuming that you know that by specifying a target of API level 19 your app will only run on Android 4.4 and higher devices... Any devices lower than Android 4.4 will not be allowed to run your app.

0 Kudos
Noah_S_
Beginner
2,124 Views

Paul, thank you. I appreciate you looking into this. 

Actually, my target API is 22 and my minimum API is 14, so it should run on anything 14 or higher. I don't know where the 19 is coming from. 

<preference name="android-minSdkVersion" value="14"/>
<preference name="android-targetSdkVersion" value="22"/>

 

0 Kudos
Noah_S_
Beginner
2,124 Views

Can someone confirm that XDK's cloud building service supports Android API 22? I'm using a third-party plugin that requires me to build against Lollipop. 

I'd like to avoid Crosswalk, since this is a very small and simple app.

0 Kudos
PaulF_IntelCorp
Employee
2,124 Views

Okay, I missed the important "target" when I was looking at your log. The versions and version code fields on the build settings page are confusing. Here's some help (following the links for more details):

App Version is a version string that is displayed to users of your app. This string is not used by the Android store, it is strictly for use by your app.

App Version Code is an integer that increases to indicate newer releases. This number is used by the Android store to signal an update to your app.

Minimum Android Version specifies the minimum Android API level supported by your app. API level 10 or 14 is recommended for Android builds and API level 14 is recommended for Crosswalk builds.

Target Android Version specifies the tested or maximum "safe" Android API level supported by your app. API level 19 is recommended for Android and Crosswalk builds.

The "target" version is difficult to know what to choose, especially given that the web runtime behavior and affected APIs are hard to pin down (the webview is effectively a giant black box). My experience has been that specifying 19 for the target version, when building webview apps (which is what Corodova apps are), is the safest choice. This does not mean that your apps will not run on devices above Android 4.4 (which equals API level 19), but that "compatibility" layers will be inserted when run on devices of a higher version than 4.4.

See this link for more details on what these "compatibility" layers mean: http://developer.android.com/reference/android/os/Build.VERSION_CODES.html -- specifying a target version less than 19 (e.g., 18 or less) has a dramatic impact on the behavior of webview apps that run on Android 4.4 and above. The behavior changes above 19 seems to be less relevant to webview apps, but there may be plugin dependencies, so it is impossible to make a hard statement that "this value is best or right and all other values are wrong."

 

That said, I'm guessing there is something else that is causing your build to fail... Can you attach the entire detailed build log (please attach it as a file to your post, do not paste it into your post).

0 Kudos
Noah_S_
Beginner
2,124 Views

Paul, thank you for that explanation. I understand these Android parameters (I am an Android developer).  I understand that apps built for API 19 should work with higher APIs, but one of my third-party plugins must be built against API 21 or higher because its Java code contains references introduced in the 21 SDK.  

I have attached the full build log, but here is the part I believe is relevant. 

-compile:
    [javac] Compiling 12 source files to .../WebToAppMB/platforms/android/ant-build/classes
    [javac] .../WebToAppMB/platforms/android/src/com/initialxy/cordova/themeablebrowser/ThemeableBrowser.java:985: cannot find symbol
    [javac] symbol  : variable LOLLIPOP
    [javac] location: class android.os.Build.VERSION_CODES
    [javac]             if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    [javac]                                                            ^
    [javac] .../WebToAppMB/platforms/android/src/com/initialxy/cordova/themeablebrowser/ThemeableBrowser.java:988: getDrawable(int) in android.content.res.Resources cannot be applied to (int,android.content.res.Resources.Theme)
    [javac]                 result = activityRes.getDrawable(id, cordova.getActivity().getTheme());
    [javac]                                     ^
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: .../WebToAppMB/platforms/android/src/com/initialxy/cordova/themeablebrowser/ThemeableBrowser.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 2 errors

The value "Build.VERSION_CODES.LOLLIPOP" was not defined until API 21. Therefore, building against API 19 will not work with this plugin, as the 19 SDK doesn't know how to resolve this value.  

Although I set my target API to 22 in XDK, it is still using build tools from 19, as shown by this build log excerpt.

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
     [echo] Resolving Build Target for CordovaApp...
[gettarget] Project Target:   Android 4.4
[gettarget] API level:        19

 

0 Kudos
PaulF_IntelCorp
Employee
2,125 Views

Now I understand, that makes much more sense. A few questions:

  • Are you setting the desired target sdk level in the Build settings panel on the Projects tab? (your previous messages imply that is the case, but just want to be sure)
  • Are you building for Android or for Crosswalk? (I'm guessing Androd) If only one, have you tried the other and do you get similar results?
  • Which CLI version are you using? (I'm assuming you're using 4.1.2)

I was discussing this issue with one of the build engineers just last week, but we were concentrating on the Crosswalk builds and confirmed (or at least we believe we confirmed) that the Crosswalk build system honors that target SDK level. My test was against API level 21 on Crosswalk, which I confirmed by inspecting the resulting APK manifest, not by inspecting the build log...

---- EDIT ----

I just spoke with the build engineer and he confirmed that the maximum API level for the Android build system is currently 19 (we will get it updated, but it won't be pushed to production immediately, there are some other issues that still need testing and verification before the next push to production can happen). The current maximum API level for the Crosswalk build system is 21. Try your test using Crosswalk.

0 Kudos
Noah_S_
Beginner
2,124 Views

To answer your questions,

  • I did set the targed sdk level to 22 on the Projects tab and confirmed the level int he xml config.
  • I'm building for Android, not Crosswalk.
  • Using CLI 4.1.2

It sounds like the situation is as I feared--I will probably have to look to other services to help me with this project. (Crosswalk works, but this is a very small and simple project and doesn't merit the overhead.)

However, you have provided premium service and I greatly look forward to returning to development with XDK when these issues are resolved. Thank you very much and I hope this helps any others with similar issues. Cheers.

0 Kudos
Reply