无法使用影子插件为gradle重新定位依赖项

时间:2016-08-25 07:14:25

标签: android android-studio gradle jar aar

我有一个项目,它使用一个包含在aar文件中的库。问题是我的应用程序使用daager 1进行依赖注入,它使用Dagger 1,因为我使用的框架只与dagger 1兼容。问题是我需要使用的库使用Dagger 2进行依赖注入,所以当我添加库和我在我的应用程序gradle文件中添加依赖项它不起作用(正如预期的那样,因为Dagger 1和Dagger 2不能在开箱即用的同时使用),所以我试图重新定位Dagger 2依赖项影子插件。

我按照本教程了解如何操作http://fernandocejas.com/2016/08/03/android-dagger-1-and-2-living-together/

jar文件是在模块内部生成的,但是是空的,它们不包含Dagger 2的重命名文件。我从github https://github.com/android10/two-daggers下载了项目并且它可以工作但是我可以设法让它工作我的项目。

我创建的模块中的gradle文件与教程中的模板完全相同。你能看出我做错了吗?

shadow.gradle也是一个精确的副本。

唯一的区别是我的app.gradle来自我的应用程序

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.jakewharton.hugo'


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.xxx.xxx"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode Integer.parseInt("$APP_VERSION_CODE")
    versionName "$APP_VERSION_NAME"

    testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"

    // Enabling multidex support.
    multiDexEnabled true

}

testBuildType "instrumentation"

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

dexOptions{
    javaMaxHeapSize "3g"
    incremental true
}

testOptions {
    unitTests.returnDefaultValues = true
}



//Append version to Apk name
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def outputFile = output.outputFile
        if (outputFile != null && outputFile.name.endsWith('.apk')) {
            def fileName = outputFile.name.replace('app-', "AccessApp-")
            fileName = fileName.replace('.apk', "-" + "$APP_TAG" + ".apk")
            output.outputFile = new File(outputFile.parent, fileName)
        }
    }
}

packagingOptions {
    exclude 'LICENSE.txt'
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}

lintOptions {
    abortOnError false
    disable 'InvalidPackage'
}
}

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
dependencies {
    classpath "com.github.jengelman.gradle.plugins:shadow:1.2.3"
    classpath "com.neenbedankt.gradle.plugins:android-apt:1.4"
}
}

apply plugin: "com.github.johnrengelman.shadow"

dependencies {
    repositories {
        maven {
            url "http://xxx.xx.xxx:0000/xxx/xxxxxx/"
    }
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }

//Dagger 1
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.dagger:dagger:1.2.2'

//Dagger 2
apt project(path: ':two-daggers-compiler', transitive: false)
compile project(path: ':two-daggers-library', transitive: false)

compile fileTree(dir: 'libs', include: ['*.jar'])

//Unit Tests
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'
testCompile 'joda-time:joda-time:2.3'
testCompile 'com.squareup.okhttp3:mockwebserver:3.2.0'
testCompile('org.robolectric:robolectric:3.0') {
    exclude group: 'commons-logging', module: 'commons-logging'
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

// Android instrumentation test dependencies
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.4.1'
// Set this dependency to use JUnit 4 rules
androidTestCompile 'com.android.support.test:rules:0.4.1'
// Set this dependency to build and run Espresso tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support:support-annotations:23.4.0'

// Android dependencies
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'

//Rosie Framework
compile 'com.karumi.rosie:rosie:2.1.0'

// Connectivity library
compile 'com.xxx.connectivity:connectivity:1.0.0.013@aar'

// Maps
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.3'

// Hockey App
compile 'net.hockeyapp.android:HockeySDK:4.0.2'

//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:converter-scalars:2.0.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'

// Images
compile 'com.squareup.picasso:picasso:2.5.2'

// Google Play Billing
compile 'com.anjlab.android.iab.v3:library:1.0.31'
compile 'joda-time:joda-time:2.3'

// View pager indicator
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1@aar'
compile 'me.grantland:autofittextview:0.2.1'

// Event bus
compile 'org.greenrobot:eventbus:3.0.0'

//Roboto font
compile 'uk.co.chrisjenx:calligraphy:2.2.0'

//MixPanel
compile "com.mixpanel.android:mixpanel-android:4.8.7"

//Amazon
compile "com.amazonaws:aws-android-sdk-mobileanalytics:2.2.9"

//AppsFlyer
compile 'com.appsflyer:af-android-sdk:4.5.0@aar'

//Multidex
compile 'com.android.support:multidex:1.0.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'

// Smart tab layout
compile 'com.ogaclejapan.smarttablayout:library:1.6.1@aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1@aar'

// Permissions
compile 'com.karumi:dexter:2.2.2'

// AP Geolocation
compile 'com.fon.analytics:analytics-sdk:0.4.3'

compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'

// WPA sharing library
compile 'com.google.guava:guava:18.0'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'

//multiDex
compile 'com.android.support:multidex:1.0.1'
}

0 个答案:

没有答案