Open nathanwharvey opened 7 years ago
This appears to be a change to an internal class in gradle that this plugin depends on. The change is in 3.5 and 3.4.1 still continues to work as a current work around. I will be updating tests and the source to NO longer depend on the internal gradle classes as this is the second time its caused the plugin to break.
Turns out the breaking change was from Gradle 3.2 to 3.3 where an interface had a method added to it.
I updated the tests to include 3.5 and before fixing this change they were still passing. So it looks like there is still something else going on in your issues.
Once #146 gets merged in you can try out the 1.2.0-SNAPSHOT and see if it resolves your issue.
Great, thanks for the quick reply. I am indeed using Gradle 3.4.1 so it's a strange issue. I'll wait for the merge
@AndrewReitz I see you merged the change, but I don't see a 1.2.0-SNAPSHOT on bintray. I'm still getting errors. I tried switching around my Gradle versions but to no avail. Are the following versions correct?
com.android.tools.build:gradle:2.4.0-alpha5
org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0
buildToolsVersion "25.0.2"
compileSdkVersion 25
I haven't tested anything using any of the alpha builds since I'm only one person and google seems to change stuff so much. An easy way to test newer version is to just add another row to the data table in the full test spec and run ./gradlew fullTest
For the snapshots you need to use the jcenter's snapshot repo instead of the regular jcenter repo. Directions to add this are on in the README.
how did it solved?
@yangxinQA Hey, sorry for the late reply, I am just getting back at my app. I solved it for one of my classes by removing @CompileStatic
. I also downgraded my build tools. Here are my versions:
com.android.tools.build:gradle:2.3.2
org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0
buildToolsVersion "25.0.2"
compileSdkVersion 25
If that doesn't work for you, I'm afraid I can't help :(. Maybe @AndrewReitz has some more ideas.
@nathanwharvey are you still seeing this issue?
I have just run into this when trying to use android-spock:2.0.0
with the Android Studio 3.0 preview and com.android.tools.build:gradle:3.0.0-alpha3
that you need to compile Java8. I guess this might be related? I was basically just grabbing the preview from here, configured an API level 25 project as described here, and tried to get the basic sample to run.
I was experiencing the same issue and i can confirm that using org.codehaus.groovy:groovy-android-gradle-plugin:1.3.0-SNAPSHOT
resolves it
@nite2 The only difference between 1.2.0 and 1.3.0-SNAPSHOT is the version number so I don't think that's what solved the issue. Maybe an update to the gradle android plugin fixed the issue?
@AndrewReitz I am not saying that this issue wasn't resolved in 1.2.0-SNAPSHOT as you have suggested in previous comment, what i was communicating is that i was having the issue when using version 1.2.0 (not 1.2.0-SNAPSHOT), then upgraded to 1.3.0-SNAPSHOT and the problem was gone. Was the fix #146 included in the "main" 1.2.0 release?
Yeah, #146 was included. As of right now, the only difference between 1.2.0 and 1.3.0-SNAPSHOT is the version number https://github.com/groovy/groovy-android-gradle-plugin/commits/master.
What about new gradle (4.1) ? I've the same issue
I've done a little bit of research and this seems to be caused by a new check in Dalvik, see https://android.googlesource.com/platform/dalvik/+/cdef1ee858fde291205f3da685b2720227d2d42f/dx/src/com/android/dx/cf/code/Simulator.java line 684. When running the gradle build with --stacktrace, you can see that the groovy class org/codehaus/groovy/vmplugin/v7/IndyInterface.java violates this check. Indy here stands for invokeDynamic - on Android, this compiler feature is only supported with minSDK >= 26. It seems to me that even though grooid (the groovy build for Android) is compiled with indy switched off, the indy-related classes still end up in the groovy artifact, thus making my build fail.
I've just gotten rid of the problem by patching the grooid library (deleted packages "indy" and "vmplugin/v7" and made sure that Option CompilerConfiguration.INVOKEDYNAMIC was false). Quick & dirty but seems to work for now.. Should probably file an issue in the groovy project.
@b-demuth any chance you can host the patched version somewhere or show us how to do it?
Created a ticket: https://issues.apache.org/jira/browse/GROOVY-8366 and working on a possible solution.
I'm at the droidcon right now, but I'll see if I can host the patched version next week. I literally just deleted said packages and the line "if (Boolean.TRUE.equals(optOptions.get(CompilerConfiguration.INVOKEDYNAMIC))) invokedynamic=true;" in class "WriterController" in the 2_4_X branch of groovy (which was easier for me than setting that parameter in the optOptions :)). Also, I switched off some of the documentation related parts of the build process and jar signing, so my patched version is UNSIGNED. This really is a dirty hack, but I didn't have time to get familiar with the groovy build scripts in order to do this properly. I guess for someone who's already acquainted with the build process, it should be quick and easy to do.
Cool. I used JarJar to remove the packages right now, haven't tested it. If it works I can submit the PR to Groovy project. Also, going to submit a ticket with build tools team.
SideNote: Were you having issues with the javadocs part of the build process?
I think another workaround is to use proguard to remove those packages as well.
Looks like the tools team will not be fixing it. The suggested fix is to "minify" the code (Progaurd) out the method calls that use invoke dynamic. https://issuetracker.google.com/issues/37567710
The good news is that we are getting invoke dynamic on 26+
Looks like the jarjar rule of
zap org.codehaus.groovy.vmplugin.v7.IndyInterface
takes care of this. Submitting a PR to groovy soon.
I saw update to AGP to 3.0.0 and I try it.
It works when I use it in groovy-android-sample-app or in simple app with dependencies only on groovy but when I try on a more complex app with multiples dependencies like Retrofit or Dagger I have an error :
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'. Job failed, see logs for details
When I set minifyEnabled to false come back to initial error :
signature-polymorphic method called without --min-sdk-version >= 26
Is it mandatory to set minifyEnabled to true to make groovy plugin works ?
Here's how you can make a groovy jar without the invoke dynamic class included for a workaround until the issue is resolved. https://gist.github.com/AndrewReitz/3e1145d66a8ef3f7b578d8604ecd671c
I've been trying this workaround and the build succeeds. Unfortunately, the application crashes at runtime when calling method evaluate
on a GroovyShell
instance:
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during class generation: can't load this type of class file
java.lang.UnsupportedOperationException: can't load this type of class file at java.lang.ClassLoader.defineClass(ClassLoader.java:300) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:93) at groovy.lang.GroovyClassLoader.access$400(GroovyClassLoader.java:62) at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:500)
Any guess?
@vincentganneau I don't think that's related to this issue. The class files created by groovy are for the JVM, when you load them on an Android device they need to be converted to Dalvik bytecode. Here's an example of how this can be done https://github.com/melix/grooidshell-example. Although I haven't been able to get this to work on newer version of Android.
add
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
to your module build.gradle
I am getting a strange bug when building, even with a fresh project. The error only occurs when groovy is being compiled. Here is the module's build.gradle:
And here is the project's build.gralde:
I am using Gradle version 3.4.1. Here is the output from building:
I also tried copying the sample app and got the same error.