Github上的Maven存储库未下载传递依赖项

时间:2019-03-09 08:40:49

标签: android maven github aar transitive-dependency

我已经创建了一个Maven存储库,并将其上传到Github。当我将其添加为示例项目的依赖项时,gradle同步成功完成。但是,当我尝试运行该应用程序时,它因java.lang.NoClassDefFoundError崩溃。

链接到存储库:https://github.com/rjain90/sdk

示例项目代码:

项目build.gradle

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

buildscript {
    ext{
        kotlin_version = '1.3.20'
        realm_version = '5.8.0'
    }
    repositories {
        google()
        jcenter()
        maven { url "https://raw.githubusercontent.com/rjain90/sdk/master/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "io.realm:realm-gradle-plugin:$realm_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://raw.githubusercontent.com/rjain90/sdk/master/" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext{
    lifecycle_version = '2.0.0'
    android_support_version = '1.1.0-alpha01'
    legacy_support_version = '1.0.0'
    constraint_version = '1.1.3'

    retrofit_version = '2.4.0'
    dagger_version = '2.16'

    rxjava_version = '2.1.7'
    rxandroid_version = '2.0.1'
}

模块build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'realm-android'

// Load keystore
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    signingConfigs {
        release {
            keyAlias keystoreProperties['ANDROID_KEY_ALIAS']
            keyPassword keystoreProperties['ANDROID_KEY_PASSWORD']
            storeFile file(keystoreProperties['ANDROID_KEYSTORE_LOCATION'])
            storePassword keystoreProperties['ANDROID_STORE_PASSWORD']
        }
    }

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.bowstring.godworld"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            signingConfig signingConfigs.release
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

    implementation "androidx.appcompat:appcompat:$android_support_version"
    implementation "androidx.constraintlayout:constraintlayout:$constraint_version"

    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"

    implementation "com.google.dagger:dagger:$dagger_version"
    kapt "com.google.dagger:dagger-compiler:$dagger_version"

    implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"

    implementation "androidx.legacy:legacy-support-v4:$legacy_support_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'


    implementation 'com.squareup.picasso:picasso:2.71828'

    implementation 'com.cabfare.android:sdk:0.0.18@aar'
}

1 个答案:

答案 0 :(得分:0)

对于托管的GitHub,您可以将https://jitpack.io用作Maven存储库。

maven { url 'https://jitpack.io' }添加到项目build.gradle的{​​{1}}块中,然后在模块allprojects -> repositories中添加一个依赖项build.gradle

但是,您的两个发行版均为containing build errors。首先解决它们。