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

Iconics 3.2.5 crash on Android 10 #470

Closed
6 tasks done
simone-gasparini opened this issue Sep 18, 2019 · 21 comments
Closed
6 tasks done

Iconics 3.2.5 crash on Android 10 #470

simone-gasparini opened this issue Sep 18, 2019 · 21 comments
Assignees

Comments

@simone-gasparini
Copy link

simone-gasparini commented Sep 18, 2019

About this issue

Details

  • [ 3.2.5 ] Used library version
  • [ androidx.appcompat:appcompat:1.1.0 ] Used support library version
  • [ 3.5.0 ] Used gradle build tools version
  • [ 29.0.2 / 3.5] Used tooling / Android Studio version
  • [ ] Other used libraries, potential conflicting libraries

Checklist

Stacktrace

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: appnamexxx, PID: 9808
    java.lang.RuntimeException: Unable to start activity ComponentInfo{appnamexxx/appnamexxx.activity.MainActivity}: android.view.InflateException: Binary XML file line #17 in appnamexxx:layout/abc_screen_simple: Binary XML file line #17 in appnamexxx:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        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:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: android.view.InflateException: Binary XML file line #17 in appnamexxx:layout/abc_screen_simple: Binary XML file line #17 in appnamexxx:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
     Caused by: android.view.InflateException: Binary XML file line #17 in appnamexxx:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
        at com.mikepenz.iconics.context.ReflectionUtils.getValue(ReflectionUtils.java:29)
        at com.mikepenz.iconics.context.InternalLayoutInflater.createCustomViewInternal(InternalLayoutInflater.java:155)
        at com.mikepenz.iconics.context.InternalLayoutInflater.access$000(InternalLayoutInflater.java:20)
        at com.mikepenz.iconics.context.InternalLayoutInflater$PrivateWrapperFactory2.onCreateView(InternalLayoutInflater.java:246)
        at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
        at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:773)
        at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
        at appnamexxx.activity.MainActivity.onCreate(MainActivity.java:70)
        at android.app.Activity.performCreate(Activity.java:7802)
        at android.app.Activity.performCreate(Activity.java:7791)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
@mikepenz
Copy link
Owner

@simone-gasparini what is the issue you have with v4?

I guess also v4 would still face the same problem.

What you can do as a quick solution. Don't use the inflator and use the specific IconicsViews where you need them. I would assume that will definitely resolve the problem?

@simone-gasparini
Copy link
Author

@mikepenz with v4 and Java i continue to get the error:
.... Caused by: android.view.InflateException: Binary XML file line #21 in appnamexxx:layout/activity_main: Error inflating class TextView Caused by: java.lang.RuntimeException: A 'Iconics.init(context)' has to happen first. Call from your application. Usually this happens via an 'IconicsDrawable' usage. ....

With

@Override protected void onCreate(Bundle savedInstanceState) { LayoutInflaterCompat.setFactory2(getLayoutInflater(), new IconicsLayoutInflater2(getDelegate()));

and even with

@Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(IconicsContextWrapper.wrap(newBase)); }

@simone-gasparini
Copy link
Author

Investigating the issue i've found that the error is related to the attachBaseContext wrapper.
By converting to Kotlin you have even fixed this issue, but I'm unable to use v4.

At the moment I've forked and fixed v3:
https://github.com/DualBit/Android-Iconics/tree/fix/iconics_3_android_q

@mikepenz
Copy link
Owner

For the issue you face with v4.

You can either init with your context in your application or the first place before using

Iconics.init(applicationContext)

or you enable the content provider specifying this in your res:

<bool name="is_iconics_content_provider_enabled">false</bool>

@simone-gasparini
Copy link
Author

With

... Iconics.init(getApplicationContext()); setContentView(R.layout.activity_main); ...

the app now start, but the results are different from API 28 and 29

Schermata 2019-09-18 alle 12 29 18

@simone-gasparini
Copy link
Author

val constructorArgs = this.constructorArgs ?: return null

this.constructorArgs is always null in Android 10

@mikepenz
Copy link
Owner

@simone-gasparini I know it is not the optimal solution but the quickest.

Use the IconicsImageView and remove the custom inflater.

Will look into implementing the thing you posted above for caligraphy

@simone-gasparini
Copy link
Author

simone-gasparini commented Sep 18, 2019

At the moment these are already IconicsImageView

        <com.mikepenz.iconics.view.IconicsImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="25dp"
            android:layout_marginBottom="12dp"
            android:rotation="270"
            app:ico_background_color="@android:color/transparent"
            app:ico_color="@android:color/black"
            app:ico_icon="faw_reply"
            app:ico_size="30dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />

        <com.mikepenz.iconics.view.IconicsImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            app:ico_background_color="@android:color/transparent"
            app:ico_color="@android:color/darker_gray"
            app:ico_icon="faw_bluetooth"
            app:ico_size="150dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

@mikepenz
Copy link
Owner

it is strange as those problems seem to not occur in the sample. unless I totally overlooked it

@simone-gasparini
Copy link
Author

Yes, the initial problem occur even in your sample at v3.2.5 tag in the OldAutomaticActivity, but with v4 it's ok.

Better inspecting log I've noticed these lines

Without any Iconics class instantiated:


W/appnamexxx: Accessing hidden method Landroid/graphics/FontFamily;-><init>()V (greylist, reflection, allowed)
W/appnamexxx: Accessing hidden method Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->freeze()Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->abortCreation()V (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface; (greylist, reflection, allowed)

With IconicsImageView in xml

W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden method Landroid/graphics/FontFamily;-><init>()V (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->freeze()Z (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/FontFamily;->abortCreation()V (greylist, reflection, allowed)
    Accessing hidden method Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface; (greylist, reflection, allowed)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)
W/appnamexxx: Accessing hidden field Landroid/view/LayoutInflater;->mConstructorArgs:[Ljava/lang/Object; (greylist-max-p, reflection, denied)

Can this be related to the issue?

@mikepenz
Copy link
Owner

I am gonna deprecate the inflator and the context wrapper because of this.

Please use the specific views moving forward. Also I highly recommend to update to v4 :)

mikepenz added a commit that referenced this issue Oct 18, 2019
…n favor of the IconicsImageView and IconicsTextView

  * Also related to: #470
@mikepenz
Copy link
Owner

v3.x as it is an old release will not be updated anymore.

I highly recommend either to use the views directly due to the Android Q problem or to use your fixed branch :)

@simone-gasparini
Copy link
Author

mikepenz added a commit that referenced this issue Oct 21, 2019
Update README to FIX #470 (comment)
@mikepenz
Copy link
Owner

done @simone-gasparini . thanks :)

@prateekarora
Copy link

prateekarora commented Nov 6, 2019

It works like a charm!

There is only to fix the README because reference the step 3
https://github.com/mikepenz/Android-Iconics/blob/develop/README.md#as-imageview-only-available-if-you-follow-step-3-or-inject-the-context

Hi @simone-gasparini @mikepenz,

Thanks for discussing the issue but, sorry, I am still a bit unclear as to what is the exact fix. Using Kotlin is out of question for us right now due to limited resources.

Initialization of Iconics library

Have a very basic usage. Am only using
implementation 'com.mikepenz:google-material-typeface:3.0.1.3.original@aar'
in app's build.gradle. Am not explicitly implementing the core Iconics v3.2.5 library.

Below is the only code snippet in the MyFirstActivityClass (class that is crashing on Android 10) :-

@Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(IconicsContextWrapper.wrap(newBase));
    }

Error thrown is

Caused by java.lang.NullPointerException
Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference" at "com.mikepenz.iconics.context.ReflectionUtils.getValue (ReflectionUtils.java:29)

Two Usages of Iconics for inserting icons

Below is the text from strings.xml that is programmatically assigned to a text view of a dialog box that is shown by the first activity (MyFirstActivityClass that is crashing on Android 10) :-

<string name="dialog_info_str">Click on {gmd_restore_page} button to...</string>

Below is a code snippet on how iconics is used later in other classes :-

fab.setImageDrawable(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_restore_page).actionBar().color(Color.WHITE));

As you can see the usage is very basic. Would really appreciate your help or feedback on how to resolve this.

Thanks in advance.

@mikepenz
Copy link
Owner

mikepenz commented Nov 6, 2019

@prateekarora as you can see in the latest README and latest releases. We have deprecated the IconicsContextWrapper and the IconicsLayoutInflator as maintaining them across different Android versions turned out tricky (Android 10 changed things)

Also there are better alternatives available in this library. E.g. using an IconicsImageView or directly setting the IconicsDrawable programatically.

So I highly recommend you to turn away from the IconicsContextWrapper and either use the view we provide, or set the icons programatically :)

@iamareebjamal
Copy link

Using Kotlin is out of question for us right now due to limited resources

Just wanting to mention as this has already caused a lot of confusion without a warrant across many libraries, but you don't need to use Kotlin for using a Kotlin first library. Kotlin is fully compatible with Java, that is its main selling point. You can call and use any kotlin JVM library in Java without any issue. If you are worries of lack of resources in context of people not wanting to/accustomed to work with Kotlin, then you can just imagine a Kotlin library being written in Java, and call it like that, and there won't be any change in behavior. Kotlin is not a separate runtime, it is compiled to the same JVM bytecode as any Java library. If you are using libraries like OkHTTP 4, then you are already using a Kotlin library

oliverlockwood added a commit to cyclestreets/android that referenced this issue May 19, 2020
* Intermediate Iconics upgrade

* Switch to implementation, and very latest iconics

* WIP: bumping Mike Penz requires us to have switched to Android X already

* Various iconics-related upgrades

* Resolve some compile warnings

* Comment tweaks

* Move away from deprecated usage of IconicsContextWrapper

(see mikepenz/Android-Iconics#470)

* Make use of some more Material icons; simplify the IconicsHelper

* Change the signatures of IconicsHelper functions, to simplify usage

* Make use of some more Material icons - and remove some old PNGs

* Rework a couple of classes into Kotlin... allowing us to bin another old icon

* Move three more icons to being provided by the icon library

* Update to new navigation icons

* Remove some more unused icons

* Scaled copies of the compass icons

* Rename wisps icons to prefix with wp for clarity and grouping

* Rearrange unused assets for clarity

* Initialise screenlock button correctly

* Move out unused assets

* Remove unused rendertheme now provided (presumably) by MapsForge library itself

* Use Material icon intsead of blurry PNG for 'route now' button

* Update Cyclestreets logo used at the start of LiveRide, to make it less blurry

* Update What's New etc

* Make POI icons clearer

* Fix bug in initialisation of POI category ListView, so it can be reused without going mental

* Add icons to the root of the Settings page
@NatyN-teac
Copy link

hello mike, i m not experienced developer but i found error when i migrate android 28 to 29 and the error is like this, can you please help me to fix this,

/CustomActivityOnCrash: The previous app process crashed. This is the stack trace of the crash:
java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.livepic.java/ru.livepic.java.activities.SplashScreen}: android.view.InflateException: Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3555)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3707)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
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:2220)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8019)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: android.view.InflateException: Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
Caused by: android.view.InflateException: Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
at com.mikepenz.iconics.context.ReflectionUtils.getValue(ReflectionUtils.java:29)
at com.mikepenz.iconics.context.InternalLayoutInflater.createCustomViewInternal(InternalLayoutInflater.java:155)
at com.mikepenz.iconics.context.InternalLayoutInflater.access$000(InternalLayoutInflater.java:20)
at com.mikepenz.iconics.context.InternalLayoutInflater$PrivateWrapperFactory2.onCreateView(InternalLayoutInflater.java:246)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:631)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at ru.livepic.java.activities.SplashScreen.onCreate(SplashScreen.java:54)
at android.app.Activity.performCreate(Activity.java:7957)
at android.app.Activity.performCreate(Activity.java:7946)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3530)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3707)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.Act

@mikepenz
Copy link
Owner

@NatyN-teac the LayoutInflater was removed from the library due to incompatibility with newer android versions.

Please update to the latest release of the library which no longer offers that feature

@NatyN-teac
Copy link

thanks for your response, can you please check my configuration, here it is:
------------------------------------------------------------------library in gradle.build(app)---------------------------------------------
implementation 'com.mikepenz:iconics-core:3.2.5'
implementation 'com.mikepenz:iconics-views:3.2.5'
implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar'
implementation 'com.mikepenz:community-material-typeface:2.0.46.1@aar'
implementation 'com.mikepenz:fontawesome-typeface:4.7.0.2@aar'

---------------------------------------------////////////////////////-----------------------------------------------

and the error keeps coming even after i update the iconics-core to latest i m using java for Android and i have migrated to AndroidX and the error is like this:

Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Binary XML file line #17 in ru.livepic.java:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout

can you please refer my configuration and suggests solution, im stuck the whole days trying to fix this

@mikepenz
Copy link
Owner

@NatyN-teac I am sorry but this outlined issue does not look to be related to this library

this states you have some screen which uses a layout which won't exist with the androidX libraries.

ru.livepic.java:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants