I tried to add ads to my app. But it reports the error:
android.view.InflateException: Binary XML file line #9: Binary XML
file line #9: Error inflating class com.google.android.gms.ads.AdView
Here is my build.gradle (module: app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.firebasedemoapp"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout: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.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-ads:9.6.0'
}
Here is my build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my MainActivity.java
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize( this, "ca-app-pub-3940256099942544~3347511713");
AdView mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
}
I expect the ads to add to my app, but it reports the error inflating.
Edit:
Add my xml file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
tools:ignore="MissingConstraints">
</com.google.android.gms.ads.AdView>
</android.support.constraint.ConstraintLayout>
stack trace:
2019-04-23 11:20:19.790 23516-23516/com.example.firebasedemoapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.firebasedemoapp, PID: 23516
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.firebasedemoapp/com.example.firebasedemoapp.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class com.google.android.gms.ads.AdView
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 #9: Binary XML file line #9: Error inflating class com.google.android.gms.ads.AdView
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.google.android.gms.ads.AdView
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.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.firebasedemoapp.MainActivity.onCreate(MainActivity.java:24)
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: Lcom/google/android/gms/R$styleable;
at com.google.android.gms.ads.internal.client.zzk.<init>(Unknown Source)
at com.google.android.gms.ads.internal.client.zzae.<init>(Unknown Source)
at com.google.android.gms.ads.internal.client.zzae.<init>(Unknown Source)
at com.google.android.gms.ads.internal.client.zzae.<init>(Unknown Source)
at com.google.android.gms.ads.BaseAdView.<init>(Unknown Source)
at com.google.android.gms.ads.AdView.<init>(Unknown Source)
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.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
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 android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.firebasedemoapp.MainActivity.onCreate(MainActivity.java:24)
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-04-23 11:20:19.790 23516-23516/com.example.firebasedemoapp E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.R$styleable" on path: DexPathList[[zip file "/data/app/com.example.firebasedemoapp-2/base.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.firebasedemoapp-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.firebasedemoapp-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)
Remove xmlns:ads="http://schemas.android.com/apk/res-auto" from com.google.android.gms.ads.AdView. You already add it to android.support.constraint.ConstraintLayout. For example:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
tools:ignore="MissingConstraints">
</com.google.android.gms.ads.AdView>
</android.support.constraint.ConstraintLayout>
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?)
I'm having this log (of course with the crash of my activity) when trying to go Chat Activity. I am following the tutorial of smack xmpp chat application It happens only when i try to open chat activity : Any suggestion at what i can do to the line 2??? Greetings log :
Unable to start activity ComponentInfo{com.testproject.rooster/com.testproject.rooster.ChatActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class co.devcenter.androiduilibrary.ChatView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class co.devcenter.androiduilibrary.ChatView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.testproject.rooster.ChatActivity.onCreate(ChatActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.ClassNotFoundException: Didn't find class "co.devcenter.androiduilibrary.ChatView" on path: DexPathList[[zip file "/data/app/com.testproject.rooster-1/base.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.testproject.rooster-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:571)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.testproject.rooster.ChatActivity.onCreate(ChatActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Suppressed: java.lang.ClassNotFoundException: co.devcenter.androiduilibrary.ChatView
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 23 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
my layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".ChatActivity">
<co.devcenter.androiduilibrary.ChatView
android:id="#+id/rooster_chat_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</co.devcenter.androiduilibrary.ChatView>
</RelativeLayout>
gradle file that has to imported .
build.gradle
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation ('com.github.timigod:android-chat-ui:v0.1.3'){
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
}
Didn't find class "co.devcenter.androiduilibrary.ChatView"
First make sure you have added :
maven { url 'https://jitpack.io' }
In repositories of the Build.gradle file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Second, error says it couldn't find that class and in the documentation and the library, the package name looks different than what you've added in the xml codes.
So, replace the dependency with this :
implementation 'com.github.timigod:android-chat-ui:v0.1.4'
And then use this tag:
<co.intentservice.chatui.ChatView
Instead of:
<co.devcenter.androiduilibrary.ChatView
Looks like the library com.github.timigod:android-chat-ui is not included properly.
Make sure the line:
implementation 'com.github.timigod:android-chat-ui:v0.1.3'
is inside dependencies {} section.
Like in this file
https://github.com/blikoon/Rooster/blob/master/Rooster/app/build.gradle
I just made a migration to androidx through Android Studio menu option Refactor -> Refactor to AndroidX
I'm getting the following error:
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Any idea?
Stacktrace:
2018-10-19 00:25:58.128 28131-28131/com.midounoo.midounoo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.midounoo.midounoo, PID: 28131
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.midounoo.midounoo/com.midounoo.midounoo.Base.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6255)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.midounoo.midounoo-2/base.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.midounoo.midounoo-2/lib/arm64, /system/lib64, /vendor/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
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 com.midounoo.midounoo.Base.MainActivity.onCreate(MainActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6666)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6255)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
I solve my problem by changing all occurrences of
androidx.constraintlayout.ConstraintLayout
to
androidx.constraintlayout.widget.ConstraintLayout
Add androidx.constraintlayout.widget.ConstraintLayout to the dependencies:
dependencies {
// https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
It's available on mavenCentral().
I had the same problem, I resolved it as follows:
In your dependecies if you have added
implementation 'androidx.constraintlayout:constraintlayout:1.x.x' that is correct
but in your xml layout file you have to use the widget as
androidx.constraintlayout.widget.ConstraintLayout
build.gradle => check dependencies version
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
to change
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
solved the problem
I has same issue after:
migration support library to androidx;
increment targetSdkVesrsion to 29;
I also use:
implementation "uk.co.chrisjenx:calligraphy:2.3.0"
I tried all posts from this question, but none success.
I fix it by adding one string .disableCustomViewInflation() to Calligraphy init:
#Override
public void onCreate() {
super.onCreate();
// ...
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Sans-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.disableCustomViewInflation() // <----- this fix
.build());
// ...
}
I hope next release of Calligraphy (Christopher Jenkins thanks for your great job) will fix it inside too.
If after adding mavenCentral() as a repository in your Gradle file and changing androidx.constraintlayout.ConstraintLayout to androidx.constraintlayout.widget.ConstraintLayout didn't solve your problem then try doing Invalidate cache and restart from the file menu. It worked for me.
make sure your project migrate to androidx completely , In my case I found :
<android.support.constraint.ConstraintLayout
instead of
<androidx.constraintlayout.widget.ConstraintLayout
So change it and my problem fixed!
After clicking on Refactor -> Migrate to AndroidX , Make sure your all dependencies in the build.gradle(Module:app) is marked to the newest version.
If its not, dependency will appear in yellow highlighted color and you can change it by hovering the mouse over it.
Secondly,
Change the ConstraintLayout tag in all XML layout files to
androidx.constraintlayout.widget.ConstraintLayout
For more safer option, clean your project and sync it again after the above steps.
Make Sure you have added the dependency for constraint layout
dependencies {
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
and have made the changes to
<androidx.constraintlayout.widget.ConstraintLayout instead of
<android.support.constraint.ConstraintLayout
I copied and pasted an existing ConstraintLayout tag from the xml, which was causing the issue for me. Simply deleting, and re-adding the ConstraintLayout tags in AndroidStudio from scratch fixed the issue for me.
Make sure to change to
<androidx.constraintlayout.widget.ConstraintLayout
instead of
<android.support.constraint.ConstraintLayout
and
<androidx.constraintlayout.widget.Barrier
instead of
<android.support.constraint.Barrier
I had this issue with Android Studio 4.0. I used android studio 4.0 for a couple of days without problems. Seemingly out of nowhere the designer view stopped working.
I could only fix this by uninstalling android studio and installing the newest android studio version.
Since my implementation was already androidx.constraintlayout.ConstraintLayout, just using a Clean Project solved my problem.
yepp.
mavenCentral() and correct dependencies solve my same problems
I had a similar error.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2757)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
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:652)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:812)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
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 com.myapp.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6858)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2710)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/widget/R$styleable;
at androidx.constraintlayout.widget.ConstraintLayout.init(ConstraintLayout.java:590)
at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:567)
... 23 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.R$styleable" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 25
Following the recomendations:
add androidx.constraintlayout.ConstraintLayout to the dependencies:
dependencies {
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
And the repository mavenCentral().
Works for me. I could compile the APK.
I updated the dependency, yet it did not resolve the error.
Then I did a clean project and build and it is working now.
Find all default before to click Refactor -> Refactor to AndroidX
Open this https://developer.android.com/jetpack/androidx/migrate/class-mappings and find "android.support.v4.widget.DrawerLayout". In same line AndroidX class name is "androidx.drawerlayout.widget.DrawerLayout" copy it.
Replace all "android.support.v4.widget.DrawerLayout" to "androidx.drawerlayout.widget.DrawerLayout" in your project"s code, layout and menu. After all replace it will work.
I mean find mapping and use it in whole project.
change your constraint layout dependancy to implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
None of the solution worked for me, looking closely at the exception stack trace:
Caused by: android.content.res.Resources$NotFoundException: Resource "com.XXX.XXX:drawable/walpaper" (7f0800aa) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0800aa a=-1 r=0x7f0800aa}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2690)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3791)
at android.view.ViewGroup.<init>(ViewGroup.java:524)
at android.view.ViewGroup.<init>(ViewGroup.java:520)
at android.view.ViewGroup.<init>(ViewGroup.java:516)
drawable background image loading was causing some issue on my old test device (newer devices load it just fine). Just removed the following line from my layouts it is working fine now, need to figure out how to set the background now..
android:background="#drawable/walpaper"
I had the issue with ImageFilterView converting jpg images to png solved the issue for me.
I've just upgraded my Gradle this morning with the new SDK:
// https://developer.android.com/studio/build/multidex.html
implementation 'com.android.support:multidex:1.0.3'
// https://developer.android.com/topic/libraries/support-library/revisions.html
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:customtabs:27.1.0'
implementation 'com.android.support:gridlayout-v7:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:exifinterface:27.1.0'
Unfortunately now there is a crash during my first Activity starts. This Activity has not layout. It worked perfectly before this SDK upgrade...
03-06 10:20:33.117 18722-18722/com.xxx.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.azeoo.dev, PID: 18722
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xxx.dev/com.xxx.ui.intro.WelcomeActivity}: android.view.InflateException: Binary XML file line #24: Binary XML file line #24: Error inflating class LinearLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: android.view.InflateException: Binary XML file line #24: Binary XML file line #24: Error inflating class LinearLayout
Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class LinearLayout
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
at android.content.res.TypedArray.getString(TypedArray.java:202)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1006)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1776)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2613)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2686)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2049)
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
at android.support.v7.app.AppCompatDelegateImplV9.initWindowDecorActionBar(AppCompatDelegateImplV9.java:175)
at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:145)
at android.support.v7.app.AppCompatActivity.getSupportActionBar(AppCompatActivity.java:109)
at com.xxx.ui.BaseActivity.onCreate(BaseActivity.java:759)
at com.xxx.ui.intro.WelcomeActivity.onCreate(WelcomeActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Thank you very much guys for your support!
Remove your
buildToolsVersion from your app-level gradle file in case you want to upgrade to 27.1.0. So if you put
buildToolsVersion 27.0.2
or buildToolsVersion 27.0.3
there might be a conflict cause buildToolsVersion 27.1.0 is not released yet.
So, removing the buildToolsVersion x.x.x might do the trick !!
Edit 1
Even though removing buildToolsVersion might work, i would recommend to stick to 27.0.2 because 27.1.0 is causing some undesired crashes and has a few bugs.
One of which is :-
java.lang.ClassCastException: android.support.v7.widget.ActivityChooserView$InnerLayout cannot be cast to android.support.v7.widget.LinearLayoutCompat
Even google has announced it ( in GOOGLE ISSUE TRACKER ). So , guys better stick to 27.0.2 untill the fixed and stable version is released.