Error inflating class android.support.design.widget.CoordinatorLayout and ClassNotFoundException: android.support.design.R$styleable
Solution 1:
I got this error while Migrating to AndroidX
To resolve I did:
-
as suggested by @Mikeumus - and added this to the module's build.gradle dependencies:
implementation 'androidx.coordinatorlayout:coordinatorlayout:latest.version.here'
check in the Layout XML file (the layout that you're trying to launch with setContentView
if the Layout contains:
<android.support.design.widget.CoordinatorLayout
...
replace that with : <androidx.coordinatorlayout.widget.CoordinatorLayout
- in the same layout file - replace the closing tag
</android.support.design.widget.CoordinatorLayout>
with
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Solution 2:
For me, this error was resulting from using some androidx
libraries but then still having the old coordinate layout in some layout.xml
files.
build.gradle
:
com.android.support:coordinatorlayout
-> androidx.coordinatorlayout:coordinatorlayout:1.0.0-alpha1
If you're using androidx
then maybe this is your problem too.
I had to update the other v7
libraries like Toolbar
as well.
See the androidx
migration guide here: https://developer.android.com/topic/libraries/support-library/refactor
Solution 3:
For android studio try to add these dependencies
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
Solution 4:
I found the solution for eclipse
Problem what i faced is R.Java
file is not generated under support.design in gen/ folder.
After doing the below steps R.Java
file is generated. Main issue is design library is target to 22. Changing to 23 worked.
Import support design library from
\sdk\extras\android\support\design
to eclipse workspace.Open
project.properties
of AppCompat and design Library and target it to 23Clean Appcompat, design and YourProject.
Run the app