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

Bad <init> method call from inside of a branch #12

Closed
kprotasov opened this issue Sep 10, 2015 · 17 comments
Closed

Bad <init> method call from inside of a branch #12

kprotasov opened this issue Sep 10, 2015 · 17 comments

Comments

@kprotasov
Copy link

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV132301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidAnswers132Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidBeta113Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlytics252Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlyticsCore235Library UP-TO-DATE
:app:prepareComGithubChrisbanesPhotoviewLibrary124Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:app:prepareComMsSquareExpandableTextView014Library UP-TO-DATE
:app:prepareIoFabricSdkAndroidFabric136Library UP-TO-DATE
:app:prepareJpCoCyberagentAndroidGpuimageGpuimageLibrary123Library UP-TO-DATE
:app:prepareMeGrantlandAutofittextview021Library UP-TO-DATE
:app:prepareOrgApmemToolsLayouts19Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDebug
:app:processDebugResources
:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:dexDebug UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug FAILED
Error:Execution failed for task ':app:assembleDebug'.
> Bad <init> method call from inside of a branch
Exception Details:
  Location:
    com/getkeepsafe/dexcount/PackageTree.<init>(Ljava/lang/String;)V @27: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: b800 214d b800 359a 0006 a700 172a 2b2c
    0x0000010: 1236 3212 022b b900 3c03 00b7 002c a700
    0x0000020: 0f2a 2b2b b800 40b8 0029 b700 2cb1     
  Stackmap Table:
    append_frame(@13,Object[#67])
    same_frame(@33)
    full_frame(@45,{Object[#2],Object[#69],Object[#67]},{})
Information:BUILD FAILED
Information:Total time: 27.534 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

Gradle 2.4

Build time: 2015-05-05 08:09:24 UTC
Build number: none
Revision: 5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Windows 7 6.1 amd64

benjamin-bader pushed a commit that referenced this issue Sep 10, 2015
Hopefully this resolves issue #12, in which execution fails due to the
verifier complaining about an error in the PackageTree bytecode.
@benjamin-bader
Copy link
Collaborator

Wow. It's not clear to me whether this is a bug in the JDK or in Groovy, but either way I think I have a fix. I've published a snapshot build (com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.2.1-SNAPSHOT), would you please give it a try and let me know whether you still see problems?

@xiphirx
Copy link
Contributor

xiphirx commented Sep 11, 2015

It's a bug in the 1.7 JDK. Please update your 1.7 JDK to at least version 7u72

@xiphirx xiphirx closed this as completed Sep 11, 2015
@kprotasov
Copy link
Author

ok. I try to use com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.2.1-SNAPSHOT
but it return next:

Gradle '360ego_android' project refresh failed
Error:Could not find com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.2.1-SNAPSHOT.
Searched in the following locations:
    file:/D:/Program Files/IDE/Android Studio 9.1/gradle/m2repository/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/maven-metadata.xml
    file:/D:/Program Files/IDE/Android Studio 9.1/gradle/m2repository/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/dexcount-gradle-plugin-0.2.1-SNAPSHOT.pom
    file:/D:/Program Files/IDE/Android Studio 9.1/gradle/m2repository/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/dexcount-gradle-plugin-0.2.1-SNAPSHOT.jar
    https://jcenter.bintray.com/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/maven-metadata.xml
    https://jcenter.bintray.com/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/dexcount-gradle-plugin-0.2.1-SNAPSHOT.pom
    https://jcenter.bintray.com/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/dexcount-gradle-plugin-0.2.1-SNAPSHOT.jar
    https://jitpack.io/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/maven-metadata.xml
    https://jitpack.io/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/dexcount-gradle-plugin-0.2.1-SNAPSHOT.pom
    https://jitpack.io/com/getkeepsafe/dexcount/dexcount-gradle-plugin/0.2.1-SNAPSHOT/dexcount-gradle-plugin-0.2.1-SNAPSHOT.jar
Required by:
    :360ego_android:unspecified

And I use the final version of JDK - 7u79

@xiphirx
Copy link
Contributor

xiphirx commented Sep 11, 2015

Here is the relevant JDK bug report http://bugs.java.com/view_bug.do?bug_id=8051012

Please try to update both your JDK and runtime to the latest versions and use the stable version.

@benjamin-bader
Copy link
Collaborator

Apologies; the build is in Sonatype snapshots. Your build.gradle will need to look something like this:

buildscript {
  repositories {
    // other repositories e.g. jcenter() or mavenCentral()
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
  }

  dependencies {
    classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.2.1-SNAPSHOT'
  }
}

benjamin-bader pushed a commit that referenced this issue Sep 11, 2015
Hopefully this resolves issue #12, in which execution fails due to the
verifier complaining about an error in the PackageTree bytecode.
@benjamin-bader
Copy link
Collaborator

I've released a stable version 0.2.1 that no longer hits this buggy behavior in the JDK. You really should upgrade, but even if you can't the new version should work for you.

@Randyanto
Copy link

Executing tasks: [assembleDebug]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2321Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72321Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72321Library UP-TO-DATE
:app:prepareComAndroidSupportCustomtabs2321Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2321Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72321Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2321Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk4110Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateDebugSigning
:app:packageDebug UP-TO-DATE
:app:zipalignDebug UP-TO-DATE
:app:assembleDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:assembleDebug'.
> Bad <init> method call from inside of a branch
Exception Details:
  Location:
    com/getkeepsafe/dexcount/PackageTree.<init>()V @85: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 04bd 0004 5903 0112 6cb8 007b 5359 10ff
    0x0000010: 1202 b800 7f2a 5fab 0000 009e 0000 0005
    0x0000020: aad3 b1ff 0000 0031 c861 6941 0000 0044
    0x0000030: ef05 6b77 0000 0059 0000 9b75 0000 0078
    0x0000040: 0756 9009 0000 0081 5f5a 5903 32b8 005e
    0x0000050: c000 605f 57b7 0082 a700 675f 5a59 0332
    0x0000060: 126c b800 86c0 006c 5f57 b700 88a7 0052
    0x0000070: 5f5a 5903 32b8 005e c000 605f 5904 3212
    0x0000080: 6cb8 0086 c000 6c5f 57b7 008a a700 335f
    0x0000090: 5a57 b700 8ba7 002a 5f5a 5903 325f 5904
    0x00000a0: 325f 5905 3212 6cb8 0086 c000 6c5f 57b7
    0x00000b0: 002d a700 0dbb 008d 5912 8fb7 0090 bf57
    0x00000c0: b1                                     
  Stackmap Table:
    full_frame(@72,{UninitializedThis},{Object[#146],UninitializedThis})
    full_frame(@91,{UninitializedThis},{Object[#146],UninitializedThis})
    full_frame(@112,{UninitializedThis},{Object[#146],UninitializedThis})
    full_frame(@143,{UninitializedThis},{Object[#146],UninitializedThis})
    full_frame(@152,{UninitializedThis},{Object[#146],UninitializedThis})
    full_frame(@181,{UninitializedThis},{Object[#146],UninitializedThis})
    full_frame(@191,{Object[#2]},{Object[#146]})


* 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: 3.279 secs

Happened again to me OTL

@benjamin-bader
Copy link
Collaborator

benjamin-bader commented Apr 21, 2016

Oh, that's annoying - sorry. What does 'OTL' mean?

Also, would you please paste the output of ./gradlew --version?

@Randyanto
Copy link

OTL is http://orig05.deviantart.net/b450/f/2013/014/8/b/otl_by_gentlehorizon-d5rjuo4.jpg hehe

Gradle 2.12

Build time: 2016-03-14 08:32:03 UTC
Build number: none
Revision: b29fbb64ad6b068cb3f05f7e40dc670472129bc0

Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_20 (Oracle Corporation 25.20-b23)
OS: Windows 7 6.1 amd64

@benjamin-bader
Copy link
Collaborator

Bahaha, I'm getting old. How apropos for this kind of bug.

Allegedly this was fixed, and the fix was applied to JVM 8u20, but clearly you're experiencing the bug, so... I have a speculative fix that I'll push momentarily. I can't repro this myself, so maybe it works, maybe it doesn't. I'm 99% sure though, that this regressed because I added a constructor to PackageTree and used arguments with default values.

It's informative to look at the output from javap -c PackageTree.class. The no-args constructor, in bytecode, is a huge mess of dynamic constructor selection and from-the-side argument passing. Astonishing! I guess it, and bugs like this, are the price of such a flexible language.

TL;DR: Try 0.5.1-SNAPSHOT tomorrow; make sure you've added the appropriate snapshot repo as described above in this issue. Let me know if it works.

benjamin-bader added a commit to benjamin-bader/dexcount-gradle-plugin that referenced this issue Apr 22, 2016
Fixes KeepSafe#12

This regressed when I added default-value parameters to PackageTree;
this compiles to an unholy horror of pass-args-by-global-static
dynamicism and other unspeakables, including the verifier crash.

This commit removes default parameters, restoring order to PackageTree
once again.
@Randyanto
Copy link

Randyanto commented Apr 22, 2016

Thanks, I will try it at Monday :)

Sorry I don't really know what you are talking about because I'm just a beginner in the Android development and all of these things are making me crazy. Not to mention, I'm not a fan of Java programming. I'm just trying to be persistent and hit my goal haha.

benjamin-bader added a commit that referenced this issue Apr 22, 2016
Fixes #12

This regressed when I added default-value parameters to PackageTree;
this compiles to an unholy horror of pass-args-by-global-static
dynamicism and other unspeakables, including the verifier crash.

This commit removes default parameters, restoring order to PackageTree
once again.
@benjamin-bader
Copy link
Collaborator

Whoops, accidentally closed this automatically. Re-opening.

Please do try it! I'd love to know that 0.5.1-SNAPSHOT does indeed fix the issue; it would be super helpful to hear how it works for you. Thanks!

@Randyanto
Copy link

Thanks! It's solved.

However, I must add mavenCentral to the the repositories. If I don't add it then
Error:Could not find com.google.code.gson:gson:2.5. will appear.

This is the buildscript I use in the build.gradle(Module:app).

buildscript {
    repositories {
        // other repos should come first
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }

    dependencies {
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.1-SNAPSHOT'
    }
}

// make sure this line comes *after* you apply the Android plugin
apply plugin: 'com.getkeepsafe.dexcount'

@benjamin-bader
Copy link
Collaborator

Interesting; I assume you had jcenter()? If so I'm confused and will have to experiment. Glad that the snapshot works for you.

@Randyanto
Copy link

Yes I have it in the build.graddle (Project)

This is my build.graddle(Project). I just notice that I also have mavenCentral() there. Hmmmmm.. then why I still need to add mavenCentral() in the build.graddle(Module:app). I'm confused haha.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

@jkreiser
Copy link

My java version:

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

This causes the same error for me:

classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.0'

This works for me:

maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.1-SNAPSHOT'

@benjamin-bader
Copy link
Collaborator

Thanks for your report. We have not yet released a non-snapshot build that has this bugfix; we just haven't had the bandwidth lately. It's on the radar!

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

5 participants