Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Unable to configure in multimodule project #9

Closed
pabloppp opened this issue Nov 16, 2017 · 7 comments
Closed

Unable to configure in multimodule project #9

pabloppp opened this issue Nov 16, 2017 · 7 comments

Comments

@pabloppp
Copy link

pabloppp commented Nov 16, 2017

We're trying to use the OneSignal Android SDK in a multimodule Android app, and we're finding it impossible to configure.

Here's the steps I follow:

  • In the base app build.gradle file I add
plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}
  • In the presentation module build.gradle I add
    apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

When I try to build the gradle project I get the following error:

Error:Cannot choose between the following configurations of project :data:
  - debugApiElements
  - debugRuntimeElements
  - releaseApiElements
  - releaseRuntimeElements
All of them match the consumer attributes:
  - Configuration 'debugApiElements':
      - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
      - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
  - Configuration 'debugRuntimeElements':
      - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
      - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
  - Configuration 'releaseApiElements':
      - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
      - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
  - Configuration 'releaseRuntimeElements':
      - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
      - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.

Then if I try to change
implementation project(path: ':data') to implementation project(path: ':data', configuration: 'default')
I get

Error:Cannot change strategy of configuration ':presentation:kapt' after it has been resolved.

We're using Android Studio 3.0 and Gradle 4.3.1 with plugin 3.0.0

@Javieraeros
Copy link

Same issue here... Any solution?

@jkasten2
Copy link
Member

@pabloppp Can you provide each build.gradle in your project so we can look into producing the same error?

@myeonginwoo
Copy link

i hava same Issue.. plz....

@aldoborrero
Copy link

aldoborrero commented Nov 30, 2017

Happens same to me. Here I leave the build.gradles

For app:

plugins {
  id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {

  def config = rootProject.ext;
  compileSdkVersion config.androidCompileSdkVersion
  buildToolsVersion config.androidBuildToolsVersion
  defaultConfig {
    applicationId config.androidApplicationId

    minSdkVersion config.androidMinSdkVersion
    targetSdkVersion config.androidTargetSdkVersion

    versionCode config.androidVersionCode
    versionName config.androidVersionName

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    vectorDrawables.useSupportLibrary = true
    multiDexEnabled true
  }

  defaultConfig {
    manifestPlaceholders = [onesignal_app_id: "", onesignal_google_project_number: "REMOTE"]
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
  }

  // Flag to tell aapt to keep the attribute ids around
  aaptOptions {
    additionalParameters "--no-version-vectors"
  }

  signingConfigs {
    debug {
      storeFile file("path")
      keyAlias "alias"
    }

    release {
      storeFile file("path")
      keyAlias "alias"
    }

    apply from: 'path', to: debug
    apply from: 'path', to: release
  }

  lintOptions {
    abortOnError false
  }

  buildTypes.all { buildType ->
    // Common constants values
    
    // buildConfigVariables
  }

  buildTypes {
    debug {
      minifyEnabled false
      debuggable true

      // buildConfigVariables
      
      signingConfig signingConfigs.debug
    }

    debugRelease {
      minifyEnabled false
      debuggable true

      // buildConfigVariables

      signingConfig signingConfigs.debug
    }

    release {
      minifyEnabled false
      debuggable false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

      // buildConfigVariables

      signingConfig signingConfigs.release
    }
  }
}

dependencies {
  def dependencies = rootProject.ext.dependencies

  implementation dependencies.playServicesLocation
  implementation dependencies.dexter

  implementation dependencies.stetho
  implementation dependencies.stethoOkhttp
  implementation dependencies.multidex

  implementation dependencies.dagger
  annotationProcessor dependencies.daggerCompiler
  implementation dependencies.javaxAnnotation

  implementation dependencies.butterknife
  annotationProcessor dependencies.butterknifeProcessor

  implementation dependencies.awsCore
  implementation dependencies.awsMobileAnalytics

  implementation dependencies.localizationActivity
  implementation dependencies.bugfender

  implementation dependencies.oneSignal

  implementation(dependencies.crashlytics) {
    transitive = true;
  }

  compile project(path: ':library')
}

For library:

apply plugin: 'com.android.library'
apply from: 'buildsystem/dependencies.gradle'

android {
  compileSdkVersion rootProject.ext.androidCompileSdkVersion
  buildToolsVersion rootProject.ext.androidBuildToolsVersion

  lintOptions {
    abortOnError false
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
  }

  defaultConfig {
    minSdkVersion rootProject.ext.androidMinSdkVersion
    targetSdkVersion rootProject.ext.androidTargetSdkVersion

    versionCode 1001

    vectorDrawables.useSupportLibrary = true
  }

  buildTypes {
    debug {
      // buildConfigVariables
    }

    debugRelease {
      // buildConfigVariables
    }

    release {
      // buildConfigVariables
    }
  }

  buildTypes.all { buildType ->
    // Common constants values
    // buildConfigVariables
  }
}

dependencies {
  def dependencies = project.ext.dependencies

  compile dependencies.appCompat
  compile dependencies.supportAnnotation
  compile dependencies.recyclerView
  compile dependencies.cardView
  compile dependencies.design

  compile dependencies.picasso
  compile dependencies.picassoOkhttp3
  compile dependencies.simpleStorage
  
  // More compile dependencies
}

The comments // buildConfigVariables has groups of those properties but not copied for obvious reasons and same happens in // more compile dependencies

Using Android Studio 3.0, Gradle 4.1 with plugin 3.0.1.

Ping me if you need more information to track down this bug. The behavior I've obtained is the same as @pabloppp

jkasten2 added a commit that referenced this issue Dec 8, 2017
* Error due to the Android plugin not able to find a matching flavor in the sub project when compiling the top level project
* We can't just skip the 'compile' named configuration on every variant as this is successful for most tasks.
* In the future hunting down the exact task, variants, and / or configurations could clean up this try-catch.
* Added multimodule test support as well as created a test for this case
* Resolves #9
jkasten2 added a commit that referenced this issue Dec 8, 2017
* Error due to the Android plugin not able to find a matching flavor in the sub project when compiling the top level project
* We can't just skip the 'compile' named configuration on every variant as this is successful for most tasks.
* In the future hunting down the exact task, variants, and / or configurations could clean up this try-catch.
* Added multimodule test support as well as created a test for this case
* Resolves #9
@jkasten2
Copy link
Member

jkasten2 commented Dec 8, 2017

@pabloppp @Javieraeros @myeonginwoo @aldoborrero Thanks for reporting this issue. Just fix this issue in the commit above. We will create a release next week with this fix included.

@jkasten2
Copy link
Member

jkasten2 commented Dec 8, 2017

It is now released in version 0.8.0.

@adarshsonkar
Copy link

Then if I try to change
implementation project(path: ':data') to implementation project(path: ':data', configuration: 'default')

How we change
implementation project(path: ':data') to implementation project(path: ':data', configuration: 'default')

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

No branches or pull requests

6 participants