Error inflating class CollapsingToolbarLayout - android

My CollapsingToolbarLayout crashes because of Error inflating class android.support.design.widget.CollapsingToolbarLayout.
I updated the android studio last weekend. Before the updated, it works fine. After I updated it, it crashed. However, I tried to downgrade it to 2.0.0 version and it's not working anymore. My coworker has no problem with the CollapsingToolbarLayout. I am not sure what happened.
The error was:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.android/com.test.android.ui.activity.RandomActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
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:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136) 
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31) 
at android.app.Activity.performCreate(Activity.java:5990) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
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:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Caused by: java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Drawable;I)V in class Landroid/support/v4/graphics/drawable/DrawableCompat; or its super classes (declaration of 'android.support.v4.graphics.drawable.DrawableCompat' appears in /data/app/com.test.android-1/base.apk)
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:197)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:132)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
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.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136) 
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31) 
at android.app.Activity.performCreate(Activity.java:5990) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372)
Here's my CollapsingToolbarLayout:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
app:contentScrim="#color/blue"
app:statusBarScrim="#color/blue_dark"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
>
<include layout="#layout/layout_page" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
layout="#layout/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
Here's my gradle file:
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:customtabs:23.4.0'
compile 'com.android.support:design:23.4.0'
Do you guys have any idea? Thanks.

I found a solution May it work try it:
add below code in gradle build file
compile ('com.android.support:support-v4:23.4.0'){
force = true;
}
Seems like it is having version conflict issue. All support library must be of same version. However, I didn't use v4 support library before and it works.
I don't know why updatimg android studio to 2.1.1 causes the issue.
I just force all v4 library to the same as other support libraries.

I know there is an accepted answer already, BUT it is not working (or no longer working).
I spent a couple of hours researching on this error, what I came up was this.
First, due to initial release of Android Nougat also known as Android 7.0 (API 24) compileSdkVersion 24 is now available. To do that, you have to update your sdk. Step 1
Second, is to update your gradle files (internet connection required). Step 2
Also Update this part of app.gradle
Third (optional) Clean Project, Build Project (Both under Build Tab)
I hope this helped someone out there and save some few hours of researching.
Cheers / Happy coding

i found two solutions,
first one is
app:statusBarScrim="#null"
second is to force app
compile ('com.android.support:support-v4:23.4.0') {
force = true;
}
Sources taken from here

I had the same issue, #Shumin's code is effective too but it is better to remove conflicts instead of bypassing them. To find the conflict -
In Android Studio, open Terminal and enter gradlew app:dependencies.
Check the dependencies tree and see which library is causing conflict
Update:-
To check for conflicts, check the dependencies of each library and see if you aren't using the same dependency in some other library but with different version. For example, in the image below, com.android.support:appcompat-v7 is dependent on com.android.support:support-vector-drawable:23.4.0. If you find some other library depending on com.android.support:support-vector-drawable but the version is different, then you have found your conflict.

My issue was that not all of the support library gradle imports we the same, eg, I had:
compile('com.android.support:recyclerview-v7:23.4.0') {
exclude module: 'support-v4'
}
compile 'com.android.support:support-annotations:24.0.0'
changing it so all imports were 24.0.0 enabled the application to run without issues.

Hello Friend i face this issue
Just Make
compileSdkVersion 25
buildToolsVersion "25.0.2"
And All support gradle change to 25.1.1 it's work for me .

please add below code in menifiest.xml.
<activity android:name=".MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and style resource file
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

I had the same issue showing the same error while inflating the CollapsingToolbar..
I had the following dependencies in my app gradle file
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
and build tool 25.0.2 with compiled with API 23 sdk.
I than checked the dependencies and found that firebase uses
android:support:support-v4:24.0.0
and the appcompat uses
android:support:support-v4-23.4.0 -> 24.0
Hence, I changed all the build library number to
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
It worked for me now. How durable ? I don't have any idea.

This worked for me. Change you your appcompact and design libray version as follows,
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

If you are working on Oreo or upper sdk and using a drawable in CollapsingToolbar, check this drawable exists in normal drawable folder and drawable-v24 folder.
If your drawable is only in drawable-v24 folder and running the app under Oreo sdk, Android Studio logcat says "crash in CollapsingToolbar" but real problem is missing some drawables in your drawable folder.

Related

Error inflating class android.webkit.WebView on android 5

I got the following error testing on Android 5.0 (API 21). Tested on other OS versions works well.
java.lang.RuntimeException: Unable to start activity
ComponentInfo{...ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity}:
android.view.InflateException: Binary XML file line #24: Error
inflating class android.webkit.WebView
Can't find nothing special about the xml layout, at line 24:
<WebView
android:id="#+id/nav_fg_legal_detail_web"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
The code:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.AppTheme_NoActionBar)
setContentView(R.layout.legal_detail_activity) // crash here. Nothing done to web view yet.
I am using library 'androidx.appcompat:appcompat:1.1.0'.
Update:
the full stack:
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.byte_artisan.mchat2, PID: 4198
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.byte_artisan.mchat2/com.byte_artisan.mchat2.ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class android.webkit.WebView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class android.webkit.WebView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.byte_artisan.mchat2.ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity.onCreate(LegalDetailActivity.kt:18)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5221) 
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:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
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 androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) 
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) 
at com.byte_artisan.mchat2.ui.activities.navigationActivity.fragments.legalFragment.LegalDetailActivity.onCreate(LegalDetailActivity.kt:18) 
at android.app.Activity.performCreate(Activity.java:5937) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5221) 
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:899) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2040002
at android.content.res.Resources.getText(Resources.java:274)
at android.content.res.Resources.getString(Resources.java:360)
at com.android.org.chromium.content.browser.ContentViewCore.setContainerView(ContentViewCore.java:702)
at com.android.org.chromium.content.browser.ContentViewCore.initialize(ContentViewCore.java:608)
at com.android.org.chromium.android_webview.AwContents.createAndInitializeContentViewCore(AwContents.java:619)
at com.android.org.chromium.android_webview.AwContents.setNewAwContents(AwContents.java:758)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:608)
at com.android.org.chromium.android_webview.AwContents.<init>(AwContents.java:546)
at com.android.webview.chromium.WebViewChromium.initForReal(WebViewChromium.java:312)
at com.android.webview.chromium.WebViewChromium.access$100(WebViewChromium.java:97)
at com.android.webview.chromium.WebViewChromium$1.run(WebViewChromium.java:264)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.drainQueue(WebViewChromium.java:124)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue$1.run(WebViewChromium.java:111)
at com.android.org.chromium.base.ThreadUtils.runOnUiThread(ThreadUtils.java:144)
at com.android.webview.chromium.WebViewChromium$WebViewChromiumRunQueue.addTask(WebViewChromium.java:108)
at com.android.webview.chro
24 April 2020, I solved it with this:
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
Previous and not working version is below:
implementation 'androidx.appcompat:appcompat:1.1.0'
Recently I faced the same, There is an issue which is mentioned over here, which is not solved yet. The crash only occurs on API 21.
There are few solutions which mention downgrading the androidx.appcompat:appcompat versions. This answer helped me. Also, there are other possible workarounds mentioned, pick the answer that applies to you.
EDIT: The crash also occurs on API 22 and 23 if the user doesn't have Google Play installed.
EDIT 2: As mentioned in the issue tracker here, and upgrading the androidx.appcompat:appcompat version to 1.2.0-alpha02 is providing the fix in some cases. Please go through a detailed discussion to find a suitable workaround.
As mentioned by #MiguelSlv adding this maven repository is a temporary fix, However, all the above workarounds have side effects. As the bug is not fixed yet, it is not a clean solution.
EDIT 3: As of May, 2020, there is a fix.
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
Previous not working version:
implementation 'androidx.appcompat:appcompat:1.1.0'
This answer I am writing in Mar, 2020, could be changed after that.
In my case , in build.gradle (app level), I changed
implementation 'androidx.appcompat:appcompat:1.0.0'
to
implementation 'androidx.appcompat:appcompat:1.2.0-alpha02'
and the Problem is solved.
Other configuration I already have, but I didn't change them:-
In Gradle project level
classpath 'com.android.tools.build:gradle:3.5.3'
And in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
And in gradle app level
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
...
}
Noting that this solution is tested on real device with android version 5
I have over ten apps, All of my apps have "Inflating problems" I was trying to solve problems... And I have tested with emulators and real device, they have no crash ... But My user thus!
Finally while testing with emulator , I catched crash.. Here is result:
This answer writing with 19 April 2020:
androidx.appcompat:appcompat:1.2.0-beta01
androidx.appcompat:appcompat:1.2.0-alpha03
androidx.appcompat:appcompat:1.2.0-alpha02
above versions have Serious problems.... Creating dialog, cause Edittext or TextView inflating problems...
below versions have been tested a little but there were no crash
androidx.appcompat:appcompat:1.2.0-alpha01
androidx.appcompat:appcompat:1.1.0
Still testing this versions , will share results

Android ProgressBar ResourceNotFound res/drawable.check_animated.xml only on device Allwinner A88S

I'm trying to display a progress bar. It works on all devices I tested (about 10 devices), but it fails on a low cost device called Allwinner A88S Android 5.1.1. The android version is not the problem as other devices in 5.1.1 works.
So, it fails to find ressource called res/drawable/check_animated.xml
My guess is that maybe it's related with a missing support library, but I can't find which library would provide check_animated.xml. Any clue or idea will be very appreciated. Maybe I could provide my own check_animated.xml, but can't find anywhere this file. Thank you.
Here is how the ProgressBar is described in the layout
<ProgressBar
android:id="#+id/jdp_waitbar"
style="#style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_centerHorizontal="true"
android:layout_width="160dp"
android:layout_height="5dp"
android:layout_alignParentTop="true"
android:layout_margin="0dip"
android:max="100"
android:visibility="invisible"
android:progressDrawable="#drawable/jdp_progress_drawable"
/>
And here is the exception :
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/check_animated.xml from drawable resource ID #0x7f0200d3
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2479)
at android.content.res.Resources.loadDrawable(Resources.java:2381)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.widget.ProgressBar.<init>(ProgressBar.java:267)
at android.widget.ProgressBar.<init>(ProgressBar.java:253)
at android.widget.ProgressBar.<init>(ProgressBar.java:249)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
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 com.furetcompany.base.components.WaitingView.createView(WaitingView.java:112) 
at com.furetcompany.base.components.WaitingView.<init>(WaitingView.java:45) 
at com.furetcompany.base.network.CircuitDownloader.showWaitingDialog(CircuitDownloader.java:86) 
at com.furetcompany.base.network.CircuitDownloader$5.run(CircuitDownloader.java:221) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
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:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Check the values of
compileSdkVersion
targetSdkVersion
in your app-level gradle build file and make sure that they are up to date. Also make sure that minSdkVersionis equal to or lower than the latest API version supported by the device in which the app is crashing. For Android 5.1.1 your minSdkVersion should be 22 or lower. Clean the project and try again.
After several tests, it seems that the problem is with the theme of the activity.
replacing
<activity android:name=".MainActivity" android:theme="#android:style/Theme.NoTitleBar">
with
<activity android:name=".MainActivity" android:theme="#android:style/Theme.AppCompat.Light.NoActionBar">
fixes the crash.

App crashes when using setErrorEnabled with floating editText

Please,I need some help,my app is crashing when I open activity in which i have declared app:errorEnabled=true in xml file for TextInputLayout i use more than tutorial but nothing work likeUser input errors
xml:
<android.support.design.widget.TextInputLayout
android:id="#+id/tilEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextLabel"
app:errorTextAppearance="#style/MyErrorText"
app:errorEnabled="true"
app:hintTextAppearance="#style/TextAppearence.TextInputLayout.Red">
<EditText
android:id="#+id/edtEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/email"
android:textSize="#dimen/text_size"
android:textColor="#color/white"
android:padding="10dp"
android:inputType="textEmailAddress"
android:singleLine="true"/>
</android.support.design.widget.TextInputLayout>
style:
<style name="MyErrorText" parent="TextAppearance.AppCompat.Small">
<item name="android:textColor">#f00</item>
</style>
Activity:
tilEmail = (TextInputLayout) findViewById(R.id.tilEmail);
tilEmail.setError(null);
if (TextUtils.isEmpty(email)) {
tilEmail.setError("Email name is required"); // show error
}
Error Stack:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.newsolution.jiibli, PID: 14042
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.newsolution.jiibli/com.newsolution.jiibli.Activity.Login}: android.view.InflateException: Binary XML file line #34: Error inflating class android.support.design.widget.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2695)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
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:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: android.view.InflateException: Binary XML file line #34: Error inflating class android.support.design.widget.TextInputLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
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 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436)
at android.app.Activity.setContentView(Activity.java:2245)
at com.newsolution.jiibli.Activity.Login.onCreate(Login.java:65)
at android.app.Activity.performCreate(Activity.java:6178)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2648)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5910) 
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:1405) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
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 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436) 
at android.app.Activity.setContentView(Activity.java:2245) 
at com.newsolution.jiibli.Activity.Login.onCreate(Login.java:65) 
at android.app.Activity.performCreate(Activity.java:6178) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2648) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5910) 
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:1405) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200) 
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 24
at android.content.res.TypedArray.getColor(TypedArray.java:402)
at android.widget.TextView.<init>(TextView.java:763)
at android.widget.TextView.<init>(TextView.java:685)
at android.widget.TextView.<init>(TextView.java:681)
at android.widget.TextView.<init>(TextView.java:677)
at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:297)
at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:119)
at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:82)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 
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 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436) 
at android.app.Activity.setContentView(Activity.java:2245) 
at com.newsolution.jiibli.Activity.Login.onCreate(Login.java:65) 
at android.app.Activity.performCreate(Activity.java:6178) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2648) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1430) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5910) 
gradle:
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.xxxx.xx"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
repositories {
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
flatDir {
dirs 'libs'
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile(name: 'osmbonuspack_v5.3', ext: 'aar')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.satsuware.lib:usefulviews:2.3.6'
compile 'com.github.ganfra:material-spinner:1.1.1'
compile 'org.osmdroid:osmdroid-android:4.3'
compile 'org.slf4j:slf4j-android:1.6.1-RC1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.github.johnpersano:supertoasts:1.3.4#aar'
}
As showing in your code you are using some custom theme for TextInputLayout i.e #style/TextLabel. Just make sure parent of TextLabel theme is Theme.Design or something like Theme.Design.Light
the problem occurs because of android:theme="#style/TextLabel"
just remove it from code and it's solved
thanks to all
As of December 2019, Google wants you to use com.google.android.material.textfield.TextInputLayout and if you want to set your own theme to a TextInputLayout, make sure you set your custom style as follows:
<style name="CustomTheme" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
<item name="...">...</item>
</style>
Note that FilledBox is the default theme of TextInputLayout. There are multiple themes possible to choose from depending on your needs, the differences are documented here: https://material.io/develop/android/components/text-input-layout/
If you are still using android.support.design.widget.TextInputLayout, this should hopefully work:
<style name="CustomTheme" parent="Widget.Design.TextInputLayout">
<item name="...">...</item>
</style>

InflateException : Error inflating class android.support.design.widget.NavigationView

I am able to test my android app on my mobile 5.0 perfectly fine, but testing it on Xiaomi, Asus phones( modified android os phones) throws an exception.
Error inflating class android.support.design.widget.NavigationView
I tried every solution given to this question on stackoverflow, but the error message still exists.
actvity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
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">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:itemTextColor="?android:textColorPrimary"
app:menu="#menu/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.image"
minSdkVersion 15
targetSdkVersion 21
versionCode 10
versionName "5.11.10"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
}
apply plugin: 'com.google.gms.google-services'
logs
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.image/com.image.MainActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5052)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.createView(LayoutInflater.java:623)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:400)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.image.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5245)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249 at android.app.ActivityThread.access$800(ActivityThread.java:141)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5052)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:597)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:400) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.image.MainActivity.onCreate(MainActivity.java:46) 
at android.app.Activity.performCreate(Activity.java:5245) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249
at android.app.ActivityThread.access$800(ActivityThread.java:141) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5052) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f020050
at android.content.res.Resources.getValue(Resources.java:1133)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:285)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:421)
at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.prepareMenuItems(NavigationMenuPresenter.java:475)
at android.support.design.internal.NavigationMenuPresenter$NavigationMenuAdapter.update(NavigationMenuPresenter.java:436)
at android.support.design.internal.NavigationMenuPresenter.updateMenuView(NavigationMenuPresenter.java:112)
at android.support.design.widget.NavigationView.inflateMenu(NavigationView.java:241)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:169)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:95)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
at android.view.LayoutInflater.createView(LayoutInflater.java:597) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:699) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:400) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
at com.image.MainActivity.onCreate(MainActivity.java:46) 
at android.app.Activity.performCreate(Activity.java:5245) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249
at android.app.ActivityThread.access$800(ActivityThread.java:141) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5052) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609) 
at dalvik.system.NativeStart.main(Native Method) 
i tried all the possible solutions, still i am facing issue only in Xiaomi, Asus phones only.
check your navigation view by removing one of these and check your code is working or not
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer"
if your logcat says cause by resourcenotfoundexception with your above error. issue may be with a icon file/resource file in drawers. if it coming from menu/drawer try changing icons and add icons to drawer folder and to drawer-v21. hope this helps
If this is due to proguard or in signed apk then you resove it by adding below line in you proguard-rule file.
-keep class org.xmlpull.v1.** { *; }

How does one inflate XWalkView in an XML layout (or programmatic)?

I'm having a serious problem with a runtime exception when inflating an XML layout that includes the XWalkView...
Stack trace :
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
at org.xwalk.core.ReflectionHelper$ConstructorHelper.loadConstructor(ReflectionHelper.java:37)
at org.xwalk.core.ReflectionHelper.createInstance(ReflectionHelper.java:246)
at org.xwalk.core.XWalkView.<init>(XWalkView.java:169)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
            at android.view.LayoutInflater.createView(LayoutInflater.java:607)
            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 com.bean.project.XWalkUIActivity.onCreate(XWalkUIActivity.java:51)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            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:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
            at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
            at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/com_bean_project_content"
android:theme="#style/com_bean_project_black" >
<!-- bottom controls -->
<RelativeLayout
android:id="#+id/com_bean_project_bottom_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<!-- some buttons, nothing to worry about -->
</RelativeLayout>
<!-- fills most of the parent view -->
<org.xwalk.core.XWalkView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/com_bean_project_webview"
android:layout_alignParentTop="true"
android:layout_above="#id/com_bean_project_bottom_layout"/>
</RelativeLayout>
Things I have done :
1) in Android Studio, I am using the armeabi-v7a folder from the library and xwalk_core_library_java_app_part.jar and xwalk_core_library_java_library_part.jar both of these are included in the dependencies. I don't know whether I should only use one of those jar's? I couldn't find anything about it in any documents.
2) the activity with XWalkView has android:hardwareAccelerated="true"
3) on the crosswalk downloads page (https://crosswalk-project.org/documentation/downloads.html) I have downloaded version 11.40.277.7 of Android webview (ARM)
4) I also merged the "res" folder from crosswalk into my project, but this makes no difference.
5) I've also tried programmatic inflation, however, it also excepts just with a new XWalkView(mParentActivity, mParentActivity); (I know, silly constructor):
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Use SharedXWalkView if you want to support shared mode
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:233)
at org.xwalk.core.ReflectionHelper.handleException(ReflectionHelper.java:237)
at org.xwalk.core.ReflectionHelper.init(ReflectionHelper.java:132)
at org.xwalk.core.ReflectionHelper.loadClass(ReflectionHelper.java:199)
at org.xwalk.core.ReflectionHelper$ConstructorHelper.loadConstructor(ReflectionHelper.java:37)
at org.xwalk.core.ReflectionHelper.createInstance(ReflectionHelper.java:246)
at org.xwalk.core.XWalkView.<init>(XWalkView.java:192)
For inspiration, I've looked at https://crosswalk-project.org/apis/embeddingapidocs/reference/org/xwalk/core/XWalkView.html however, it's no help on this issue.
Maybe this will help you:
At first i also tried to use jars in my app. That didn't work and i got the same exceptions as you.
Then i stumbled upon this sample app that shows how to use Crosswalk.
I then copied the build into my app and everything worked ok.
Here is what i added in my gradle file:
in the repositories section i added one line (below the crashlytics..)
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven'}
maven { url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'}
}
In the dependencies section i also added one line - the last one:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'org.xwalk:xwalk_core_library:10.39.235.15'
}
This is the xml for the activity:
<org.xwalk.core.XWalkView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/walk_view"
android:layout_width="fill_parent"
android:background="#000000"
android:layout_height="fill_parent"
/>
And this is how i use it in the java code:
private void setXView(){
mXview = (XWalkView)findViewById(R.id.walk_view);
mXview.load("http://www.cnn.com",null);
}
Don't forget to delete the jars in your app or you might get a compilation error if you have fileTree(dir: 'libs', include: ['*.jar']) in your dependencies.
After a day of insane experimentation, I finally gave up on trying to store a local copy of the library.
Instead, I went with Maven using these instructions: https://crosswalk-project.org/documentation/embedding_crosswalk/crosswalk_aar.html
At the bottom of that page is a link to a sample app that's set up with Maven - which is useful.
Note: to find out what versions of the library are available, go here: https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/
for example, instead of the "beta" dependency, you would have compile 'org.xwalk:xwalk_core_library:12.41.296.5'
After having it set up with maven, I then reverted to the XML inflation.
However, I was then faced with
04-02 16:38:31.036 14165-14165/com.bean.project W/System.err﹕ Caused by: java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity
04-02 16:38:31.037 14165-14165/com.bean.project W/System.err﹕ at org.xwalk.core.internal.XWalkViewInternal.<init>(XWalkViewInternal.java:197)
04-02 16:38:31.037 14165-14165/com.bean.project W/System.err﹕ at org.xwalk.core.internal.XWalkViewBridge.<init>(XWalkViewBridge.java:46)
the insanity continues...
public XWalkViewInternal(Context context, AttributeSet attrs) {
super(convertContext(context), attrs);
checkThreadSafety();
mActivity = (Activity) context;
mContext = getContext();
init(mContext, attrs);
}
how can they possibly think that's a good idea ??!! /facepalm
EDIT: to get the XWalkView added to a layout programmatically I put a placeholder (empty) RelativeLayout in the XML with ID FULLSCREEN_YOUTUBE_CONTAINER_ID and then in onCreate() of the activity I did:
mYoutubeVideoViewContainer = (RelativeLayout) mLayoutView.findViewById(FULLSCREEN_YOUTUBE_CONTAINER_ID);
mYoutubeWebView = new XWalkView(mParentActivity, mParentActivity);
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mYoutubeVideoViewContainer.addView(mYoutubeWebView, relativeParams);

Categories

Resources