dpa99c / phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
369 stars 131 forks source link

Plugin version conflicts #201

Closed lokisanhitleson closed 6 years ago

lokisanhitleson commented 6 years ago

I'm submitting a ... (check one with "x"):

Bug report

Current behavior:

If this plugin added to my ionic project, build fails with app:transformDexArchiveWithExternalLibsDexMergerForDebug error. If plugin removed, then build success

Expected behavior:

Successful build

Steps to reproduce:

I am developing ionic android app with map navigation plugin.. before the navigation plugin, the app working normally. But after installed

ionic cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator

the ionic cordova build android command throws below error

> cordova build android
Android Studio project detected

ANDROID_HOME=/Users/mazelon/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.

The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

    at build_2oatwbcuz91e1yov85asv190t.run(/Users/mazelon/WorkArea/deals/platforms/android/app/build.gradle:143)

Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.

:CordovaLib:preBuild

UP-TO-DATE

          ................
          ................
          ................

:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE

:app:mergeDebugAssets

UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug

:app:transformClassesWithDesugarForDebug

:app:transformClassesWithDexBuilderForDebug

:app:transformDexArchiveWithExternalLibsDexMergerForDebug

FAILED

FAILURE: 
Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* 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 10s
37 actionable tasks: 9 executed, 28 up-to-date
(node:21890) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/mazelon/WorkArea/deals/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: /Users/mazelon/WorkArea/deals/platforms/android/app/src/main/java/org/apache/cordova/file/AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* 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 10s
(node:21890) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

So, I ran cordova clean for above error. After that, build is successful. But, app crashing while startup. I didn't receiving any errors in colsole The ionic cordova run android --device -l -c outputs,

BUILD SUCCESSFUL in 17s

46 actionable tasks: 44 executed, 2 up-to-date
Built the following apk(s): 
    /Users/mazelon/WorkArea/deals/platforms/android/app/build/outputs/apk/debug/app-debug.apk

ANDROID_HOME=/Users/mazelon/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
none
Skipping build...

Built the following apk(s): 
    /Users/mazelon/WorkArea/deals/platforms/android/app/build/outputs/apk/debug/app-debug.apk

Using apk: /Users/mazelon/WorkArea/deals/platforms/android/app/build/outputs/apk/debug/app-debug.apk

Package name: com.mazelon.xoomdeals
LAUNCH SUCCESS

[17:54:38]  console.log: deviceready has not fired after 5 seconds. 
[17:54:38]  console.log: Channel not fired: onDOMContentLoaded 
[17:54:45]  console.log: Angular is running in the development mode. Call enableProdMode() to enable the production 
            mode. 
[17:54:45]  console.log: OPEN database: _ionicstorage 
[17:54:45]  console.log: new transaction is queued, waiting for open operation to finish 
[17:54:45]  console.log: OPEN database: _ionicstorage - OK 
[17:54:45]  console.log: DB opened: _ionicstorage 
[17:54:45]  console.log: Ionic Native: deviceready event fired after 5063 ms 
[17:54:45]  console.log: Home service started 
[17:54:45]  console.log: http://dealstesting.mazelon.com/index.php/AppAPIs/Deals/getCategories 
[17:54:45]  console.log: http://dealstesting.mazelon.com/index.php/AppAPIs/Deals/getCities 

No errors in console. How do I need to debug this?

Environment information

Runtime issue

Android build issue:

iOS build issue: Note: Biuld for iOS is successful with this plugin and working properly

Cordova:

cordova (Cordova CLI) : 8.0.0 Cordova Platforms : android 7.1.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 13 other plugins)

System:

Android SDK Tools : 26.1.1 ios-deploy : 1.9.2 NodeJS : v8.9.4 (/usr/local/bin/node) npm : 6.1.0 OS : macOS High Sierra Xcode : Xcode 9.4.1 Build version 9F2000

Environment:

ANDROID_HOME : /Users/mazelon/Library/Android/sdk


- Installed Ionic Native modules and versions
    - `npm list | grep "@ionic-native"`:
├── @ionic-native/android-permissions@4.11.0
├── @ionic-native/app-center-crashes@4.12.0
├── @ionic-native/core@4.12.0
├── @ionic-native/device@4.9.2
├── @ionic-native/facebook@4.10.0
├── @ionic-native/google-plus@4.10.1
├── @ionic-native/http@4.9.1
├── @ionic-native/in-app-browser@4.9.1
├── @ionic-native/keyboard@4.11.0
├── @ionic-native/launch-navigator@4.12.0
├── @ionic-native/social-sharing@4.9.0
├── @ionic-native/splash-screen@4.8.0
├── @ionic-native/status-bar@4.8.0
├── @ionic-native/uid@4.11.0
dpa99c commented 6 years ago

This error is not caused directly by this plugin, but because you now have enough native Android code in your project that it has exceeded the 64k methods in the single dex limit. This is probably indirectly caused by this plugin when it pulls in the OKHTTP library as a dependency - the straw that broke the camel's back.

You can confirm this by Googling the error message, for example this SO question.

The solution, as pointed out in this answer to the above question is to enable multidex mode in the Gradle config which removes the 64k limit.

The easiest way to enable multidex in a Cordova project is via a plugin such as cordova-multidex.

Closing as this plugin is not the direct cause of the issue.

lokisanhitleson commented 6 years ago

Thanks for your quick response and solution. But, enabling multidex resolves only the error app:transformDexArchiveWithExternalLibsDexMergerForDebug. My app keep crashing at startup when i install this plugin.. I also tried adding below plugin for multidex but no improvements cordova plugin add --save https://github.com/jwall149/cordova-multidex My app working fine once I removed launch navigator plugin

dpa99c commented 6 years ago

If the app is encountering a native crash on startup, you'll need to look at the Android logcat output to determine the cause.

lokisanhitleson commented 6 years ago

OKHTTP library crashing my app

  • 08-21 16:10:46.515 31441 31549 W PluginManager: THREAD WARNING: exec() call to CordovaHttpPlugin.get blocked the main thread for 20ms. Plugin should use CordovaInterface.getThreadPool().
  • 08-21 16:10:46.541 31441 31519 D EGL_emulation: eglMakeCurrent: 0xe1603c60: ver 3 0 (tinfo 0xe5594270)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: FATAL EXCEPTION: pool-2-thread-3
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: Process: com.mazelon.xoomdeals, PID: 31441
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: java.lang.NoSuchMethodError: No virtual method getHttpUrlChecked(Ljava/lang/String;)Lokhttp3/HttpUrl; in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/com.mazelon.xoomdeals-ZM12c3U7qD13ZQRi2OnfPA==/base.apk!classes2.dex)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at okhttp3.internal.huc.OkHttpURLConnection.buildCall(OkHttpURLConnection.java:373)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at okhttp3.internal.huc.OkHttpURLConnection.getResponse(OkHttpURLConnection.java:435)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at okhttp3.internal.huc.OkHttpURLConnection.getResponseCode(OkHttpURLConnection.java:491)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at com.github.kevinsawicki.http.HttpRequest.code(HttpRequest.java:1717)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at com.synconset.cordovahttp.CordovaHttp.returnResponseObject(CordovaHttp.java:284)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at com.synconset.cordovahttp.CordovaHttpGet.run(CordovaHttpGet.java:30)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
  • 08-21 16:10:46.564 31441 31551 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
  • 08-21 16:10:46.590 31441 31579 I Process : Sending signal. PID: 31441 SIG: 9
  • 08-21 16:10:46.697 1803 1917 W InputDispatcher: channel 'df6520c com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
  • 08-21 16:10:46.697 1803 1917 E InputDispatcher: channel 'df6520c com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
  • 08-21 16:10:46.698 1803 1917 W InputDispatcher: channel 'a6a6874 com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
  • 08-21 16:10:46.698 1803 1917 E InputDispatcher: channel 'a6a6874 com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
  • 08-21 16:10:46.702 1803 22304 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=35, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND Unwanted: Uid: 10082] ], android.os.BinderProxy@7f4dd58)
  • 08-21 16:10:46.703 1803 1815 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=34, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&FOREGROUND Unwanted: Uid: 10082] ], android.os.BinderProxy@8c33eb1)
  • 08-21 16:10:46.704 1803 8335 I ActivityManager: Process com.mazelon.xoomdeals (pid 31441) has died: fore TOP
  • 08-21 16:10:46.705 1803 3512 I WindowManager: WIN DEATH: Window{df6520c u0 com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity}
  • 08-21 16:10:46.705 1803 3512 W InputDispatcher: Attempted to unregister already unregistered input channel 'df6520c com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity (server)'
  • 08-21 16:10:46.714 1803 1821 W libprocessgroup: kill(-31441, 9) failed: No such process
  • 08-21 16:10:46.714 1803 22304 I WindowManager: WIN DEATH: Window{a6a6874 u0 com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity}
  • 08-21 16:10:46.714 1803 22304 W InputDispatcher: Attempted to unregister already unregistered input channel 'a6a6874 com.mazelon.xoomdeals/com.mazelon.xoomdeals.MainActivity (server)'
  • 08-21 16:10:46.715 1803 8335 W ActivityManager: Force removing ActivityRecord{1deb76 u0 com.mazelon.xoomdeals/.MainActivity t24}: app died, no saved state
  • 08-21 16:10:46.720 1651 2259 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{c72a5e4 token=Token{dbf6577 ActivityRecord{1deb76 u0 com.mazelon.xoomdeals/.MainActivity t24}}}#0
  • 08-21 16:10:46.725 1652 1652 I Zygote : Process 31441 exited due to signal (9)
  • 08-21 16:10:46.730 1803 8335 I ActivityManager: Killing 31483:com.android.chrome:sandboxed_process0/u0a82i7 (adj 0): isolated not needed
  • 08-21 16:10:46.747 29613 31582 V Bugle : Reclaiming memory.
  • 08-21 16:10:46.758 1803 1821 W libprocessgroup: kill(-31441, 9) failed: No such process
  • 08-21 16:10:46.758 1803 1821 I libprocessgroup: Successfully killed process cgroup uid 10082 pid 31441 in 51ms
  • 08-21 16:10:46.758 1803 1821 W libprocessgroup: Failed to open process cgroup uid 99007 pid 31483: No such file or directory
  • 08-21 16:10:46.758 1803 1821 E libprocessgroup: Error encountered killing process cgroup uid 99007 pid 31483: No such file or directory
  • 08-21 16:10:46.819 2029 2029 I Zygote : Process 31483 exited cleanly (0)
  • 08-21 16:10:46.827 1533 1579 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 16592896
  • 08-21 16:10:46.854 1803 1819 W Looper : Slow dispatch took 141ms android.ui h=com.android.server.am.ActivityManagerService$UiHandler c=null m=53
  • 08-21 16:10:46.857 1803 1818 W system_server: Long monitor contention with owner Binder:1803_1A (8335) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1876) waiters=3 in void com.android.server.am.TaskChangeNotificationController$MainHandler.handleMessage(android.os.Message) for 138ms
  • 08-21 16:10:46.864 1533 1533 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 16592896
  • 08-21 16:10:46.884 1803 1822 E KernelCpuSpeedReader: Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state (No such file or directory)
  • 08-21 16:10:46.902 1803 1827 W ActivityManager: setHasOverlayUi called on unknown pid: 31441
  • 08-21 16:10:46.917 29613 31583 V Bugle : Reclaiming memory.
  • 08-21 16:10:46.929 1533 1579 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 16592896
  • 08-21 16:10:46.963 1651 1651 D SurfaceFlinger: duplicate layer name: changing com.google.android.apps.nexuslauncher/com.google.android.apps.nexuslauncher.NexusLauncherActivity to com.google.android.apps.nexuslauncher/
dpa99c commented 6 years ago

Looking at the list of plugins in your project, the most like cause is a conflict between this plugin and cordova-plugin-advanced-http. That plugin pins v3.10.0 of the OKHTTP library's urlconnection component while this plugin defaults to v3.+ of the entire library.

Consequently you have a version mismatch between the urlconnection component which is pinned at 3.10.0 and the rest of the library which is pinned at 3.x

A possible solution is to align the version requested by this plugin with that pinned by cordova-plugin-advanced-http by using the plugin variable at installation:

cordova plugin rm uk.co.workingedge.phonegap.plugin.launchnavigator
cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable OKHTTP_VERSION=3.10.0
lokisanhitleson commented 6 years ago

Thanks man, You made my day. It's now working

dpa99c commented 6 years ago

👍