Skip to content

java.lang.NoClassDefFoundError: io.grpc.ManagedChannelBuilder #3010

@KrishHari

Description

@KrishHari

What version of gRPC are you using?

v1.3.0

What JVM are you using (java -version)?

1.8.0_45

What did you do?

I created a library project that sends data to server over GPRC. I tested it as a module dependency on a sample project and it is working fine. When I take the aar file and add it as a dependency on apps, the app is crashing.

What did you expect to see?

The app should run without crashing as it runs when I add it as a normal module dependency.

What did you see instead?

I get a crash with trace

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.tuktuk, PID: 7362
java.lang.NoClassDefFoundError: io.grpc.ManagedChannelBuilder

My library project gradle file looks like below

apply plugin: 'com.android.library'
apply plugin: 'com.google.protobuf'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        consumerProguardFiles 'proguard-project.pro'

    }
}

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.2.0'
    }
    plugins {
        javalite {
            artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
        }
        grpc {
            artifact = 'io.grpc:protoc-gen-grpc-java:1.3.0' // CURRENT_GRPC_VERSION
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                javalite {}
                grpc {
                    // Options added to --grpc_out
                    option 'lite'
                }
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'io.grpc:grpc-okhttp:1.3.0'
    compile 'io.grpc:grpc-protobuf-lite:1.3.0'
    compile 'io.grpc:grpc-stub:1.3.0'
    compile 'javax.annotation:javax.annotation-api:1.2'
    compile 'com.google.firebase:firebase-messaging:9.8.0'
    compile 'com.google.code.gson:gson:2.8.0'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions