Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem running instrumentation tests #32

Closed
kaushikgopal opened this issue Jul 25, 2014 · 6 comments
Closed

problem running instrumentation tests #32

kaushikgopal opened this issue Jul 25, 2014 · 6 comments

Comments

@kaushikgopal
Copy link

I'm facing an issue similar to #18 . I get an exception when running normal instrumentation tests, but for a class that's placed in an independent directory (i.e. a subproject).

Here's the exception:

Executing tasks: [:app:assembleDebug, :app:assembleDebugTest]

---- /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
---- /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
---- 1.6
// ....
:app:mergeDebugResources
:app:processDebugResources
:app:generateDebugSources
:app:compileDebugJava
:app:compileRetrolambdaDebug
objc[90452]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
:app:preDexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
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:472)
  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.processClass(Main.java:665)
  at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
  at com.android.dx.command.dexer.Main.access$600(Main.java:78)
  at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
  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:596)
  at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
  at com.android.dx.command.dexer.Main.run(Main.java:230)
  at com.android.dx.command.dexer.Main.main(Main.java:199)
  at com.android.dx.command.Main.main(Main.java:103)
...while parsing com/mycompany/app/pojo/TrackingData.class

1 error; aborting

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Applications/Android Studio.app/sdk/build-tools/19.1.0/dx --dex --output ~/code/myapp/app/build/intermediates/pre-dexed/debug/pojos-688c6bfda22a0b4cc1fcd404a1c3832cb61f70ee.jar ~/code/myapp/app/pojos/build/libs/pojos.jar
  Error Code:
    1
  Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    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:472)
      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.processClass(Main.java:665)
      at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
      at com.android.dx.command.dexer.Main.access$600(Main.java:78)
      at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
      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:596)
      at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
      at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
      at com.android.dx.command.dexer.Main.run(Main.java:230)
      at com.android.dx.command.dexer.Main.main(Main.java:199)
      at com.android.dx.command.Main.main(Main.java:103)
    ...while parsing com/mycompany/app/pojo/TrackingData.class

    1 error; aborting


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

BUILD FAILED

Total time: 15.057 secs

OS: OSX Maverics

echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
echo $JAVA8_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
echo $JAVA6_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

build.gradle (IDEA project level)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
        classpath 'me.tatarka:gradle-retrolambda:2.1.0'
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.9'
}

build.gradle (app level)

evaluationDependsOn(':subProjects:pojos')

// ..

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
apply plugin: 'retrolambda'


repositories {
    mavenCentral()
    maven { url 'http://download.crashlytics.com/maven' }
}

dependencies {
    compile 'com.android.support:support-v13:20.0.+'
    compile 'com.google.guava:guava:17.+'
    // ..
    compile project(':subProjects:pojos')
    // ..
}

android {

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    // see https://github.com/JakeWharton/double-espresso/issues/13
    useOldManifestMerger true

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        // ..
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }

retrolambda {
    jdk System.getenv("JAVA8_HOME")
    oldJdk System.getenv("JAVA6_HOME")
    javaVersion JavaVersion.VERSION_1_6
    println "---- ${System.getenv("JAVA8_HOME")}"
    println "---- ${System.getenv("JAVA_HOME")}"
    println "---- ${System.getenv("JAVA6_HOME")}"
    println "---- ${javaVersion}"
}
@evant
Copy link
Owner

evant commented Jul 26, 2014

Could you post your build.gradle for ":subProjects:pojos"? My guess is that it's producing a java 8 jar that dex can't convert. If you are not already applying the retrolambda plugin to the subproject, you should try that.

@evant
Copy link
Owner

evant commented Aug 3, 2014

@kaushikgopal Have you made any progress on this? Did you try my suggestion on adding the plugin to your pojos project as well? Did https://github.com/Takhion/supertest help any?

@kaushikgopal
Copy link
Author

@evant apologies, I had an urgent release, so had to drop back to a clean branch and push some changes.

I suspect your suggestion of applying retrolambda to the pojos would be the best bet. Alternatively the reverse, i.e. forcing 1.6 in my pojos project.

I'll report back with a solution that worked for me, in the next coming days.

@vinc3m1
Copy link

vinc3m1 commented Aug 4, 2014

@kaushikgopal not sure if this is the same issue as yours, but I had a similar error that ended up being this: luontola/retrolambda#25 (comment)

Seems to happen only when using lambdas inside classes that override classes from Google Play Services (and only when using gps 5.+)

@evant
Copy link
Owner

evant commented Aug 17, 2014

@kaushikgopal I still haven't heard back from you, If you're busy that's fine. I'm going to close this issue, feel free to reopen if you get a chance to apply a solution and are still having trouble.

@evant evant closed this as completed Aug 17, 2014
@kaushikgopal
Copy link
Author

@evant that's totally fair. Apologies again , for keeping this open for so
long. I'll try the suggested solutions and post back with results once i
get the chance.

On Sun, Aug 17, 2014 at 1:53 PM, Evan Tatarka notifications@github.com
wrote:

@kaushikgopal https://github.com/kaushikgopal I still haven't heard
back from you, If you're busy that's fine. I'm going to close this issue,
feel free to reopen if you get a chance to apply a solution and are still
having trouble.


Reply to this email directly or view it on GitHub
#32 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants