Android build failed after installing navigation component

  android, androidx, build.gradle, gradle, navigation

I’m trying to build android project with navigation component.
My android project is written by both java and kotlin with some third party libraries(some library is very old).

When I add the following code into my app’s build.gradle file in order to install navigation component as gogole site described([navigation component][1])

dependencies {
  def nav_version = "2.3.3"

  // Java language implementation
  implementation "androidx.navigation:navigation-fragment:$nav_version"
  implementation "androidx.navigation:navigation-ui:$nav_version"

  // Kotlin
  implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
  implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

  // Feature module Support
  implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"

  // Testing Navigation
  androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"

  // Jetpack Compose Integration
  implementation "androidx.navigation:navigation-compose:1.0.0-alpha05"
}

After that my project build failed with following error.

Execution failed for task ':<<ProjectName>>:transformClassesWithByteCodeTransformForDebug'.
> java.util.concurrent.ExecutionException: java.lang.RuntimeException: cannot find META-INF.versions.9.module-info: module-info found in META-INF/versions/9/module-info.class

The module is java9 feature and module-info.class seems it is required with java9 even I compile my android project with java8.

I also added following statement as some back articles explained, but it’s not helped.

packagingOptions {
        exclude "**/module-info.class"
    }

All Dependencies:

dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    compile fileTree(include: ['*.jar'], dir: 'libs')

    // Support library
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'

    // viewmodel
    implementation "androidx.lifecycle:lifecycle-reactivestreams:2.1.0"
    implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"
    implementation "androidx.lifecycle:lifecycle-runtime:2.1.0"
    implementation "androidx.lifecycle:lifecycle-common-java8:2.1.0"
    androidTestImplementation "androidx.arch.core:core-testing:2.1.0"

    // room
    implementation "androidx.room:room-runtime:2.2.3"
    kapt "androidx.room:room-compiler:2.2.3"
    implementation "androidx.room:room-rxjava2:2.2.3"
    testImplementation "androidx.room:room-testing:2.2.3"
    androidTestImplementation "androidx.room:room-testing:2.2.3"

    // GMS
    implementation "com.google.android.gms:play-services-maps:15.0.2"
    implementation "com.google.android.gms:play-services-location:15.0.2"
    implementation "com.google.android.gms:play-services-tagmanager:16.0.8"
    // for Places SDK for Android
    implementation "com.google.android.libraries.places:places-compat:1.1.0"

    implementation 'com.google.maps.android:maps-ktx:1.5.0'
    implementation 'com.google.maps.android:maps-utils-ktx:1.5.0'

    // Google
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.google.guava:guava:14.0.1'

    // Directions API
    implementation "com.google.maps:google-maps-services:0.2.11"

    // GreenDao
    compile 'de.greenrobot:greendao:1.3.7'

    // Util
    compile 'com.deploygate:sdk:3.1'

    // Firebase
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
    implementation "com.google.firebase:firebase-dynamic-links:17.0.0"
    implementation "com.google.firebase:firebase-config:17.0.0"
    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
    implementation 'com.google.firebase:firebase-analytics:17.6.0'

    // AppsFlyer
    implementation 'com.appsflyer:af-android-sdk:[email protected]'
    implementation 'com.android.installreferrer:installreferrer:1.0'

    // Retrofit2
    compile "com.squareup.retrofit2:retrofit:2.3.0"
    compile "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
    compile "com.squareup.retrofit2:converter-moshi:2.3.0"
    implementation("com.squareup.retrofit2:converter-simplexml:2.3.0") {
        exclude group: 'xpp3', module: 'xpp3'
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
    }
    compile "com.squareup.retrofit2:retrofit-mock:2.3.0"
    compile "com.squareup.okhttp3:okhttp:3.8.0"
    testCompile "com.squareup.okhttp3:mockwebserver:3.8.0"
    compile "com.squareup.okhttp3:logging-interceptor:3.8.0"
    compile "com.squareup.moshi:moshi:1.5.0"
    compile "com.squareup.moshi:moshi-kotlin:1.5.0"
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'io.reactivex.rxjava2:rxkotlin:2.2.0'

    // dagger
    implementation "com.google.dagger:dagger:2.25.4"
    implementation "com.google.dagger:dagger-android:2.25.4"
    implementation "com.google.dagger:dagger-android-support:2.25.4"
    kapt "com.google.dagger:dagger-compiler:2.25.4"
    kapt "com.google.dagger:dagger-android-processor:2.25.4"
    kaptTest "com.google.dagger:dagger-compiler:2.25.4"
    kaptAndroidTest "com.google.dagger:dagger-compiler:2.25.4"
    kaptAndroidTestDebug "com.google.dagger:dagger-compiler:2.25.4"

    implementation('com.github.bumptech.glide:glide:4.7.1') {
        exclude group: 'com.android.support'
    }
    implementation('jp.wasabeef:glide-transformations:3.3.0'){
        exclude group: 'com.android.support'
    }
    kapt 'com.github.bumptech.glide:compiler:4.5.0'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61"
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.61"

    // Kotlin Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-rx2:1.3.3'

    implementation 'com.jakewharton.timber:timber:4.6.0'

    // RxRelay
    implementation 'com.jakewharton.rxrelay3:rxrelay:3.0.0'

    // for Test
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test:rules:1.2.0'

    testCompile 'org.powermock:powermock-api-mockito2:1.7.3'
    testCompile 'org.powermock:powermock-module-junit4:1.7.3'
    testCompile 'org.mockito:mockito-core:2.19.0'
    androidTestCompile 'org.mockito:mockito-android:2.19.0'

    compile 'com.ethanhua:skeleton:1.0.0'

    //flexbox
    implementation 'com.google.android:flexbox:1.0.0'
    
    // runtime permission
    implementation "com.github.hotchemi:permissionsdispatcher:3.3.1"
    kapt "com.github.hotchemi:permissionsdispatcher-processor:3.3.1"

    // JTS
    implementation 'org.locationtech.jts:jts-core:1.17.1'

    // デバッグ用
    debugImplementation 'com.facebook.stetho:stetho:1.5.1'

    def nav_version = "2.3.3"

    // Java language implementation
    implementation "androidx.navigation:navigation-fragment:$nav_version"
    implementation "androidx.navigation:navigation-ui:$nav_version"

    // Kotlin
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

    // Feature module Support
    implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"

    // Testing Navigation
    androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"

    // Jetpack Compose Integration
    implementation "androidx.navigation:navigation-compose:1.0.0-alpha05"
}

Could you please how to solve this problem.

Thanks
[1]: https://developer.android.com/guide/navigation/navigation-getting-started?hl=ja

Source: Android Questions

LEAVE A COMMENT