9

Android Studio won't let me build this. It says com.mixpanel.blahblahblah is not found. com.mixpanel.blahblahblah comes from mavenCentral() I know the problem is because it doesn't recognize mavenCentral() because it only recognizes the other repo. How can I include both and get this project working?

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

buildscript {
    repositories {
        maven { url 'http://download.crashlytics.com/maven' }
    }

    dependencies {
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}


repositories {
    maven { url 'http://download.crashlytics.com/maven' }
    mavenCentral()
}


android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "co.dilmile.dilmile"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.parse.bolts:bolts-android:1.1.2'
    compile 'com.loopj.android:android-async-http:1.4.6'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.facebook.android:facebook-android-sdk:3.20.0'
    compile 'com.android.support:support-v4:21.0.3'
    compile 'org.roboguice:roboguice:3.+'
    compile 'com.google.code.findbugs:jsr305:1.3.9'
    provided 'org.roboguice:roboblender:3.+'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.mixpanel.android:mixpanel-android:4.5.3'
}
bharv14
  • 493
  • 1
  • 6
  • 15
  • If you comment out the `compile 'com.mixpanel.android:mixpanel-android:4.5.3'` line, does the rest of the app build? If so, your problem is not the `mavenCentral()` statement directly, as most everything else in your `dependencies` comes from there. – CommonsWare Jan 23 '15 at 01:06
  • yes it builds without that line. But I only added mavenCentral() just now before I added the com.mixpanel. If I remove mavenCentral() and com.mixpanel then it works fine and the other dependencies build. – bharv14 Jan 23 '15 at 01:24

3 Answers3

7

I think you should add maven central to your buildscript repositories. I have it like this and works no problem:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
    }
...
}

allprojects {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
    }
}

Edit: I believe your gradle file should be

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

buildscript {
    repositories {
        maven { url 'http://download.crashlytics.com/maven' }
        mavenCentral()
    }

    dependencies {
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    }
}


repositories {
    maven { url 'http://download.crashlytics.com/maven' }
    mavenCentral()
}


android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "co.dilmile.dilmile"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.parse.bolts:bolts-android:1.1.2'
    compile 'com.loopj.android:android-async-http:1.4.6'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.facebook.android:facebook-android-sdk:3.20.0'
    compile 'com.android.support:support-v4:21.0.3'
    compile 'org.roboguice:roboguice:3.+'
    compile 'com.google.code.findbugs:jsr305:1.3.9'
    provided 'org.roboguice:roboblender:3.+'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.mixpanel.android:mixpanel-android:4.5.3'
}
darnmason
  • 2,672
  • 1
  • 17
  • 23
1

Since now Android Studio use jcenter instead of maven, you should migrate the repository by change mavenCentral to jcenter

buildscript {
    repositories {
        //old
        //mavenCentral()
        //new
        jcenter()
        maven { url 'http://download.crashlytics.com/maven' }
    }
...
}

allprojects {
    repositories {
        //old
        //mavenCentral()
        //new
        jcenter()
        maven { url 'http://download.crashlytics.com/maven' }
    }
}

jcenter is more complete and faster than mavenCentral

HendraWD
  • 2,984
  • 2
  • 31
  • 45
0

jcenter will mirror mavenCentral repository so you can use jcenter if you encounter problem with mavenCentral.

And try to avoid use + in declare version number of dependency. It's might be problem too.

I recently write an dependency management tool to find out which dependency are out of date, you can give it a try.

https://github.com/Jintin/andle

Jintin
  • 1,426
  • 13
  • 22