I'm trying to add navigation drawer to my android application but it continuously throws error about error inflation. I've added the support library as well. The xml files doesn't shows the layout, it just shows a grey background with android.support.drawerlayout written on it. Like it does when it can't find that library. I've tried searching on the internet but couldn't find any results that could help me.
Error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.comsian.safetyalert/com.comsian.safetyalert.HomeActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3312)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:113)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:71)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:226)
at android.app.ActivityThread.main(ActivityThread.java:7189)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.widget.DrawerLayout" on path: DexPathList[[zip file "/data/app/com.comsian.safetyalert-J3HAuRvzmTnad2_jIuQroQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.comsian.safetyalert-J3HAuRvzmTnad2_jIuQroQ==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
Caused By:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.comsian.safetyalert/com.comsian.safetyalert.HomeActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.widget.DrawerLayout" on path: DexPathList[[zip file "/data/app/com.comsian.safetyalert-J3HAuRvzmTnad2_jIuQroQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.comsian.safetyalert-J3HAuRvzmTnad2_jIuQroQ==/lib/arm64, /system/lib64]]
Build.grade(app) file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.google.firebase:firebase-auth:19.0.0"
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'android.arch.navigation:navigation-fragment:1.0.0'
implementation 'android.arch.navigation:navigation-ui:1.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
if you are using androidx then use
<androidx.drawerlayout.widget.DrawerLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"></androidx.drawerlayout.widget.DrawerLayout>
once this works also replace below dependencies with androidx
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha08'
Related
I am having trouble inflating a coordinator layout. This is the most of the logcat(let me know if you need to see more)
2019-06-17 00:06:50.530 19494-19494/com.vitrixhealth.datacollection E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vitrixhealth.datacollection, PID: 19494
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vitrixhealth.datacollection/com.vitrixhealth.datacollection.ui.patients.PatientsActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2884)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2963)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1655)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6665)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:772)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.CoordinatorLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/base.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_resources_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.vitrixhealth.datacollection-U3yD_XQl1CDFy1VwoToeOQ==/lib/arm64, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.vitrixhealth.datacollection.ui.patients.patientslist.PatientsListFragment.onCreateView(PatientsListFragment.kt:43)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2595)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:880)
at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2096)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1870)
I have this in my build.gradle file:
implementation 'com.google.android.material:material:1.0.0'
Is there anything else I need to add to my build.gradle to be able to use the coordinator layout?
add this to your dependencies:
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
I'm trying to create a floating button in android studio on a Google map. The objective of the button is to update marks on the map, but when trying to inflate it gives me the following error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kakao/com.example.kakao.MapsActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3297)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3405)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1994)
at android.os.Handler.dispatchMessage(Handler.java:108)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #12: Error inflating class android.support.design.widget.FloatingActionButton
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.design.widget.FloatingActionButton
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.FloatingActionButton" on path: DexPathList[[zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/base.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_resources_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.kakao-OUJ-bqVa2zcpC7rS80Bifg==/lib/arm64, /system/lib64, /vendor/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.kakao.MapsActivity.onCreate(MapsActivity.java:76)
at android.app.Activity.performCreate(Activity.java:7383)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1218)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3250)
The button in xml:
<android.support.design.widget.FloatingActionButton
android:id="#+id/my_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="#drawable/ic_alert_circle_white_36dp" />
The reference and inflated in java:
FloatingActionButton my_fab = (FloatingActionButton) findViewById(R.id.my_fab);
my_fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Snackbar.make(view, "Tocaste el FAB", Snackbar.LENGTH_LONG).show();
}
});
My dependencies:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.material:material:1.0.0'
You should use app:srcCompat instead of android:src.
app:srcCompat="#drawable/ic_alert_circle_white_36dp"
The correct xml will be
<android.support.design.widget.FloatingActionButton
android:id="#+id/my_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:srcCompat="#drawable/ic_alert_circle_white_36dp" />
you are working with androidx library so the class you should using for FAB in your xml is :
com.google.android.material.floatingactionbutton.FloatingActionButton
instead of :
android.support.design.widget.FloatingActionButton
I made a migration to Androidx but after the migration, I'm getting the following error:
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
I studied all the resources and migrated to Androidx, but I still have a lot of problems.
Can someone help me?
I will post the sections of the code below.
--------- beginning of crash ---------
2019-01-23 09:47:34.171 17578-17578/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.bijac.com.bijac, PID: 17578
java.lang.RuntimeException: Unable to start activity ComponentInfo{ir.bijac.com.bijac/ir.bijac.com.bijac.TestActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ir.bijac.com.bijac.BaseActivity.onCreate(BaseActivity.java:43)
at ir.bijac.com.bijac.TestActivity.onCreate(TestActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/coreui/R$attr;
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:202)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ir.bijac.com.bijac.BaseActivity.onCreate(BaseActivity.java:43)
at ir.bijac.com.bijac.TestActivity.onCreate(TestActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
2019-01-23 09:47:34.171 17578-17578/? E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.coreui.R$attr" on path: DexPathList[[zip file "/data/app/ir.bijac.com.bijac-2/base.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_dependencies_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_0_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_1_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_2_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_3_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_4_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_5_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_6_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_7_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_8_apk.apk", zip file "/data/app/ir.bijac.com.bijac-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/ir.bijac.com.bijac-2/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 27 more
build gradle:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
applicationId "ir.bijac.com.bijac"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestUtil 'androidx.test:orchestrator:1.1.1'
configurations.all { resolutionStrategy.force 'com.android.support:support-v4:28.0.0' }
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation "cz.msebera.android:httpclient:4.4.1.2"
implementation 'org.apache.httpcomponents:httpcore:4.4.10'
implementation 'com.androidadvance:topsnackbar:1.1.1'
implementation 'co.ronash.android:pushe-base:1.4.1'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
--------- activity_main.xml ---------
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
You are likely to have a reference to android.support.design.widget.CoordinatorLayout in some of your xml layout files.
Press CTRL + SHIFT + F or go to Edit/Find/Find in Path and just search for android.support.design.widget.CoordinatorLayout and replace it with androidx.coordinatorlayout.widget.CoordinatorLayout.
You may use CTRL + SHIFT + R or Edit/Find/Replace in Path instead to replace all matches at once.
in XML file, replace
androidx.appcompat.widget.RecyclerView
with:
androidx.recyclerview.widget.RecyclerView
It looks like app is trying to inflate android.support.design.widget.CoordinatorLayout from support library instead of androidx library. Try doing following things and check if it works.
Do clean and build your app.
Try Invalidate Cache and Restart.
Also make sure you are not using coordinator layout from support library anywhere else.
Make sure in your activities and fragments there is no reference to the old support libraries in the imports section.Make sure all layouts are not using the ols support widgets too.
Add these two lines in gradle.properties file to automatically migrate existing project to Androix.
android.useAndroidX=true
android.enableJetifier=true
more info here -> https://developer.android.com/jetpack/androidx/migrate
this will automatically solve ur problem.
Simply Just go to XML file (in `res/layout) and replace
androidx.appcompat.widget.RecyclerView
with:
androidx.recyclerview.widget.RecyclerView
You have to replace all android.support.design classes with new classes of AndroidX. Here are the links with the correspondences between old and new classes:
https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
https://developer.android.com/jetpack/androidx/migrate/class-mappings
Fore more you can read the guide how to migrate to AndroidX:
https://developer.android.com/jetpack/androidx/migrate
Edit --> Find --> Find in Path
Replace all of following
android.support.v7.widget.CardView
--> androidx.cardview.widget.CardView
android.support.design.widget.TextInputLayout
--> com.google.android.material.textfield.TextInputLayout
android.support.v4.widget.NestedScrollView
--> androidx.core.widget.NestedScrollView
android.support.v4.view.ViewPager
--> androidx.viewpager.widget.ViewPager
androidx.constraintlayout.ConstraintLayout
--> androidx.constraintlayout.widget.ConstraintLayout
androidx.core.view.ViewPager
--> androidx.viewpager.widget.ViewPager
androidx.core.widget.SwipeRefreshLayout
--> androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android.support.design.widget.AppBarLayout
--> com.google.android.material.appbar.AppBarLayout
android.support.design.widget.CollapsingToolbarLayout
--> com.google.android.material.appbar.CollapsingToolbarLayout
android.support.v7.widget.Toolbar
--> androidx.appcompat.widget.Toolbar
Today I tried to initialize "ChatSDK" and had a few problems. Now, if I want to start my app it is crashing all time. I found this problem:
E/androidRuntime: FATAL EXEPTION: main Process: com.inspredunity.gm.germanminelife, PID: 2605
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inspredunity.gm.germanminelife/com.inspredunity.gm.germanminelife.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class android.support.design.widget.FloatingActionButton
Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class android.support.design.widget.FloatingActionButton
E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.FloatingActionButton" on path: DexPathList[[zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/base.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_resources_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/base.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_dependencies_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_resources_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_0_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_1_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_2_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_3_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_4_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_5_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_6_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_7_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_8_apk.apk!/lib/x86, /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_slice_9_apk.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
E/AndroidRuntime: at com.inspredunity.gm.germanminelife.MainActivity.onCreate(MainActivity.java:37)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.inspredunity.gm.germanminelife-EdgnsjPOMDBCjzzyKZd6KA==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
Here are my Gradle dependencies:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplemenstation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.android.support:design:28.0.0'
implementation 'co.chatsdk.chatsdk:chat-sdk-core:4.4.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-ui:4.4.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-adapter:4.4.8'
implementation 'co.chatsdk.chatsdk:chat-sdk-firebase-file-storage:4.4.8'
implementation 'com.android.support:recyclerview-v7:28.0.0'
I tired every fix suggestion which I found at the internet but nothing worked. I hope you guys can help me.
If you need my MainActivity or my gradle file(s) please say it!
Thank you in advance!
FIXED
For any person still having this problem after febuary 2019, if you are using androidx or the new material libraries, This problem is happening because Google changed the naming format of the libraries using androidx.. you can check this official mapping https://developer.android.com/jetpack/androidx/migrate/artifact-mappings
and search for your library to see what the new name is, now that Google is in androidx
In your case, your library "android.support.design.widget.FloatingActionButton" in your xml file, is now called as using com.google.android.material.floatingactionbutton.FloatingActionButton
Android Support Library is no longer maintained. It is therefore recommended to use AndroidX Library instead.
FloatingActionButton using AndroidX:
1. Add in gradle:
implementation 'com.google.android.material:material:1.1.0'
2. Add in your layout:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:src="#drawable/share_button"
android:layout_margin="16dp" />
Did you add android support library to your project? If not try this one :
implementation "com.android.support:design:28.0.0"
For more details about how to setup support library, you can check this
https://developer.android.com/topic/libraries/support-library/setup
Add this into your gradle :
implementation com.android.support:design:28.0.0
I just made a migration to Androidx but after the migration, I'm getting the following error:
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout`
Any idea?
Stacktrace:
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:964)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ir.bijac.com.bijac.BaseActivity.onCreate(BaseActivity.java:43)
at ir.bijac.com.bijac.TestActivity.onCreate(TestActivity.java:22)
compileSdkVersion 28
minSdkVersion 18
targetSdkVersion 28
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
} ```
I had a similar experience after migrating to Androidx. I resolved the issue following these steps:
[1]
Ensure that the layout file uses this
<androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
[2]
Follow this step if Android studio did not change the support libraries imports after migration to Androidx.
Go to the class file(java or kt), DELETE all imports related to the former libraries and allow Android Studio to import the appropriate Androidx libraries. Do these for all other migration issues.
This is what your dependencies should look like:
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.drawerlayout:drawerlayout:1.0.0' //DrawerLayout
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0' //androidx AppBarLayout, CollapsingToolbarLayout etc.
implementation 'androidx.webkit:webkit:1.0.0' //androidx webview
Do you by any chance have some forgotten layout-land directory or something? Which maybe contains some XML files the migration skipped over. I just discovered that this is what happened in my project. (maybe inside a different falvor?)