Installing APK says "There was a problem parsing the package"


#1

Our APK build, which has been working great for the past couple years, suddenly started failing a few days ago.

It would appear that now, in order to make the APK build happy, android-minSdkVersion must be equal to a mystical number that is both >= 26 and at the same time < 26.

To be precise…

First, we had this:

  Building Cordova app for Android          /
:compileReleaseSourcesp for Android          /
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
7 errors; aborting
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithPreDexForRelease'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/home/mad/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.13.1/b49cf3799bd473199e96c4fb9987e9e08395a1c0/okhttp-3.13.1.jar' to '/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/build/intermediates/transforms/preDex/release/13.jar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 27s
39 actionable tasks: 39 executed
%% Command finished with error code 1: /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/gradlew cdvBuildRelease,-b,/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true
=> Errors executing Cordova commands:         
                                              
   While building Cordova app for platform Android:
   Error: /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/gradlew: Command failed with exit code 1
   Error output:
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use unchecked or unsafe operations.
   Note: Recompile with -Xlint:unchecked for details.
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   Uncaught translation error: com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires
   --min-sdk-version >= 26)
   7 errors; aborting
   
   FAILURE: Build failed with an exception.
   
   * What went wrong:
   Execution failed for task ':transformClassesWithPreDexForRelease'.
   > com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable
   to pre-dex
   '/home/mad/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.13.1/b49cf3799bd473199e96c4fb9987e9e08395a1c0/okhttp-3.13.1.jar'
   to
   '/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/build/intermediates/transforms/preDex/release/13.jar'
   
   * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
   
   * Get more help at https://help.gradle.org
   
   BUILD FAILED in 27s
   at ChildProcess.whenDone
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
   at emitTwo (events.js:126:13)
   at ChildProcess.emit (events.js:214:7)
   at maybeClose (internal/child_process.js:925:16)
   at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
./build-android.sh: line 85: cd: /home/mad/spoticle-build/android/project/build/outputs/apk/release: No such file or directory

It seems that our APK build is somehow depenendant on the good will of Google, and they decided to break something. So, we changed the “android-minSdkVersion” property from 19 to 26 in mobile-config.js, thusly:

App.setPreference("android-minSdkVersion", "26");

and…

BUILD SUCCESSFUL

Great. The build now works again, like it did a few days ago.

So, full of hope, we go to install this new APK, only to be greeted with a cheerful dialog informing us:

Parse Error

There was a problem parsing the package.

OK

No, not really OK. We have nowhere to go from here.

So, what broke???

EDIT:

Attempting to run on device also fails, but gives this somewhat useful output:

=> Errors executing Cordova commands:         
                                              
   While running Cordova app for platform Android with options --device:
   Error: Command failed: /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/run --device
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use or override a deprecated API.
   Note: Recompile with -Xlint:deprecation for details.
   Note: Some input files use unchecked or unsafe operations.
   Note: Recompile with -Xlint:unchecked for details.
   { CordovaError: Failed to install apk to device: [  0%] /data/local/tmp/android-debug.apk
   [  1%] /data/local/tmp/android-debug.apk
   [  1%] /data/local/tmp/android-debug.apk
   [  2%] /data/local/tmp/android-debug.apk
   [  2%] /data/local/tmp/android-debug.apk
   [  3%] /data/local/tmp/android-debug.apk
   [  4%] /data/local/tmp/android-debug.apk
   [  4%] /data/local/tmp/android-debug.apk
   [  5%] /data/local/tmp/android-debug.apk
   [  5%] /data/local/tmp/android-debug.apk
   [  6%] /data/local/tmp/android-debug.apk
   [  7%] /data/local/tmp/android-debug.apk
   [  7%] /data/local/tmp/android-debug.apk
   [  8%] /data/local/tmp/android-debug.apk
   [  8%] /data/local/tmp/android-debug.apk
   [  9%] /data/local/tmp/android-debug.apk
   [  9%] /data/local/tmp/android-debug.apk
   [ 10%] /data/local/tmp/android-debug.apk
   [ 11%] /data/local/tmp/android-debug.apk
   [ 11%] /data/local/tmp/android-debug.apk
   [ 12%] /data/local/tmp/android-debug.apk
   [ 12%] /data/local/tmp/android-debug.apk
   [ 13%] /data/local/tmp/android-debug.apk
   [ 14%] /data/local/tmp/android-debug.apk
   [ 14%] /data/local/tmp/android-debug.apk
   [ 15%] /data/local/tmp/android-debug.apk
   [ 15%] /data/local/tmp/android-debug.apk
   [ 16%] /data/local/tmp/android-debug.apk
   [ 16%] /data/local/tmp/android-debug.apk
   [ 17%] /data/local/tmp/android-debug.apk
   [ 18%] /data/local/tmp/android-debug.apk
   [ 18%] /data/local/tmp/android-debug.apk
   [ 19%] /data/local/tmp/android-debug.apk
   [ 19%] /data/local/tmp/android-debug.apk
   [ 20%] /data/local/tmp/android-debug.apk
   [ 21%] /data/local/tmp/android-debug.apk
   [ 21%] /data/local/tmp/android-debug.apk
   [ 22%] /data/local/tmp/android-debug.apk
   [ 22%] /data/local/tmp/android-debug.apk
   [ 23%] /data/local/tmp/android-debug.apk
   [ 23%] /data/local/tmp/android-debug.apk
   [ 24%] /data/local/tmp/android-debug.apk
   [ 25%] /data/local/tmp/android-debug.apk
   [ 25%] /data/local/tmp/android-debug.apk
   [ 26%] /data/local/tmp/android-debug.apk
   [ 26%] /data/local/tmp/android-debug.apk
   [ 27%] /data/local/tmp/android-debug.apk
   [ 28%] /data/local/tmp/android-debug.apk
   [ 28%] /data/local/tmp/android-debug.apk
   [ 29%] /data/local/tmp/android-debug.apk
   [ 29%] /data/local/tmp/android-debug.apk
   [ 30%] /data/local/tmp/android-debug.apk
   [ 30%] /data/local/tmp/android-debug.apk
   [ 31%] /data/local/tmp/android-debug.apk
   [ 32%] /data/local/tmp/android-debug.apk
   [ 32%] /data/local/tmp/android-debug.apk
   [ 33%] /data/local/tmp/android-debug.apk
   [ 33%] /data/local/tmp/android-debug.apk
   [ 34%] /data/local/tmp/android-debug.apk
   [ 35%] /data/local/tmp/android-debug.apk
   [ 35%] /data/local/tmp/android-debug.apk
   [ 36%] /data/local/tmp/android-debug.apk
   [ 36%] /data/local/tmp/android-debug.apk
   [ 37%] /data/local/tmp/android-debug.apk
   [ 37%] /data/local/tmp/android-debug.apk
   [ 38%] /data/local/tmp/android-debug.apk
   [ 39%] /data/local/tmp/android-debug.apk
   [ 39%] /data/local/tmp/android-debug.apk
   [ 40%] /data/local/tmp/android-debug.apk
   [ 40%] /data/local/tmp/android-debug.apk
   [ 41%] /data/local/tmp/android-debug.apk
   [ 42%] /data/local/tmp/android-debug.apk
   [ 42%] /data/local/tmp/android-debug.apk
   [ 43%] /data/local/tmp/android-debug.apk
   [ 43%] /data/local/tmp/android-debug.apk
   [ 44%] /data/local/tmp/android-debug.apk
   [ 44%] /data/local/tmp/android-debug.apk
   [ 45%] /data/local/tmp/android-debug.apk
   [ 46%] /data/local/tmp/android-debug.apk
   [ 46%] /data/local/tmp/android-debug.apk
   [ 47%] /data/local/tmp/android-debug.apk
   [ 47%] /data/local/tmp/android-debug.apk
   [ 48%] /data/local/tmp/android-debug.apk
   [ 49%] /data/local/tmp/android-debug.apk
   [ 49%] /data/local/tmp/android-debug.apk
   [ 50%] /data/local/tmp/android-debug.apk
   [ 50%] /data/local/tmp/android-debug.apk
   [ 51%] /data/local/tmp/android-debug.apk
   [ 51%] /data/local/tmp/android-debug.apk
   [ 52%] /data/local/tmp/android-debug.apk
   [ 53%] /data/local/tmp/android-debug.apk
   [ 53%] /data/local/tmp/android-debug.apk
   [ 54%] /data/local/tmp/android-debug.apk
   [ 54%] /data/local/tmp/android-debug.apk
   [ 55%] /data/local/tmp/android-debug.apk
   [ 56%] /data/local/tmp/android-debug.apk
   [ 56%] /data/local/tmp/android-debug.apk
   [ 57%] /data/local/tmp/android-debug.apk
   [ 57%] /data/local/tmp/android-debug.apk
   [ 58%] /data/local/tmp/android-debug.apk
   [ 58%] /data/local/tmp/android-debug.apk
   [ 59%] /data/local/tmp/android-debug.apk
   [ 60%] /data/local/tmp/android-debug.apk
   [ 60%] /data/local/tmp/android-debug.apk
   [ 61%] /data/local/tmp/android-debug.apk
   [ 61%] /data/local/tmp/android-debug.apk
   [ 62%] /data/local/tmp/android-debug.apk
   [ 63%] /data/local/tmp/android-debug.apk
   [ 63%] /data/local/tmp/android-debug.apk
   [ 64%] /data/local/tmp/android-debug.apk
   [ 64%] /data/local/tmp/android-debug.apk
   [ 65%] /data/local/tmp/android-debug.apk
   [ 65%] /data/local/tmp/android-debug.apk
   [ 66%] /data/local/tmp/android-debug.apk
   [ 67%] /data/local/tmp/android-debug.apk
   [ 67%] /data/local/tmp/android-debug.apk
   [ 68%] /data/local/tmp/android-debug.apk
   [ 68%] /data/local/tmp/android-debug.apk
   [ 69%] /data/local/tmp/android-debug.apk
   [ 70%] /data/local/tmp/android-debug.apk
   [ 70%] /data/local/tmp/android-debug.apk
   [ 71%] /data/local/tmp/android-debug.apk
   [ 71%] /data/local/tmp/android-debug.apk
   [ 72%] /data/local/tmp/android-debug.apk
   [ 72%] /data/local/tmp/android-debug.apk
   [ 73%] /data/local/tmp/android-debug.apk
   [ 74%] /data/local/tmp/android-debug.apk
   [ 74%] /data/local/tmp/android-debug.apk
   [ 75%] /data/local/tmp/android-debug.apk
   [ 75%] /data/local/tmp/android-debug.apk
   [ 76%] /data/local/tmp/android-debug.apk
   [ 77%] /data/local/tmp/android-debug.apk
   [ 77%] /data/local/tmp/android-debug.apk
   [ 78%] /data/local/tmp/android-debug.apk
   [ 78%] /data/local/tmp/android-debug.apk
   [ 79%] /data/local/tmp/android-debug.apk
   [ 79%] /data/local/tmp/android-debug.apk
   [ 80%] /data/local/tmp/android-debug.apk
   [ 81%] /data/local/tmp/android-debug.apk
   [ 81%] /data/local/tmp/android-debug.apk
   [ 82%] /data/local/tmp/android-debug.apk
   [ 82%] /data/local/tmp/android-debug.apk
   [ 83%] /data/local/tmp/android-debug.apk
   [ 84%] /data/local/tmp/android-debug.apk
   [ 84%] /data/local/tmp/android-debug.apk
   [ 85%] /data/local/tmp/android-debug.apk
   [ 85%] /data/local/tmp/android-debug.apk
   [ 86%] /data/local/tmp/android-debug.apk
   [ 87%] /data/local/tmp/android-debug.apk
   [ 87%] /data/local/tmp/android-debug.apk
   [ 88%] /data/local/tmp/android-debug.apk
   [ 88%] /data/local/tmp/android-debug.apk
   [ 89%] /data/local/tmp/android-debug.apk
   [ 89%] /data/local/tmp/android-debug.apk
   [ 90%] /data/local/tmp/android-debug.apk
   [ 91%] /data/local/tmp/android-debug.apk
   [ 91%] /data/local/tmp/android-debug.apk
   [ 92%] /data/local/tmp/android-debug.apk
   [ 92%] /data/local/tmp/android-debug.apk
   [ 93%] /data/local/tmp/android-debug.apk
   [ 94%] /data/local/tmp/android-debug.apk
   [ 94%] /data/local/tmp/android-debug.apk
   [ 95%] /data/local/tmp/android-debug.apk
   [ 95%] /data/local/tmp/android-debug.apk
   [ 96%] /data/local/tmp/android-debug.apk
   [ 96%] /data/local/tmp/android-debug.apk
   [ 97%] /data/local/tmp/android-debug.apk
   [ 98%] /data/local/tmp/android-debug.apk
   [ 98%] /data/local/tmp/android-debug.apk
   [ 99%] /data/local/tmp/android-debug.apk
   [ 99%] /data/local/tmp/android-debug.apk
   [100%] /data/local/tmp/android-debug.apk
   /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/build/outputs/apk/debug/android-debug.apk: 1
   file pushed. 2.7 MB/s (11222519 bytes in 3.920s)
   pkg: /data/local/tmp/android-debug.apk
   Failure [INSTALL_FAILED_OLDER_SDK]
   at /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/lib/Adb.js:73:29
   at _fulfilled
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:854:54)
   at self.promiseDispatch.done
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:883:30)
   at Promise.promise.promiseDispatch
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:816:13)
   at /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:624:44
   at runSingle
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:137:13)
   at flush
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:125:13)
   at _combinedTickCallback (internal/process/next_tick.js:131:7)
   at process._tickCallback (internal/process/next_tick.js:180:9)
   name: 'CordovaError',
   message: 'Failed to install apk to device: [  0%] /data/local/tmp/android-debug.apk\n[  1%]
   /data/local/tmp/android-debug.apk\n[  1%] /data/local/tmp/android-debug.apk\n[  2%]
   /data/local/tmp/android-debug.apk\n[  2%] /data/local/tmp/android-debug.apk\n[  3%]
...
   /data/local/tmp/android-debug.apk\n[ 97%] /data/local/tmp/android-debug.apk\n[ 98%]
   /data/local/tmp/android-debug.apk\n[ 98%] /data/local/tmp/android-debug.apk\n[ 99%]
   /data/local/tmp/android-debug.apk\n[ 99%] /data/local/tmp/android-debug.apk\n[100%]
   /data/local/tmp/android-debug.apk\n/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/build/outputs/apk/debug/android-debug.apk:
   1 file pushed. 2.7 MB/s (11222519 bytes in 3.920s)\n\tpkg: /data/local/tmp/android-debug.apk\r\nFailure
   [INSTALL_FAILED_OLDER_SDK]',
   code: 0,
   context: undefined } 'CordovaError: Failed to install apk to device: [  0%] /data/local/tmp/android-debug.apk\n[
   1%] /data/local/tmp/android-debug.apk\n[  1%] /data/local/tmp/android-debug.apk\n[  2%]
   /data/local/tmp/android-debug.apk\n[  2%] /data/local/tmp/android-debug.apk\n[  3%]
....
   /data/local/tmp/android-debug.apk\n[ 96%] /data/local/tmp/android-debug.apk\n[ 96%]
   /data/local/tmp/android-debug.apk\n[ 97%] /data/local/tmp/android-debug.apk\n[ 98%]
   /data/local/tmp/android-debug.apk\n[ 98%] /data/local/tmp/android-debug.apk\n[ 99%]
   /data/local/tmp/android-debug.apk\n[ 99%] /data/local/tmp/android-debug.apk\n[100%]
   /data/local/tmp/android-debug.apk\n/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/build/outputs/apk/debug/android-debug.apk:
   1 file pushed. 2.7 MB/s (11222519 bytes in 3.920s)\n\tpkg: /data/local/tmp/android-debug.apk\r\nFailure
   [INSTALL_FAILED_OLDER_SDK]\n    at
   /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/lib/Adb.js:73:29\n    at _fulfilled
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:854:54)\n    at
   self.promiseDispatch.done
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:883:30)\n    at
   Promise.promise.promiseDispatch
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:816:13)\n    at
   /home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:624:44\n    at
   runSingle
   (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:137:13)\n    at
   flush (/home/mad/git/spoticle/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:125:13)\n
   at _combinedTickCallback (internal/process/next_tick.js:131:7)\n    at process._tickCallback
   (internal/process/next_tick.js:180:9)'
   at ChildProcess.exitCallback (/tools/utils/processes.js:151:23)
   at emitTwo (events.js:126:13)
   at ChildProcess.emit (events.js:214:7)
   at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

/home/mad/.meteor/packages/coffeescript/.1.0.17.1rcqxve.044w++os+web.browser+web.cordova/plugin.compileCoffeescript.os/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:116
      throw error;
      ^
ExitWithCode:1

So, it would seem that the min SDK version 26 also no good?


How to upgrade android Build tools in meteor?
#2

What meteor version are you using?


#3

1.8.0.1 and 1.8.0.2

I created a test project and started adding pieces to it from our project bit by bit, trying to get it to break
and finally… I found my culprit. This thing:

uk.co.workingedge.phonegap.plugin.launchnavigator

So I tried upgrading from the 4.0.7 version we were using to the current version, 5.0.2. This also fails, but with at least a good explanation:

Failed to install ‘uk.co.workingedge.phonegap.plugin.launchnavigator’: Error: Variable(s) missing: GOOGLE_API_KEY_FOR_ANDROID

So, I add to mobile-config.js:

App.configurePlugin("uk.co.workingedge.phonegap.plugin.launchnavigator", {
	GOOGLE_API_KEY_FOR_ANDROID : "<our API key>"
});

and… this configuration is cheerfully ignored.

So, that is the state of things this morning.

None of this answers the mystery of how a build that has been working for years can suddenly break over night.


#4

Try asking in the plugin github page.

Is it possible that Google did something like changing an API?


#5

Well, the build finally changed its mind (for no identifiable reason) about ignoring my mobile-config.js configuration, and now everything is back to normal.

Now the launchnavigator plugin simply silently fails to do anything useful. But that will be a story for another time…

Anyway, thanks for taking an interest.