Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Error while adding spoon plugin to build.gradle #80

Open
MateuszGajowski opened this issue Nov 14, 2015 · 12 comments
Open

Error while adding spoon plugin to build.gradle #80

MateuszGajowski opened this issue Nov 14, 2015 · 12 comments

Comments

@MateuszGajowski
Copy link

While adding line apply plugin: 'spoon' to build.gradle(Module: app) and syncing I have that error:
"Error:Cannot add task ':app:spoonDebugAndroidTest' as a task with that name already exists."
I found why this is happening. It's related to this in build.gradle:

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi', 'armeabi-v7a', 'mips'
            universalApk false
        }
    }
@roman-mazur
Copy link
Contributor

Sorry @Mateuszg7. I missed this when you posted the issue. The problem is that this plugin does not really support APK splits and expects one possible output for each variant.

@michael-mohemian
Copy link

👍

@saruye
Copy link

saruye commented Mar 20, 2017

we also have this issue. is there any way around it? We are doing:
afterEvaluate { apply plugin: 'spoon' }
in the debug build type. But it still throw the task already exists error when assembling the release apk.
Is there any good workaround to only apply spoon for debug where split apk is not enabled?

@saruye
Copy link

saruye commented Mar 20, 2017

just as a reference for anyone with the same problem, we "solved" it now with this piece of code:
afterEvaluate { if(gradle.startParameter.taskNames.contains("spoon")){ apply plugin: 'spoon' } }

@barontxu
Copy link

barontxu commented Apr 7, 2017

@saruye i have the same problem too.where in gradle file did you put the "afterEvaluate { if(gradle.startParameter.taskNames.contains("spoon")){ apply plugin: 'spoon' } }"?

@saruye
Copy link

saruye commented Apr 7, 2017

@barontxu
in the buildTypes
buildTypes { release { ... } debug { ... afterEvaluate { if(gradle.startParameter.taskNames.contains(":app:spoon") || gradle.startParameter.taskNames.contains("spoon")){ apply plugin: 'spoon' } } } }

@mandrachek
Copy link

So, I've been strugging with this problem for awhile. The app is using APK splits, and we've been using the universal apk for testing and deploying to fabric beta (with some hacks to send the the universal apk), but haven't had any success getting it to work with spoon-gradle.

By combining the approach here - https://code.google.com/p/android/issues/detail?id=76469 - that is to say, turning off split apk's for debug builds, combined with using afterEvaluate taken from here, I've now got:

android {

   buildTypes {
      debug {
         project.ext.disableAbiSplit = true
      }
      release {
         project.ext.disableAbiSplit = false
      }
   }

   splits {
      abi {
         enable !project.hasProperty("disableAbiSplit") && !project.ext.disableAbiSplit
         reset()
         include('arm64-v8a','armeabi-v7a','x86_64','x86')
         universalApk !project.hasProperty("disableAbiSplit") && !project.ext.disableAbiSplit
      }
   }

}

afterEvaluate {
   if (!(!project.hasProperty("disableAbiSplit") && !project.ext.disableAbiSplit)) {
      apply plugin: 'spoon'
      spoon {
         // spoon options
      }
   }
}

So:

  • Debug builds are not split and have spoon enabled.
  • Release builds are split and do not have spoon enabled.

@barontxu
Copy link

@saruye thank you!

@barontxu
Copy link

@mandrachek seems like a great idea that fit my situation, i'll take the piece of code into my project, thank you!

@michael-mohemian
Copy link

I solved it in a very similar way as @mandrachek. I am not sure if I need afterEvaluate, at least it works without.

def useSplitApk = project.hasProperty('splitApk')

if (!useSplitApk) {
  apply plugin: 'spoon'

  spoon {
    debug = true
    sequential = true
    grantAllPermissions = true
  }
}
android {
...
  splits {
    abi {
      enable useSplitApk
      reset()
      include "arm64-v8a", "armeabi-v7a"
      universalApk true
    }
  }
...
}

I am using split apk only to build a release ./gradlew assembleRelease -PsplitApk. For all other cases I am not defining the property, so split APK is not applied and spoon runs fine.

@barontxu
Copy link

@michael-mohemian thanks for sharing!Seems like a graceful idea.

@barontxu
Copy link

@michael-mohemian man your answer is awesome, the after evaluate answer makes spoon config unavailable but yours works great.Thanks so much for sharing.

koral-- added a commit to koral--/android-gradle-jenkins-plugin that referenced this issue Apr 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants