4

I want to include this Color Picker into my Android Studio project.

So I checked it out into a local folder, added it to my project with the "New->Import Module Dialog in Android Studio.

Then I added those 2 lines to my app.gradle file

apply plugin: 'com.android.application'
...
compile project(':colorpicker')

Here is the complete gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'

    defaultConfig {
        applicationId "com.mydomain.myapp"
        minSdkVersion 17
        targetSdkVersion 24
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile fileTree(include: ['dtp_library'], dir: 'libs')
    compile project(':libs:dtp_library')
    compile 'com.android.support:design:24.2.1'        
    compile project(':colorpicker')
}

But I keep getting the error

Error:Cause: buildToolsVersion is not specified.

If I do not add the first line to the gradle file (do it exactly like the color picker description said) then I get

Error:(3, 0) Could not find method android() for arguments [build_xxxxx] on project ':app' of type org.gradle.api.Project.

How to fix it?

2
  • I will try this and let u know although u can also create this with gridview and fab buttons Commented Oct 4, 2016 at 2:49
  • dude check out the solution , it's done Commented Oct 4, 2016 at 7:58

2 Answers 2

8

Follow the steps :

Open the build.gradle file of color picker module

enter image description here

so in your case add these lines to build.gradle file of colorpicker module

compileSdkVersion 24
buildToolsVersion '24.0.2'
6
  • I tried to add the buildToolsVersion. I went into that project folder, added it to the gradle file. But I get still the same error. Do I have to refresh this somehow. I did change it externally.
    – juergen d
    Commented Oct 3, 2016 at 17:17
  • The second option throws the second error mentioned in my question.
    – juergen d
    Commented Oct 3, 2016 at 17:17
  • @juergend try updated part with allprojects and compile dependency Commented Oct 3, 2016 at 17:29
  • And removing apply plugin: 'com.android.application' makes the app not having even a main module and is not runnable any more. And compile 'com.github.QuadFlask:colorpicker:0.0.12' is another color picker.
    – juergen d
    Commented Oct 3, 2016 at 18:03
  • I already tried that too. Now I ended up including the code directly into my project and it works. But thanks anyway.
    – juergen d
    Commented Oct 4, 2016 at 10:16
-1

Please put your buildToolVersion in double quotes like

buildToolsVersion "23.0.2"
1
  • That changes nothing.
    – juergen d
    Commented Oct 3, 2016 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.