<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>parcelize Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/parcelize/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/parcelize/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Tue, 17 Jan 2023 06:48:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>How to fix android.view.InflateException: Error inflating class fragment</title>
		<link>https://creatronix.de/how-to-fix-android-view-inflateexception-error-inflating-class-fragment/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Sun, 21 Nov 2021 10:09:17 +0000</pubDate>
				<category><![CDATA[Android & iOS development]]></category>
		<category><![CDATA[Error inflating class fragment]]></category>
		<category><![CDATA[InflateException]]></category>
		<category><![CDATA[keepnames]]></category>
		<category><![CDATA[parcelize]]></category>
		<category><![CDATA[proguard]]></category>
		<category><![CDATA[r8]]></category>
		<guid isPermaLink="false">https://creatronix.de/?p=4148</guid>

					<description><![CDATA[<p>I got the error E/AndroidRuntime: FATAL EXCEPTION: main Process: de.creatronix.levelup, PID: 17026 java.lang.RuntimeException: Unable to start activity ComponentInfo{de.creatronix.levelup/de.creatronix.levelup.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment after enabling minification in my build. The issue is that with the usage of safeargs with custom objects we use the the @parcelize annotation which seems to&#8230;</p>
<p>The post <a href="https://creatronix.de/how-to-fix-android-view-inflateexception-error-inflating-class-fragment/">How to fix android.view.InflateException: Error inflating class fragment</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got the error</p>
<pre>E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.creatronix.levelup, PID: 17026
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.creatronix.levelup/de.creatronix.levelup.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment</pre>
<p>after enabling minification in my build.</p>
<p>The issue is that with the usage of <a href="https://creatronix.de/pass-custom-objects-via-safeargs/">safeargs with custom objects</a> we use the the @parcelize annotation which seems to be <a href="https://creatronix.de/how-to-enable-r8-in-your-build-process/">optimized away with R8</a><span id="more-4148"></span></p>
<h2>Fix</h2>
<p>Add</p>
<pre>-keepnames class * extends android.os.Parcelable</pre>
<p>to your <a href="https://creatronix.de/what-is-proguard/">proguard-rules.pro file</a></p>
<p>The post <a href="https://creatronix.de/how-to-fix-android-view-inflateexception-error-inflating-class-fragment/">How to fix android.view.InflateException: Error inflating class fragment</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Pass custom objects via SafeArgs</title>
		<link>https://creatronix.de/pass-custom-objects-via-safeargs/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Tue, 28 Sep 2021 14:26:07 +0000</pubDate>
				<category><![CDATA[Android & iOS development]]></category>
		<category><![CDATA[Kotlin & Java]]></category>
		<category><![CDATA[gradle]]></category>
		<category><![CDATA[kotlin]]></category>
		<category><![CDATA[parcelable]]></category>
		<category><![CDATA[parcelize]]></category>
		<category><![CDATA[safe args]]></category>
		<guid isPermaLink="false">https://creatronix.de/?p=3711</guid>

					<description><![CDATA[<p>In Passing data between fragments using SafeArgs I showed You how to pass data between -well-  fragments. This included all basic / built-in types like Strings and Integers. In this part I will show you how you can pass custom objects. Peprare your class To use a custom class for passing between fragments it has&#8230;</p>
<p>The post <a href="https://creatronix.de/pass-custom-objects-via-safeargs/">Pass custom objects via SafeArgs</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In <a href="https://creatronix.de/passing-data-between-fragments-using-safeargs/">Passing data between fragments using SafeArgs</a> I showed You how to pass data between -well-  fragments.</p>
<p>This included all basic / built-in types like Strings and Integers.</p>
<p>In this part I will show you how you can pass custom objects.<span id="more-3711"></span></p>
<h2>Peprare your class</h2>
<p>To use a custom class for passing between fragments it has to be of type Parcelable and you must use the annotation @Parcelize</p>
<pre>import android.os.Parcelable
import kotlinx.parcelize.Parcelize

<strong>@Parcelize</strong>
class VideoPlayListItem(val videoID: String, val videoTitle: String): <strong>Parcelable</strong> {

}</pre>
<h2>Gradle Plugin</h2>
<p>Add kotlin-parcelize to your module gradle.build</p>
<pre>plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'androidx.navigation.safeargs.kotlin'
    <strong>id "kotlin-parcelize"</strong></pre>
<h2>Add argument in nav_graph.xml</h2>
<pre>&lt;fragment
    android:id="@+id/VideoPlayerFragment"
    android:name="de.creatronix.levelup.fragments.VideoPlayerFragment"
    android:label="@string/video_player_fragment_label"
    tools:layout="@layout/fragment_video_player"&gt;

    &lt;argument
        android:name="video"
        app:argType="<strong>de.creatronix.levelup.VideoPlayListItem</strong>" /&gt;
&lt;/fragment&gt;</pre>
<h2>Pass data to fragment action</h2>
<pre>val action =
    VideoFragmentDirections.actionVideoFragmentToVideoPlayerFragment(
        clickedItem
    )
findNavController().navigate(action)</pre>
<p>The post <a href="https://creatronix.de/pass-custom-objects-via-safeargs/">Pass custom objects via SafeArgs</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
