2

I have created a maven repository and uploaded it to Github. When I add it as a dependency to a sample project, the gradle sync completes successfully. But when I try to run the app, it crashes with a java.lang.NoClassDefFoundError.

Link to repository: https://github.com/rjain90/sdk

Sample project code:

Project 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'
}

Module 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'
}
Rishabh Jain
  • 297
  • 2
  • 13

1 Answers1

0

For GitHub hosted, you can use https://jitpack.io as a Maven repository.

Add maven { url 'https://jitpack.io' } into the project build.gradle's allprojects -> repositories block, then in your module build.gradle, add a dependency implementation 'com.github.rjain90:sdk:0.0.17', for example.

However, your two releases are both containing build errors. Solve them first.

Geno Chen
  • 4,916
  • 6
  • 21
  • 39
  • I've removed the errors and tried again with Jitpack but it still doesn't work. – Rishabh Jain Mar 13 '19 at 10:08
  • @RishabhJain Did you "doesn't work" with `ERROR: Failed to resolve: Android-SDK-Core-Source:coresdk:unspecified`? – Geno Chen Mar 13 '19 at 10:53
  • Yes and I tried to resolve it by using implementation 'com.github.rjain90:sdk:0.0.17@aar' but ran into the NoClassDefFoundError again – Rishabh Jain Mar 14 '19 at 08:27
  • Yes. You can use `implementation 'com.github.rjain90:sdk:1.0'`, then you will found your SDK has the dependency `com.estimote:sdk:1.0.3` which depends on `Android-SDK-Core-Source:coresdk:unspecified` which throws the error. After you found where the `Android-SDK-Core-Source:coresdk:unspecified` is, the question is solved. – Geno Chen Mar 14 '19 at 15:29
  • As of [my search](https://github.com/Estimote/Android-SDK#introduction), "All the proximity monitoring features of this SDK have been deprecated and are no longer supported. Instead, we strongly recommend [Estimote Proximity SDK](https://github.com/Estimote/Android-Proximity-SDK) for Android powered by Estimote Monitoring. ", which have no dependency problems as of the [Maven said](https://mvnrepository.com/artifact/com.estimote/proximity-sdk/1.0.4). – Geno Chen Mar 14 '19 at 16:01
  • Conclusion: At the `pom.xml` of your SDK, modify `com.estimote`'s `artifactId` from `sdk` to `proximity-sdk`, and use the newest version `1.0.4`, then let Jitpack rebuild your SDK, then you will probably successfully use your SDK in your project. – Geno Chen Mar 14 '19 at 16:04
  • @RishabhJain The same error with what kind of detail? :-( – Geno Chen Mar 19 '19 at 12:23