To work-around, you can put the code in a buildSrc 
project: 
https://docs.gradle.org/3.3/userguide/organizing_build_logic.html#sec:build_sources

On Tuesday, May 30, 2017 at 4:54:17 PM UTC-7, Alex Waters wrote:
>
> When you do apply from: 'other.gradle' it does weird classloader things 
> such that the two scripts have different classloaders (and thus even though 
> it's the "same" class, it's not seen as the same to the JVM - a very 
> irritating aspect of Gradle build scripts).
> Can you put that same code at the end of the file instead? If that works 
> then it's likely this.
> I can't suggest a work-around unfortunately other than not using "apply 
> from" (if you do discover a nice fix please post it)
>
> On Tuesday, May 9, 2017 at 6:35:13 PM UTC+9:30, Malcolm Evershed wrote:
>>
>> My app/build.gradle says at the end "apply from: 'other.gradle'". The 
>> other.gradle file is very simple and contains the following:
>>
>> buildscript {
>>
>>     repositories {
>>
>>         jcenter()
>>
>>     }
>>
>>     dependencies {
>>
>>         // Needed for com.android.build.api classes
>>
>>         classpath 'com.android.tools.build:gradle-api:2.3.1'
>>
>>     }
>>
>> }
>>
>>
>> import com.android.build.api.transform.QualifiedContent
>>
>> import com.android.build.api.transform.Transform
>>
>>
>> // Stub implementation
>>
>> class MyTransform extends Transform {
>>
>>     @Override
>>
>>     String getName() {
>>
>>         return null
>>
>>     }
>>
>>
>>     @Override
>>
>>     Set<QualifiedContent.ContentType> getInputTypes() {
>>
>>         return null
>>
>>     }
>>
>>
>>     @Override
>>
>>     Set<QualifiedContent.Scope> getScopes() {
>>
>>         return null
>>
>>     }
>>
>>
>>     @Override
>>
>>     boolean isIncremental() {
>>
>>         return false
>>
>>     }
>>
>> }
>>
>>
>> Class parameterClass
>>
>>
>> for (def method : android.getClass().getMethods()) {
>>
>>     if (method.getName() == "registerTransform") {
>>
>>         parameterClass = method.getParameterTypes()[0]
>>
>>         println 'Class of first parameter to android.registerTransform: ' + 
>> parameterClass
>>
>>     }
>>
>> }
>>
>>
>> Class superClass = MyTransform.class.getSuperclass()
>>
>> println 'Class of parameter that we want to pass to 
>> android.registerTransform: ' + superClass
>>
>> println 'Are the names of the two types equal? ' + 
>> superClass.getCanonicalName().equals(parameterClass.getCanonicalName())
>>
>> println 'Are the two types equal? ' + superClass.equals(parameterClass)
>>
>>
>> *// This fails with:*
>>
>> *// 
>> org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException:
>>  Could*
>>
>> *// not find method registerTransform() for arguments [MyTransform@cac15ac] 
>> on object of type*
>>
>> *// com.android.build.gradle.AppExtension.*
>>
>> android.registerTransform(new MyTransform())
>>
>>
>> Why is this occuring? How can it be dealt with?
>>
>> The printlns suggest that the superclass of MyTransform is a different 
>> type from the first parameter to registerTransform(), but I don't 
>> understand how that could be. The names match, but somehow the types are 
>> not the same.
>>
>> Thanks.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to