Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
110 stars 139 forks source link

Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. #273

Closed guirip closed 6 years ago

guirip commented 6 years ago

Hello !

I now have the following error:

:transformClassesWithDexForDebugDex: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

Installed java version:

$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

Installed android tools:

Npm resolved: https://registry.npmjs.org/pushwoosh-cordova-plugin/-/pushwoosh-cordova-plugin-7.1.0.tgz

Simple steps to reproduce:

Here is the output from my machine:

$ cordova create test-pushwoosh-plugin
Creating a new cordova project.
$ cd test-pushwoosh-plugin/
$ cordova plugin add pushwoosh-cordova-plugin
Adding pushwoosh-cordova-plugin to package.json
Saved plugin info for "pushwoosh-cordova-plugin" to config.xml
[12:42] guillaume@asus:test-pushwoosh-plugin $ cordova platform add android
Using cordova-fetch for cordova-android@~6.3.0
Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: io.cordova.hellocordova
    Name: HelloCordova
    Activity: MainActivity
    Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android@6.3.0
Installing "pushwoosh-cordova-plugin" for android
Subproject Path: CordovaLib
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving android@~6.3.0 into config.xml file ...
[12:42] guillaume@asus:test-pushwoosh-plugin $ cordova build
ANDROID_HOME=/home/guillaume/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
:wrapper

BUILD SUCCESSFUL

Total time: 0.839 secs
Subproject Path: CordovaLib
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_cpughyboh3wkc4q81mciddqvj.run(/var/www/projets/test-pushwoosh-plugin/platforms/android/build.gradle:141)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:preReleaseBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:CordovaLib:mergeDebugProguardFiles
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:processDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseAidl
:CordovaLib:compileReleaseNdk UP-TO-DATE
:CordovaLib:copyReleaseLint UP-TO-DATE
:CordovaLib:mergeReleaseShaders
:CordovaLib:compileReleaseShaders
:CordovaLib:generateReleaseAssets
:CordovaLib:mergeReleaseAssets
:CordovaLib:mergeReleaseProguardFiles
:CordovaLib:packageReleaseRenderscript UP-TO-DATE
:CordovaLib:compileReleaseRenderscript
:CordovaLib:generateReleaseResValues
:CordovaLib:generateReleaseResources
:CordovaLib:packageReleaseResources
:CordovaLib:processReleaseManifest
:CordovaLib:generateReleaseBuildConfig
:CordovaLib:processReleaseResources
:CordovaLib:generateReleaseSources
:CordovaLib:incrementalReleaseJavaCompilationSafeguard
:CordovaLib:compileReleaseJavaWithJavac
:CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processReleaseJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForRelease
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
:CordovaLib:mergeReleaseJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForRelease
:CordovaLib:transformNative_libsWithSyncJniLibsForRelease
:CordovaLib:bundleRelease
:prepareAndroidArchLifecycleRuntime100Library
:prepareComAndroidSupportSupportCompat2610Library
:prepareComAndroidSupportSupportCoreUi2610Library
:prepareComAndroidSupportSupportCoreUtils2610Library
:prepareComAndroidSupportSupportFragment2610Library
:prepareComAndroidSupportSupportMediaCompat2610Library
:prepareComAndroidSupportSupportV42610Library
:prepareComGoogleAndroidGmsPlayServicesBase1162Library
:prepareComGoogleAndroidGmsPlayServicesBaseLicense1162Library
:prepareComGoogleAndroidGmsPlayServicesBasement1162Library
:prepareComGoogleAndroidGmsPlayServicesBasementLicense1162Library
:prepareComGoogleAndroidGmsPlayServicesGcm1162Library
:prepareComGoogleAndroidGmsPlayServicesGcmLicense1162Library
:prepareComGoogleAndroidGmsPlayServicesIid1162Library
:prepareComGoogleAndroidGmsPlayServicesIidLicense1162Library
:prepareComGoogleAndroidGmsPlayServicesLocation1162Library
:prepareComGoogleAndroidGmsPlayServicesLocationLicense1162Library
:prepareComGoogleAndroidGmsPlayServicesTasks1162Library
:prepareComGoogleAndroidGmsPlayServicesTasksLicense1162Library
:prepareComGoogleFirebaseFirebaseAnalytics1162Library
:prepareComGoogleFirebaseFirebaseAnalyticsImpl1162Library
:prepareComGoogleFirebaseFirebaseAnalyticsImplLicense1162Library
:prepareComGoogleFirebaseFirebaseAnalyticsLicense1162Library
:prepareComGoogleFirebaseFirebaseCommon1162Library
:prepareComGoogleFirebaseFirebaseCommonLicense1162Library
:prepareComGoogleFirebaseFirebaseCore1162Library
:prepareComGoogleFirebaseFirebaseIid1162Library
:prepareComGoogleFirebaseFirebaseIidLicense1162Library
:prepareComGoogleFirebaseFirebaseMessaging1162Library
:prepareComGoogleFirebaseFirebaseMessagingLicense1162Library
:prepareComPushwooshPushwoosh551Library
:prepareComPushwooshPushwooshAmazon551Library
:prepareComPushwooshPushwooshBadge551Library
:prepareComPushwooshPushwooshGcm551Library
:prepareOrgApacheCordovaCordovaLib630DebugLibrary
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:incrementalDebugJavaCompilationSafeguard
:compileDebugJavaWithJavac
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:compileDebugNdk UP-TO-DATE
:compileDebugSources
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:mergeDebugAssets
:transformClassesWithDexForDebugDex: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.RuntimeException: Exception parsing classes
        at com.android.dx.command.dexer.Main.processClass(Main.java:775)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:741)
        at com.android.dx.command.dexer.Main.access$1200(Main.java:88)
        at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1683)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
        at com.android.dx.command.dexer.Main.processOne(Main.java:695)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)
        at com.android.dx.command.dexer.Main.run(Main.java:292)
        at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
        at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:173)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
        at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:476)
        at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
        at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
        at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
        at com.android.dx.command.dexer.Main.parseClass(Main.java:787)
        at com.android.dx.command.dexer.Main.access$1600(Main.java:88)
        at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1722)
        at com.android.dx.command.dexer.Main.processClass(Main.java:773)
        ... 16 more

1 error; aborting
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

BUILD FAILED

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

Total time: 16.766 secs
Error: /var/www/projets/test-pushwoosh-plugin/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.
Dex: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.RuntimeException: Exception parsing classes
        at com.android.dx.command.dexer.Main.processClass(Main.java:775)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:741)
        at com.android.dx.command.dexer.Main.access$1200(Main.java:88)
        at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1683)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
        at com.android.dx.command.dexer.Main.processOne(Main.java:695)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)
        at com.android.dx.command.dexer.Main.run(Main.java:292)
        at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
        at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:173)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
        at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:476)
        at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
        at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
        at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
        at com.android.dx.command.dexer.Main.parseClass(Main.java:787)
        at com.android.dx.command.dexer.Main.access$1600(Main.java:88)
        at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1722)
        at com.android.dx.command.dexer.Main.processClass(Main.java:773)
        ... 16 more

1 error; aborting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

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

If you need anything else that can help you, please tell me.

guirip commented 6 years ago

PS: No issue encountered if I switch back on version 7.0.8

zarko-tg commented 6 years ago

Same issue here.

wfhm commented 6 years ago

Hi,

Starting with Pushwoosh Cordova plugin v7.1.0, you need to use Android Plugin for Gradle v3.0.0 (or higher) with Gradle v4.1 (or higher). You should add Java 8 support as well. To do so you should use Cordova-android v7.0.0 (or higher):

#remove previous android platform
cordova platform remove android

#add new one with cordova-android v7.0.0
cordova platform add android@7.0.0
guirip commented 6 years ago

Okay, that was tricky as cordova-android@7.0.0 is available since 2 days ago only :) Will try tomorrow and let you know. Thanks @wfhm

wfhm commented 6 years ago

@guirip Any news?

guirip commented 6 years ago

@wfhm Damn, I said 'tomorrow' 6 days ago... facepalm :)

We had a release to make/test/deliver to a client so we couldn't afford to change the cordova-android version this late. But this morning I had some time available for this so I tried. I could say that it is better, because I no longer have the error reported, but the build still fails because a service provided by one of our contractors does not seem to be compatible with cordova-android@7 / minSdk 19.

Thus we need to keep on working with version 7.0.8 of pushwoosh-cordova-plugin for a while. Sorry that I can't help more.

wfhm commented 6 years ago

@guirip

Sorry for pinging you again. Did you have a chance to try the solution above? Please also note that we have added Java 7 support to pushwoosh-cordova-plugin starting with 7.2.2 version.

zarko-tg commented 6 years ago

@wfhm 7.2.2 works well for me, no build problem as reported.