Skip to content
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

cordova-android@11 layout/splash_screen_view #1497

Closed
3 tasks done
cmartinezv opened this issue Sep 21, 2022 · 8 comments
Closed
3 tasks done

cordova-android@11 layout/splash_screen_view #1497

cmartinezv opened this issue Sep 21, 2022 · 8 comments
Labels
info-needed / awaiting response Further information is requested

Comments

@cmartinezv
Copy link

cmartinezv commented Sep 21, 2022

Bug Report

Problem

After upgrading my project to cordova-android11 I'm getting a RuntimeException only with Android API S after opening the app, though is working fine with API 33 and API 29.

What is expected to happen?

Show splashscreen and run app normally.

What does actually happen?

I'm getting this error:

--------- beginning of crash
2022-09-21 10:08:38.566 6584-6584/io.cordova.hellocordova E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.cordova.hellocordova, PID: 6584
java.lang.RuntimeException: Unable to start activity ComponentInfo{io.cordova.hellocordova/io.cordova.hellocordova.MainActivity}: android.view.InflateException: Binary XML file line #24 in io.cordova.hellocordova: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:3608)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3765)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:102)
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:2193)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7796)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)
Caused by: android.view.InflateException: Binary XML file line #24 in io.cordova.hellocordova: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:827)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:8230)
at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:8428)
at android.widget.FrameLayout$LayoutParams.(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:1129)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
at android.view.View.inflate(View.java:27024)
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.(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:724)
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)
2022-09-21 10:08:38.566 6584-6584/io.cordova.hellocordova E/AndroidRuntime: at io.cordova.hellocordova.MainActivity.onCreate(MainActivity.java:40)
at android.app.Activity.performCreate(Activity.java:8036)
at android.app.Activity.performCreate(Activity.java:8016)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3581)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3765)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:102)
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:2193)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7796)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)

Information

This bug is resolved when I add a splash_screen_view.xml file myself in the layout folder, but after then API 29 doesn't work.

Command or Code

cordova create myApp2
cordova platform add android@11
cordova run android ( Android API S Simulator )

Environment, Platform, Device

cordova-android@11
Android API S Simulator

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@cellcrowd
Copy link

cellcrowd commented Sep 22, 2022

I too am seeing crashes in the Google Play console related to InflateException, SynchronizedLazyImpl.getValue. All errors are pointing to android.view.InflateException at LayoutInflater.java:539. Looking further into the stack traces they seem splashscreen related. Devices suffering from this are running Android 6.0

@breautek
Copy link
Contributor

By Android API S, I assume you mean API 31/Android 12.0 simulator.

I tried this with an empty cordova project with the default settings, as shown in the reproduction steps. and it isn't producing any RuntimeException for me.

I recommend to do the following:

  • Ensure that Build Tools 32.0.0 is in your PATH. Sometimes Cordova can intelligently find the correct build tools version, but other command line utilities will silently fail and produce bad builds by using an older build tools than what is expected for your compile target.
  • Ensure that Java 11 is being used (JAVA_HOME and PATH leads to a Java 11 environment)
  • Compile/target against API 32 (The cordova default in cordova-android@11)

If all that looks correct and you still have a reproducible error, then we may need a minimal reproduction app to move this issue along.

@breautek breautek added the info-needed / awaiting response Further information is requested label Sep 23, 2022
@cellcrowd
Copy link

On my case, I was overriding the app's theme

<edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:label='@string/activity_name']" mode="merge">
    <activity android:theme="@style/AppTheme"></activity>
</edit-config>

Obviously the initial theme now needs to be a splash theme, which was causing my issues. To solve the issue, I removed above lines and replaced it with

<preference name="AndroidPostSplashScreenTheme" value="@style/AppTheme"/>

@BenjaminPiette
Copy link

On my case, I was overriding the app's theme

<edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:label='@string/activity_name']" mode="merge">
    <activity android:theme="@style/AppTheme"></activity>
</edit-config>

Obviously the initial theme now needs to be a splash theme, which was causing my issues. To solve the issue, I removed above lines and replaced it with

<preference name="AndroidPostSplashScreenTheme" value="@style/AppTheme"/>

That was it, thanks!

@jcesarmobile
Copy link
Member

closing since the reporter never answered and some other users found out their problem

@nicolastinkl
Copy link

Solve it : #1559 (comment)

@andreszs
Copy link

For anyone else using vanilla Cordova, the solution is to se 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 xmlns:android="http://schemas.android.com/apk/res/android" in your element in config.xml.

@dpogue
Copy link
Member

dpogue commented Aug 29, 2023

For anyone else using vanilla Cordova [...]

You shouldn't need to change this for vanilla Cordova Android 12.x, because Theme.App.SplashScreen is the default value:

android:theme="@style/Theme.App.SplashScreen"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed / awaiting response Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants