Bottomnavigationview infalte error after migrating to androidx

问题: When I try to launch my app, my Mainactivity throws this error in the oncreate() method at "setContentView(R.layout.activity_main);" : java.lang.RuntimeException: Unable...

问题:

When I try to launch my app, my Mainactivity throws this error in the oncreate() method at "setContentView(R.layout.activity_main);" :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sanchez.worldgramproject/com.example.sanchez.worldgramproject.Fragments.MainActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class android.support.design.widget.BottomNavigationView

This Error appeared after migrating to androidx, after further inspection I noticed that the import statements in the Bottomnavigationview class were outdated (no androidx format, but old format). The Bottomnavigationview class file is read only, so I can't edit it.

gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.example.sanchez.worldgramproject"
        minSdkVersion 21
        targetSdkVersion 28
        multiDexEnabled true
        versionCode 0
        versionName "0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }
    }
}



dependencies {

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

    implementation 'com.github.madrapps:pikolo:1.1.6'
    implementation 'com.google.android.material:material:1.1.0-alpha02'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation'com.firebaseui:firebase-ui-storage:2.3.0'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'com.jakewharton:butterknife:8.8.1'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.exifinterface:exifinterface:1.0.0'
    implementation 'com.google.firebase:firebase-storage:16.0.5'
    implementation 'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.5'
    testImplementation 'junit:junit:4.12'

}


apply plugin: 'com.google.gms.google-services'

full stacktrace: https://pastebin.com/Yfek0YCH

Is there any way to change all import statements to fit the new androidx format? and how can I do this for all the other classes aswell?


回答1:

add this dependency:

dependencies {
    // https://mvnrepository.com/artifact/com.google.android.material/material
    api "com.google.android.material:material:1.0.0"
}

and use com.google.android.material.bottomnavigation.BottomNavigationView.

  • 发表于 2018-12-29 08:52
  • 阅读 ( 1191 )
  • 分类:网络文章

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除