-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App crashes on splash screen after upgrading to Cordova 11.0.0 on any API level less than 30. 31 + work. #1559
Comments
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.baniyan.travels/com.baniyan.MainActivity}: android.view.InflateException: Binary XML file line #24 in com.baniyan.layout/splash_screen_view: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f030243 a=-1} Android 13 is working fine but lower android versions like 11, 10, and 9 have this same issue occurred |
@breautek Cloud you please help me to resolve above the issue |
Personally I don't use xml/vectors, instead I used a rasterized PNG. It's not the recommended approach, but it seems to be easier to support/maintain. This has the limitation of not being animatable, but if that's not a problem then it's something you can try. When using PNGs, you'll need to render it at the highest resolution you intend to support (so for xxxhdpi, you need scale the image x4 of the recommended DP value). The smaller devices will scale down rastered images appropriately assuming the aspect ratio is correct, but if a device needs to upscale, it's not going to look right.
One reason XML vectors may not work, particularly if the XML resource is an SVG is Android doesn't support the full SVG spec. In fact, I believe you're really suppose to use the Vector Asset Studio (a tool inside Android Studio... see gif) to convert an SVG to to an Android Vector Drawable (AVD). Screencast.from.2023-03-13.07.52.08.PM.webmIf you can provide me a sample reproduction repo or provide me the assets used then I can take deeper look. |
@breautek I tried just now with this png. I took the largest version of the png I had and used the Android Vector Asset studio you mentioned. In the previous build I had taken the original png, and converted that to an svg and then used the Asset studio to convert the svg to and xml. neither of these approaches worked for me. I should mention, that in both cases, I used the Asset Studio and took the resulting '_foreground.' file and placed in the my resources folder and referenced it in the config as the value for "AndroidWindowSplashScreenAnimatedIcon". |
@Christy-Kuruvilla-PWS Thanks. Later tonight after my work day (about 8 hours from now) I'll try to experiment and see if I can reproduce any issues on my end, if I can I'll dig deeper to see if I can find a solution, or at the very least an explanation on why it doesn't work. |
Thank you so much @breautek ! Let me know. |
Alright to start off, I'm testing using the API 29 emulator. The image works with a simple cordova project (specifying just the icon and autohide false so I can screen capture easily) So I then started to add more of your custom configuration. I'm not sure which custom configuration plugin in you're using, I tried cordova-custom-config but for some reason it doesn't appear to be working and it's not overwriting the So I applied the changes manually, starting with the most interesting override: <activity ... android:theme="@style/Theme.AppCompat.NoActionBar"> This is overriding the default theme, which for splashscreen compatibility layer, it needs to be kept as If you want to change the theme for the app, you can use the So scratch out I think most people having this problem is probably related to a plugin or something overriding the default theme, which to my understanding, Must be the splashscreen theme for Google's compatibility library to work. Due to volume of people raising similar issues, it will be worth documenting the error and the solution under the Quirks section and I'll create a separate issue in our docs repo for this. |
Also, I want to add that |
@breautek So I tried both just removing the AppCompat theme from the item in the config file as well as adding it as an AndroidPostSplashScreenTheme in . In both cases I'm getting this error.
Could it be something else interfering ? Is your intent filter section different ? |
Something else could be interfering. The cordova CLI sets up the native project, and you can view the AndroidManifest at Although the error seems like it's actually passing the splashscreen stage is now trying to render the main activity. You can check It should contain:
Where the assigned theme is controlled by the If you have a plugin or something overriding the <?xml version='1.0' encoding='utf-8'?>
<resources>
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenBackground">@color/cdv_splashscreen_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_cdv_splashscreen</item>
<item name="windowSplashScreenAnimationDuration">200</item>
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
</style>
</resources> The |
So the AndroidManifest.xml file doesn't have |
Then something must be overwriting it... I'm guessing the So perhaps you still need to explicitly configure it when you use the <custom-config-file parent="/*" target="AndroidManifest.xml">
<application android:allowBackup="false" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.App.SplashScreen" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="io.fabric.ApiKey" android:value="xxxxxxx" />
</application>
</custom-config-file> If that works, you may also want to compare against the cordova default AndroidManifest.xml and to see if there is anything else that you're missing... |
@breautek This worked! The correct value for 'android:theme' in my case specifically is '@style/Theme.App.SplashScreen'. Setting Thanks again for helping out with this bug. |
This method not working. Issue happens only in the ionic cordova project |
If the issue only happens in an ionic cordova project, then the ionic framework might be overriding something in an incompatible way. |
I have barely the same issue my app crashes when launching the app on a device running on Android 11 (only for release apk, debug works fine) |
For anyone else using vanilla Cordova, the solution is to set the proper theme for AndroidManifest.xml in your config.xml as follows: <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<activity android:theme="@style/Theme.App.SplashScreen"></activity>
</edit-config> This requires the XML namespace |
Bug Report
Problem
After upgrading to Cordova 11.0.0 from 8.0.0, the app is crashing on the splash screen. Before this error I hadn't changed the config.xml to handle the new splash screen for API level 31 and up. Even without doing anything API levels 31 and up work without crashing and show the icon during the splash.
What is expected to happen?
Launch normally in api level 30 and below after splash, just like api 31 and up.
What does actually happen?
it crashes on this line for splash_screen_view
.MainActivity}: android.view.InflateException: Binary XML file line #24 layout/splash_screen_view
Information
I saw this ticket number 1534 that had a similar issue. I tried what was suggested and it didn't work for me. This ticket also mentioned 1479, I also tied what was mentioned here which didn't work either.
The following Cordova 11 Doc mentions that the old tags are to be removed from the config.xml file and replaced with 'AndroidWindowSplashScreenAnimatedIcon'. I removed all my splash tags and added the new preference. The following is a copy of my Android platform config
I crated the xml file by converting a png to an svg and then using the svg in the Android Asset studio for Images to create the xml. I used a new temp project to do this and copied just the ic_launcher_foreground.xml. Is this wrong way to go about it?
The Cordova doc suggests that this is all that is needed for backward compatibility.
Crash Report
D/PluginManager: startupPlugins: put - CoreAndroid D/PluginManager: postMessage: setupSplashScreen D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.company.app, PID: 1832 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.app/com.company.app.MainActivity}: android.view.InflateException: Binary XML file line #24 in com.company.app:layout/splash_screen_view: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f0300df a=-1} at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by: android.view.InflateException: Binary XML file line #24 in com.company.app:layout/splash_screen_view: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f0300df a=-1} Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f0300df a=-1} at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:826) at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:8231) at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:8429) at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:452) at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:380) at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:58) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082) at android.view.LayoutInflater.inflate(LayoutInflater.java:680) at android.view.LayoutInflater.inflate(LayoutInflater.java:532) at android.view.LayoutInflater.inflate(LayoutInflater.java:479) at android.view.View.inflate(View.java:26707) at androidx.core.splashscreen.SplashScreenViewProvider$ViewImpl$_splashScreenView$2.invoke(SplashScreenViewProvider.kt:94) at androidx.core.splashscreen.SplashScreenViewProvider$ViewImpl$_splashScreenView$2.invoke(SplashScreenViewProvider.kt:93) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at androidx.core.splashscreen.SplashScreenViewProvider$ViewImpl.get_splashScreenView(SplashScreenViewProvider.kt:93) at androidx.core.splashscreen.SplashScreenViewProvider$ViewImpl.createSplashScreenView(SplashScreenViewProvider.kt:103) at androidx.core.splashscreen.SplashScreenViewProvider.<init>(SplashScreenViewProvider.kt:52) at androidx.core.splashscreen.SplashScreen$Impl.setOnExitAnimationListener(SplashScreen.kt:305) at androidx.core.splashscreen.SplashScreen.setOnExitAnimationListener(SplashScreen.kt:185) at org.apache.cordova.SplashScreenPlugin.setupSplashScreen(SplashScreenPlugin.java:141) at org.apache.cordova.SplashScreenPlugin.onMessage(SplashScreenPlugin.java:113) at org.apache.cordova.PluginManager.lambda$postMessage$0(PluginManager.java:345) at org.apache.cordova.PluginManager$$ExternalSyntheticLambda0.accept(Unknown Source:8) at java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) at java.util.Collections$SynchronizedMap.forEach(Collections.java:2698) at org.apache.cordova.PluginManager.postMessage(PluginManager.java:343) at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:161) at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:234) at com.company.app.MainActivity.onCreate(MainActivity.java:40) at android.app.Activity.performCreate(Activity.java:8000) E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7984) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Command or Code
cordova prepare
grunt init
cordova build android --debug
Environment, Platform, Device
Android API level <= 30
Version information
Mac OS Bug Sur 11.7.1
Android Studio Electric Eel | 2022.1.1
Cordova Android 11.0.0
Checklist
The text was updated successfully, but these errors were encountered: