Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle-android-scala-plugin: error after following the tutorial

Tags:

android

gradle

I followed this link, and then run gradle build.

https://github.com/saturday06/gradle-android-scala-plugin

It raised error of:

 gradle build --daemon -s

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'hello-scaloid-gradle-master'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find com.android.support:multidex:1.0.0.
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/support/multidex/1.0.0/multidex-1.0.0.pom
         https://jcenter.bintray.com/com/android/support/multidex/1.0.0/multidex-1.0.0.jar
     Required by:
         :hello-scaloid-gradle-master:unspecified

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'hello-scaloid-gradle-master'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:91)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:86)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:65)

gradle setting is:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:1.0.0-rc1"
        classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.3.1"
    }
}

repositories {
    jcenter()
}

apply plugin: "com.android.application"
apply plugin: "jp.leafytree.android-scala"

android {
    compileSdkVersion "android-21"
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 21
        testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
        versionCode 1
        versionName "1.0"
    }

    sourceSets {
        main {
            scala {
                srcDir "src/main/scala" // default: "src/main/scala"
            }
        }

        androidTest {
            scala {
                srcDir "src/androidTest/scala" // default: "src/androidTest/scala"
            }
        }
    }

    dexOptions {
        preDexLibraries false
    }
}

dependencies {
    compile "com.android.support:multidex:1.0.0"
    compile "org.scala-lang:scala-library:2.11.4"
}

tasks.withType(ScalaCompile) {
    scalaCompileOptions.deprecation = false
    scalaCompileOptions.additionalParameters = ["-feature"]
}

afterEvaluate {
    tasks.matching {
        it.name.startsWith("dex")
    }.each { dx ->
        if (dx.additionalParameters == null) {
            dx.additionalParameters = []
        }
        dx.additionalParameters += "--multi-dex"
        dx.additionalParameters += "--main-dex-list=$rootDir/main-dex-list.txt".toString()
    }
}
like image 930
Daniel Wu Avatar asked Nov 09 '22 22:11

Daniel Wu


1 Answers

I suspect that you put all the configuration into your app level build.gradle.

Maybe try it like this ->

project/build.gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.3'
        classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.4"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

project/app/build.gradle

apply plugin: 'com.android.application'
apply plugin: "jp.leafytree.android-scala"

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "your.apps.id"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "org.scala-lang:scala-library:2.11.6"
    compile 'com.android.support:appcompat-v7:22.0.0'
}
like image 127
Ostkontentitan Avatar answered Nov 14 '22 21:11

Ostkontentitan