<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aparna Tati on Medium]]></title>
        <description><![CDATA[Stories by Aparna Tati on Medium]]></description>
        <link>https://medium.com/@aparnatati47?source=rss-9d33a4281005------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*4CfKWp0EG0eDnjsE</url>
            <title>Stories by Aparna Tati on Medium</title>
            <link>https://medium.com/@aparnatati47?source=rss-9d33a4281005------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:09:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aparnatati47/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Customisation of Shared Element Transition of Jetpack Compose]]></title>
            <link>https://medium.com/simform-engineering/customisation-of-shared-element-transition-of-jetpack-compose-49eb0cba6f48?source=rss-9d33a4281005------2</link>
            <guid isPermaLink="false">https://medium.com/p/49eb0cba6f48</guid>
            <category><![CDATA[shared-element-transition]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[google-io-2024]]></category>
            <category><![CDATA[customisation]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Aparna Tati]]></dc:creator>
            <pubDate>Fri, 06 Dec 2024 12:12:50 GMT</pubDate>
            <atom:updated>2024-12-06T12:34:28.299Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Seamless smooth transition between composables</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kCI-nTp7Ap0uRvAO1Nc8hg.gif" /></figure><p>In <a href="https://medium.com/p/ad77ba202e49/edit"><strong>Part 1</strong></a>, we explored the shared element transition API and used it to create a functional demo showing an album list transitioning into a detailed album view.</p><p>In this article, we will understand how we can customise the shared element transition API and provide a more interactive and impressive user experience.</p><p>A few parameters can be used to customise the shared element transition API:</p><ol><li>Animation Spec</li><li>Animated Visibility</li></ol><h3><strong>1. Animation Spec</strong></h3><p>To create a more dynamic and visual transition, we can customise the animation behaviour for size and position changes.</p><p>By specifying a different boundsTransform parameter on Modifier.sharedElement() where we can control the initial and target Rect positions.</p><p>For example, to make the text move with an arc motion, simply set the boundsTransform parameter to use a keyframe spec, adding a touch of elegance to your transition animation.</p><h4>Creating a Text Transform Animation with Shared Element Transition API</h4><p>Let’s begin implementing text transform animation with animation spec customisation.</p><blockquote><strong>Setting up AnimationSpec</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fd429394566da1b3426284a31a1da59/href">https://medium.com/media/8fd429394566da1b3426284a31a1da59/href</a></iframe><ul><li><strong>textBoundsTransform</strong></li></ul><p>The BoundsTransform is used in shared element transitions to smoothly animate between the starting and ending positions of an element.</p><p>It uses a tween animation, which you can control with durationMillis to set how long the animation lasts.</p><p>The FastOutSlowInEasing adds a natural, smooth motion, making the transition between UI components look seamless.</p><ul><li><strong>animatedTextBoundsTransform</strong></li></ul><p>The animatedTextBoundsTransform uses a keyframes-based animation to smoothly move text elements from their starting position to their final position.</p><p>It defines how the text moves over time, beginning with the initialBounds and ending with the targetBounds.</p><p>By using ArcMode.ArcBelow and FastOutSlowInEasing, the movement follows a curved path with a smooth, visually pleasing effect. This creates a dynamic transition specifically designed for text elements.</p><ul><li><strong>textEnterAnimation</strong></li></ul><p>The textEnterAnimation creates a fade-in effect for a Text component as it enters the screen.</p><p>The animation lasts for a specified duration, using the FastOutSlowInEasing function to start quickly and gradually slow down, resulting in a smooth and visually appealing transition.</p><ul><li><strong>textExitAnimation</strong></li></ul><p>The textExitAnimation applies a fade-out effect to a Text component as it exits the screen.</p><p>It matches the fade-in animation in duration and uses the same FastOutSlowInEasing function, ensuring a consistent and smooth animation style for both entering and exiting transitions.</p><blockquote><strong>Setting up MainContent</strong></blockquote><p>The outermost layer of your composables must be SharedTransitionLayout.</p><p>It mainly involves opening and closing the details screen using the showDetails state variable, which changes based on two lambda functions: showDetails() and onBack().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/219e4f0b4904c9daa4d27be8600392dc/href">https://medium.com/media/219e4f0b4904c9daa4d27be8600392dc/href</a></iframe><p>The sharedBoundsModifier in the MainContent composable is used to manage the shared element transition between different content states. Here’s a breakdown of its components:</p><ul><li><strong>sharedBounds</strong>: This is a modifier function that integrates shared element transitions. It helps animate the bounds of a UI element between different states.</li><li><strong>sharedContentState</strong>: rememberSharedContentState(key = &quot;bounds&quot;) creates and remembers the state of the shared content bounds using a unique key. This state is used to track the position and size of the shared element.</li><li><strong>animatedVisibilityScope</strong>: This is the scope provided by AnimatedContent, which allows the sharedBoundsModifier to apply animations to the shared element within this scope.</li><li><strong>enter and </strong><strong>exit animations</strong>: textEnterAnimation and textExitAnimation define how the shared element should animate when it enters or exits the screen.</li><li><strong>boundsTransform</strong>: textBoundsTransform specifies how the bounds of the shared element should transition between the initial and target states, using tween animation for smooth changes.</li></ul><p>In summary, sharedBoundsModifier ensures that the element’s position and size are animated smoothly when transitioning between different content states, maintaining visual continuity during the transition.</p><blockquote><strong>Implementing CarScreen</strong></blockquote><p>Here, we will see the implementation of <strong>Car</strong> composable, which contains an image and the car&#39;s name. We have applied the sharedElement modifier on both components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d1155ef7bb86c90633095c8cf022113/href">https://medium.com/media/5d1155ef7bb86c90633095c8cf022113/href</a></iframe><blockquote><strong>Implementing CarDetailsScreen</strong></blockquote><p>Here, we will see the implementation of <strong>CarDetails </strong>composable, which contains an image, name, and description of the car.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dd47ac96c12228d261b703f259548ab/href">https://medium.com/media/3dd47ac96c12228d261b703f259548ab/href</a></iframe><p>In the above code, we have used sharedBounds() modifier on text because we need to change the position of the text during transition animation.</p><p>That’s all we need to do for text transform animation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*SDic-GLCYVyz5ZWNlx4Nfw.gif" /></figure><p>You can find the complete code of the above sample demo on <a href="https://github.com/SimformSolutionsPvtLtd/SSCompose-SharedElement/tree/master/app/src/main/java/com/jetpack/sharedelement/ui/transition/text/transform"><strong>GitHub</strong></a><strong>.</strong></p><h3>2. Animated Visibility</h3><p>Shared Element Transition also works with animated visibility, both shared element and bounds modifier.</p><p>For example, whenever the item in a list is clicked on, the content has the visual effect of being pulled out of the UI into a dialog-like component. We can achieve this kind of animation using this API.</p><h4>Creating a Shared Element Transition Animation with Animated Visibility</h4><p>Let’s begin the implementation of shared element transition animation with Animated Visibility customisation.</p><blockquote><strong>Setting up AnimationSpec</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76fc8e473217119037351ccac7f66ebf/href">https://medium.com/media/76fc8e473217119037351ccac7f66ebf/href</a></iframe><p>It defines a constant ANIMATION_DURATION_IN_MILLIS set to 200 milliseconds and a dessertBoundsTransition using a BoundsTransform.</p><p>The sharedElementTransitionSpec function provides a tween animation specification, which can be used for shared element transitions, with a duration of 200 milliseconds.</p><blockquote><strong>Defining Dessert Model</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf26dc494b705601990e24cb093a1af7/href">https://medium.com/media/bf26dc494b705601990e24cb093a1af7/href</a></iframe><p>It defines a data class named Dessert, which represents a dessert item with three properties: an id (as an Int), a name (as a string) and an image (as a drawable resource ID annotated with @DrawableRes).</p><blockquote><strong>Defining Screens</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81df1c8a0b54cb353e03f589a5acaebf/href">https://medium.com/media/81df1c8a0b54cb353e03f589a5acaebf/href</a></iframe><p>This code defines a sealed class named Screen to manage navigation. It includes two screens: DessertsScreen, with a static route &quot;list&quot;, and DessertDetailsScreen, with a dynamic route &quot;details/{dessertId}&quot;. The createRoute function in DessertDetailsScreen generates a specific route based on the dessert ID.</p><blockquote><strong>Setting Up TransitionAnimatedVisibilityScreen Composable</strong></blockquote><p>Here, we are going to see the implementation <strong>TransitionAnimated VisibilityScreen </strong>composable, which contains Scaffold implementation and a list of desserts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99938a8f9d9cb0e26cf9e660cc02f45e/href">https://medium.com/media/99938a8f9d9cb0e26cf9e660cc02f45e/href</a></iframe><blockquote><strong>Setting Up MainContent</strong></blockquote><p>The outermost layer of your composables must be SharedTransitionLayout. This layout is used to connect the two screens, DessertsScreen and DessertDetailScreen, using the Jetpack Compose navigation framework.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41f4fc0fc9199392bf28f05895812c92/href">https://medium.com/media/41f4fc0fc9199392bf28f05895812c92/href</a></iframe><blockquote><strong>Implementing DessertsScreen</strong></blockquote><p>Here, we are going to see the implementation of the <strong>DessertsScreen</strong> composable, which contains a list of desserts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af197683322b3e253d286219875efb66/href">https://medium.com/media/af197683322b3e253d286219875efb66/href</a></iframe><p>The above code defines a dessert item with a custom transition effect, making it appear and disappear smoothly using shared element transitions. The transition includes animations for both the bounds (size and position) and the individual elements (e.g., name and image) within the dessert item.</p><blockquote><strong>Implementing DessertContents</strong></blockquote><p>Here, we are going to see the implementation of <strong>DessertContents</strong> composable, which contains an image and a text of dessert.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc4af031713b3b1d4c669c1baa2b9563/href">https://medium.com/media/fc4af031713b3b1d4c669c1baa2b9563/href</a></iframe><blockquote><strong>Implementing DessertDetailScreen</strong></blockquote><p>Here, we are going to see the implementation of <strong>DessertDetailScreen</strong> composable, which contains an image and the name of the dessert. The save button closes the <strong>DessertDetailScreen</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/243e93e7c93b8d25d0d6dfce29f8707a/href">https://medium.com/media/243e93e7c93b8d25d0d6dfce29f8707a/href</a></iframe><p>That’s all we need to do for shared element transition with Animated Visibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*kmMyPvArEpfoqnXrVHbHzA.gif" /></figure><p>You can find the complete code of the above sample demo on <a href="https://github.com/SimformSolutionsPvtLtd/SSCompose-SharedElement/tree/master/app/src/main/java/com/jetpack/sharedelement/ui/transition/animated/visibility"><strong>GitHub</strong></a><strong>.</strong></p><h3>Conclusion</h3><p><strong>Customising the Shared Element Transition </strong>in Jetpack Compose enhances screen transitions, making them smoother and more visually appealing. With AnimationSpec, you can control movement, like curving text paths, while Animated Visibility enables smooth appearance and disappearance of elements. These APIs allow for seamless transitions of text, images, and other UI elements, improving the user experience.</p><p>For more information, you can visit the <a href="https://developer.android.com/develop/ui/compose/animation/shared-elements"><strong>official document</strong></a> for the<strong> </strong>Shared Element Transition API.</p><blockquote><strong>For more updates on the latest tools and technologies, follow the </strong><a href="https://medium.com/simform-engineering"><strong>Simform Engineering</strong></a><strong> blog.</strong></blockquote><blockquote><strong>Follow Us: </strong><a href="https://twitter.com/simform"><strong>Twitter</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/simform/"><strong>LinkedIn</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49eb0cba6f48" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/customisation-of-shared-element-transition-of-jetpack-compose-49eb0cba6f48">Customisation of Shared Element Transition of Jetpack Compose</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shared Element Transition in Jetpack Compose]]></title>
            <link>https://medium.com/simform-engineering/shared-element-transition-in-jetpack-compose-ad77ba202e49?source=rss-9d33a4281005------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad77ba202e49</guid>
            <category><![CDATA[google-io-2024]]></category>
            <category><![CDATA[shared-element-transition]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Aparna Tati]]></dc:creator>
            <pubDate>Fri, 06 Dec 2024 12:03:54 GMT</pubDate>
            <atom:updated>2024-12-06T12:03:54.180Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Seamless smooth transition between composables</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NJTgYh5LwLrbjVbS3TmrgA.gif" /></figure><p>Google introduced Shared Element Transitions for Jetpack Compose at their <a href="https://android-developers.googleblog.com/2024/05/whats-new-in-jetpack-compose-at-io-24.html"><strong>2024 I/O event!</strong></a></p><p>The <strong>Shared Element Transition API</strong> provides a way to create smooth and visually appealing transitions between composables that share the same UI element. This helps maintain visual continuity and improves the user experience, especially when navigating different screens.</p><p>For example, imagine a user taps on a photo in a list, and instead of jumping to a new screen, the photo smoothly expands to fill the screen which creates a great user experience. Previously, creating such effects in Jetpack Compose required complex code. Now, Google has streamlined this process, making it much simpler to achieve.</p><p>In this article, we’ll explore Shared Element Transitions and its key elements and show you how to set them up with clear examples. In <a href="https://medium.com/@aparnatati47/customisation-of-shared-element-transition-of-jetpack-compose-49eb0cba6f48"><strong>Part 2</strong></a>, we’ll cover how to customise them for your app to create interactive user experiences.</p><blockquote><strong><em>Experimental: </em></strong><em>Shared element support is available from Compose 1.7.0-beta01 and is experimental, the APIs may change in future.</em></blockquote><h4>Key Elements</h4><p>In Jetpack Compose, there are a few high-level APIs that facilitate the creation of shared element transitions:</p><ol><li><strong>SharedTransitionLayout</strong></li></ol><ul><li>It is a special layout required when creating shared element transitions in Jetpack Compose.</li><li>It provides a SharedTransitionScope, which is essential for the elements that participate in the transition.</li></ul><p><strong>2. Modifier.sharedElement()</strong></p><ul><li>It marks a composable (UI element) as one that should be linked with another composable for a transition.</li><li>It instructs the SharedTransitionScope to match this element with its corresponding element in the transition.</li></ul><p><strong>3. Modifier.sharedBounds()</strong></p><ul><li>It is used when you want a composable’s boundaries (size and position) to define the area for the transition.</li><li>Unlike sharedElement(), this modifier is for cases where the content inside the transitioning elements might differ, but they still need to transition together.</li></ul><h4>SharedBounds Vs SharedElement</h4><p>Modifier.sharedBounds() is similar to Modifier.sharedElement(). However, the modifiers are different in the following ways:</p><ul><li>sharedBounds() is for content that is visually different but should share the same area between states, whereas sharedElement() expects the content to be the same.</li><li>With sharedBounds(), the content entering and exiting the screen is visible during the transition between the two states, whereas with sharedElement() , only the target content is rendered in the transforming bounds.</li></ul><h4>Required Dependencies</h4><p>To use the new Shared Element Transition APIs, ensure you are using the latest version of Jetpack Compose UI and animation libraries. Below is an example of adding the required dependencies:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16a7141c5809d63a473ed57971e8ed52/href">https://medium.com/media/16a7141c5809d63a473ed57971e8ed52/href</a></iframe><p>Always refer to the <a href="https://developer.android.com/jetpack/androidx/releases/compose#versions">official documentation</a> to verify and use the latest versions.</p><h4>Creating a Sample Implementation with Shared Element Transitions</h4><p>Let’s begin our sample implementation with the navigation setup.</p><blockquote><strong>Defining Screens</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e53a687565df2fad34229864a5e3008/href">https://medium.com/media/3e53a687565df2fad34229864a5e3008/href</a></iframe><p>This code defines a sealed class named Screen to manage navigation. It includes two screens: AlbumsScreen, with a static route &quot;list&quot;, and AlbumDetailsScreen, with a dynamic route &quot;details/{albumId}&quot;. The createRoute function in AlbumDetailsScreen generates a specific route based on the album ID.</p><blockquote><strong>Defining Album Model</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/748a5872c64a0454331d65ac1fb5fc18/href">https://medium.com/media/748a5872c64a0454331d65ac1fb5fc18/href</a></iframe><p>It defines a data class named Album, which models an album with properties such as ID, title, author, release year, and a drawable resource ID for the album cover.</p><blockquote><strong>Setting Up AnimationSpec</strong></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8019774d5181a9e1916c31f77a9a0e7/href">https://medium.com/media/e8019774d5181a9e1916c31f77a9a0e7/href</a></iframe><p>This code makes an animation last 500 milliseconds (or half a second). The albumBoundsTransform function describes how to smoothly move a shared element from its starting position to its ending position during this time.</p><blockquote><strong>Setting Up MainContent</strong></blockquote><p>The outermost layer of your composables must be SharedTransitionLayout. This layout is used to connect the two screens, AlbumsScreen and AlbumDetailScreen, using the Jetpack Compose navigation framework.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b8c20b7d0051b71f54be117cb5144cb/href">https://medium.com/media/2b8c20b7d0051b71f54be117cb5144cb/href</a></iframe><p>With this setup, our navigation is ready to handle transitions between the two screens. The SharedTransitionScope is available within these screens, enabling shared element transitions.</p><p>Note at this point that the sharedElement modifier is only available within the SharedTransitionScope scope provided by SharedTransitionLayout so we need to ensure the scope is available to the AlbumsScreen composable; we could either pass the scope as an argument and then wrap the composable with a with(scope) or, alternatively, we can make the AlbumsScreen composable an extension function on SharedTransitionScope.</p><blockquote><strong>Implementing AlbumsScreen</strong></blockquote><p>Here, we are going to see the implementation for <strong>AlbumsScreen</strong> and shared element transition, for detailed UI implementation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63e9fd337abf960e0e3347323da77564/href">https://medium.com/media/63e9fd337abf960e0e3347323da77564/href</a></iframe><p>In the above code, we have taken LazyVerticalGrid with two columns, where all the albums are aligned in the Grid. We have applied the sharedElement modifier on each AlbumItem click.</p><p>To enable shared element transition, we used <strong>Modifier.sharedElement()</strong> API that takes three parameters an <strong>AnimatedVisibilityScope, rememberSharedContentState() </strong>and <strong>boundsTransform.</strong></p><p>The <strong>AnimatedVisibilityScope</strong> is the scope for the content of <strong>AnimatedVisibility</strong>. In this scope, direct and indirect children of AnimatedVisibility will be able to define their own enter/ exit transitions using the built-in options via a custom function <strong>Modifier. animateEnterExit. </strong>You can go through more about <strong>AnimatedVisibility</strong> from its <a href="https://developer.android.com/develop/ui/compose/animation/composables-modifiers">official documentation</a>.</p><p>The <strong>rememberSharedContentState(), </strong>is the important parameter that helps in shared element transition, ensuring that the transition is applied consistently across screens. This function remembers a <strong>SharedContentState</strong> object, which stores a unique key that determines which elements are shared.</p><p>The <strong>boundsTransformation</strong> defines the animation spec used to animate from initial bounds to the target bounds.</p><blockquote><strong>Implementing AlbumItem</strong></blockquote><p>Here, we are going to see the implementation of <strong>AlbumItem</strong> composable which contains the Image of the album and adds a shared element transition effect.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ede493a432674e09046269e0c0f898a4/href">https://medium.com/media/ede493a432674e09046269e0c0f898a4/href</a></iframe><p>That’s all we need to do for the AlbumsScreen to achieve the shared element transition. Next, we will see the implementation of AlbumDetailScreen.</p><blockquote><strong>Implementing AlbumDetailScreen</strong></blockquote><p>In this screen, we will be applying the same <strong>keyed</strong> sharedElement() in our composable so that transition is applied for that particular item.</p><p>The AlbumDetailScreen is mainly divided into three composables: <strong>AlbumDetailHeader</strong>, <strong>AlbumDetailInfo</strong> and <strong>AlbumDetailDescription</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1574a22b794a9afa3e336909230828dc/href">https://medium.com/media/1574a22b794a9afa3e336909230828dc/href</a></iframe><ol><li><strong>AlbumDetailHeader</strong></li></ol><p>Here, the <strong>AlbumDetailHeader</strong> composable contains a cover image of the album with the back button.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/036dfa35b64123c6eb7c7ec460230057/href">https://medium.com/media/036dfa35b64123c6eb7c7ec460230057/href</a></iframe><p><strong>2. AlbumDetailInfo</strong></p><p>Here, the <strong>AlbumDetailInfo</strong> composable contains album details like title, author, year &amp; play button, etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9352af6b3af558c9dec40c95817714fd/href">https://medium.com/media/9352af6b3af558c9dec40c95817714fd/href</a></iframe><p><strong>3. AlbumDetailDescription</strong></p><p>Here, the <strong>AlbumDetailDescription</strong> composable contains a detailed description of the album.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10bc323f411f38d0fff2a9a9a47cc6ef/href">https://medium.com/media/10bc323f411f38d0fff2a9a9a47cc6ef/href</a></iframe><p><strong>4. InformationPanel</strong></p><p>Here, the <strong>InformationPanel</strong> composable contains an album description.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b65463e0b723522096209b0eb7f427d/href">https://medium.com/media/9b65463e0b723522096209b0eb7f427d/href</a></iframe><p>We used the <strong>skipToLookaheadSize()</strong> function of the shared element transition for the text. By default, when transitioning between two layouts, the layout size animates between its start and final state. This may be undesirable behaviour when animating content such as text.</p><p>So basically, <strong>skipToLookaheadSize()</strong> prevents the reflowing of the text and keeps its final state at the start of the animation.</p><p>With this setup, we are finally done with the implementation of shared element transition in compose with navigation!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*Jx1AhX6Z_fs47kGJuNMqxw.gif" /></figure><p>You can find the complete code of the above sample demo on <a href="https://github.com/SimformSolutionsPvtLtd/SSCompose-SharedElement/tree/master/app/src/main/java/com/jetpack/sharedelement/ui/transition/with/navigation"><strong>GitHub</strong></a><strong>.</strong></p><h3><strong>Conclusion</strong></h3><p><strong>Shared Element Transitions</strong> in Jetpack Compose streamline creating smooth, visually connected animations between screens. With straightforward setup and customisation, these transitions help create a polished and engaging app design, making navigation feel smooth and natural.</p><p>In <a href="https://medium.com/p/49eb0cba6f48/edit"><strong>Part 2,</strong></a> we will explore and implement the customisation part of the Shared Element Transition API.</p><p>For more information, you can visit the <a href="https://developer.android.com/develop/ui/compose/animation/shared-elements"><strong>official document</strong></a> for the<strong> </strong>Shared Element Transition API.</p><blockquote><strong>For more updates on the latest tools and technologies, follow the </strong><a href="https://medium.com/simform-engineering"><strong>Simform Engineering</strong></a><strong> blog.</strong></blockquote><blockquote><strong>Follow Us: </strong><a href="https://twitter.com/simform"><strong>Twitter</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/simform/"><strong>LinkedIn</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad77ba202e49" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/shared-element-transition-in-jetpack-compose-ad77ba202e49">Shared Element Transition in Jetpack Compose</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publishing Library in Maven Central [Part 2]]]></title>
            <link>https://medium.com/simform-engineering/publishing-library-in-maven-central-part-2-515c5d54f566?source=rss-9d33a4281005------2</link>
            <guid isPermaLink="false">https://medium.com/p/515c5d54f566</guid>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[maven-central]]></category>
            <category><![CDATA[gpg]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Aparna Tati]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 06:40:44 GMT</pubDate>
            <atom:updated>2024-04-08T06:40:44.205Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A step-by-step approach to streamline your deployments</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QiUz325FSr-IphfOhPg8og.png" /></figure><p>In our <a href="https://medium.com/simform-engineering/publishing-library-in-maven-central-part-1-994c5fe0c004">previous blog</a> post, we discussed where to publish the library, set up a Maven Central account, and walked you through adding and verifying the namespace and configuring the Gradle files using the Maven Publish plugin.</p><p>In this continuation, we will cover the remaining steps for publishing the library on Maven Central, which includes how to:</p><h4>Table of Contents</h4><p>6. <a href="#c1f4">Install and configure GPG</a></p><p>7. <a href="#97c5">Sign the artifacts</a></p><p>8. <a href="#a06a">Generate MD5 and SHA1 checksums</a></p><p>9. <a href="#ad49">Upload a bundle</a></p><blockquote>Maven Central requires that the artifacts be signed with GPG.</blockquote><h3><strong>Step 6: Install and configure GPG</strong></h3><p>GPG provides the capability to generate a signature, manage keys, and verify signatures.</p><p>To install GPG, follow these steps:</p><p><strong>1. Install GPG on your computer by running the command:</strong></p><blockquote><em>brew install gnupg</em></blockquote><p><strong>2. Verify the installed version of GPG:</strong></p><blockquote><em>gpg — version</em></blockquote><p><strong>3. Generate a key pair for signing artifacts:</strong></p><p>A key pair allows you to sign artifacts with GPG, and users can subsequently validate that you have signed them. Generate a key pair with the following command.</p><blockquote><em>gpg — gen-key</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lwVEFPOuzi-P0I_r.png" /></figure><p><strong>4. List the generated keys:</strong></p><p>Once a key pair is generated, list them and any other keys installed.</p><blockquote><em>gpg — list-keys</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y22IEpJyC1OOOLC4.png" /></figure><p><strong>5. Generate a secring.gpg file:</strong></p><p>Due to the latest changes in gpg<strong>, </strong>it no longer generates <strong>a secring.gpg file. </strong>However, the command below helps to generate the file:</p><blockquote><em>gpg — keyring secring.gpg — export-secret-keys &gt; ~/.gnupg/secring.gpg</em></blockquote><p><strong>6. Distribute your public key:</strong></p><p>Since other people need your public key to verify your files, you have to distribute your public key to a key server.</p><p><strong>Important: </strong>As the SKS Key server Network is being deprecated, Maven recommends using a specific GPG key server. Current GPG Key servers supported by Central Servers are:</p><ul><li>keyserver.ubuntu.com</li><li>keys.openpgp.org</li><li>pgp.mit.edu</li></ul><blockquote><em>gpg — keyserver keyserver.ubuntu.com — send-keys KeyId</em></blockquote><ul><li>--keyserver: Identifies the target key server address.</li><li>--send-keys: Sends your public key to the specified server.</li><li>KeyId: This is the unique identifier (also known as the key ID) of the GPG key you want to send. Every GPG key has a unique identifier associated with it, which helps identify it in the keyring</li></ul><p>Now you can import your public key from the key server to the local machine.</p><blockquote><em>gpg — keyserver keyserver.ubuntu.com — recv-keys keyId</em></blockquote><h3><strong>Step 7: Sign the artifacts</strong></h3><p>Maven Central has the following requirements for the artifacts:</p><ol><li>ASCII Signature files</li><li>MD5 Checksum files</li><li>SHA1 Checksum files</li></ol><p>After installing and configuring GPG successfully, you need to sign the artifacts using GPG.</p><p>There are a total of four files generated when you click the ‘<strong>PublishToMavenLocal’</strong> task in the Publishing section of the Gradle window.</p><blockquote><em>example-application-1.4.7.pom</em></blockquote><blockquote><em>example-application-1.4.7.jar</em></blockquote><blockquote><em>example-application-1.4.7-sources.jar</em></blockquote><blockquote><em>example-application-1.4.7-javadoc.jar</em></blockquote><ol><li>Create an ASCII-formatted signature file for each file using the run the following gpg command:</li></ol><blockquote><em>gpg -ab example-application-1.4.7.pom</em></blockquote><p>The -a option tells gpg to create ASCII output, the -b option tells gpg to make a detached signature.</p><p>GPG will create a signature file <strong>example-application-1.4.7.pom.asc</strong> for <strong>example-application-1.4.7.pom</strong>.</p><p>2. Repeat the command for each artifact file.</p><ul><li><em>example-application-1.4.7.pom</em></li><li><em>example-application-1.4.7.pom.asc</em></li><li><em>example-application-1.4.7.jar</em></li><li><em>example-application-1.4.7.jar.asc</em></li><li><em>example-application-1.4.7-sources.jar</em></li><li><em>example-application-1.4.7-sources.jar.asc</em></li><li><em>example-application-1.4.7-javadoc.jar</em></li><li><em>example-application-1.4.7-javadoc.jar.asc</em></li></ul><p>We have created all the signature files for the artifacts of mylibrary in the command terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZrK1slM5kkAEVE3t.png" /></figure><p>Now, we have the signature files of each artifact in the specified location: ‘<strong>/Users/home’ </strong>directory of current user<strong> ‘/.m2/repository/io/github/aparnatati471/mylibrary/1.0.0’.</strong></p><blockquote><strong>Note:-</strong> .m2 is a hidden folder. Press Command + Shift + .(dot) to view and open it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LH8HkaCHewu4czSa.png" /></figure><h3><strong>Step 8: Generate MD5 and SHA1 checksums</strong></h3><p>Maven also requires valid checksum files for each artifact. A valid checksum file contains a hex-encoded checksum value.</p><ul><li>.md5 and .sha1 are required,</li><li>.sha256 and .sha512 are supported but not mandatory.</li></ul><p>For example, if you deploy the files:</p><ul><li><em>example-application-1.4.7.pom</em></li><li><em>example-application-1.4.7.jar</em></li><li><em>example-application-1.4.7-sources.jar</em></li><li><em>example-application-1.4.7-javadoc.jar</em></li></ul><p>you need to include the md5 and sha1 files, such as:</p><ul><li><em>example-application-1.4.7.pom</em></li><li><em>example-application-1.4.7.pom.md5</em></li><li><em>example-application-1.4.7.pom.sha1</em></li><li><em>example-application-1.4.7.jar</em></li><li><em>example-application-1.4.7.jar.md5</em></li><li><em>example-application-1.4.7.jar.sha1</em></li><li><em>example-application-1.4.7-sources.jar</em></li><li><em>example-application-1.4.7-sources.jar.md5</em></li><li><em>example-application-1.4.7-sources.jar.sha1</em></li><li><em>example-application-1.4.7-javadoc.jar</em></li><li><em>example-application-1.4.7-javadoc.jar.md5</em></li><li><em>example-application-1.4.7-javadoc.jar.sha1</em></li></ul><p><strong>Here’s how to generate MD5 and SHA1:</strong></p><h4><strong>1. Generate an MD5 file:</strong></h4><p>The MD5 file contains a 128-bit checksum value. To generate an MD5 file, run the following command in the terminal.</p><p><strong>Steps:</strong></p><ol><li>Open a command terminal</li><li>Navigate to the directory containing the files you want to create MD5 files.</li><li>Use the following command to generate an MD5 file for a specific file.</li></ol><blockquote><em>md5sum filename | cut -d ‘ ‘ -f 1 &gt; filename.md5</em></blockquote><ul><li>Replace filename with the actual name of the file.</li></ul><p><strong>Explanation of the command:</strong></p><ul><li>md5sum filename: Calculates the MD5 hash of the specified file.</li><li>|: Pipes the output of the md5sum command to the cut command.</li><li>cut -d &#39; &#39; -f 1: Extracts only the first field (the MD5 hash value) from the output.</li><li>&gt; filename.md5: Redirects the extracted hash value to a new file named filename.md5.</li></ul><p>4. Repeat this command for each file you want to create an MD5 file for.</p><p>Here, we generated MD5 files of all the artifacts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fRyBUDOhK71-7OpO.png" /></figure><h4><strong>2. Generate SHA1 file</strong></h4><p>The SHA1 file contains a 160-bit checksum value. To generate one, run the following command in the terminal.</p><p><strong>Steps:</strong></p><ol><li>Open a command terminal</li><li>Navigate to the directory containing the files you want to create SHA1 files for.</li><li>Use the following command to generate an SHA1 file for a specific file.</li></ol><blockquote><em>sha1sum filename | cut -d ‘ ‘ -f 1 &gt; filename.sha1</em></blockquote><p><strong>Explanation of the command:</strong></p><ul><li>sha1sum filename: Calculates the SHA1 hash of the specified file.</li><li>|: Pipes the output to the cut command.</li><li>cut -d &#39; &#39; -f 1: Extracts the SHA1 hash value.</li><li>&gt; filename.sha1: Redirects the hash value to a file named filename.sha1.</li></ul><p>4. Repeat this command for each file you want to create an SHA1 file for.</p><p>Here, we generated SHA1 files for all the artifacts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uXgiO1y2r033ials.png" /></figure><p>As for generating signature files, MD5 and SHA1 files for the artifacts, your library will contain the following files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PFfHIbPFSxIQrZmv.png" /></figure><p>Once you’ve fulfilled all the requirements for publishing artifacts on Maven Central, you can upload your components to the Maven Central Portal.</p><h3><strong>Step 9: Upload a bundle</strong></h3><p>The Maven central portal supports uploading a zip file containing your components and required files (metadata, checksums, signatures). We need to create a bundle of artifacts and upload the zip on the portal.</p><p>To create a bundle of artifacts, go to the repository folder under the .m2 folder → open the command terminal → run the following command.</p><blockquote><em>zip release.zip io/github/aparnatati471/mylibrary/1.0.0/*</em></blockquote><p>Explanation:</p><ul><li>zip release.zip: This is the main command used to create a ZIP archive named release.zip.</li><li>io/github/aparnatati471/mylibrary/1.0.0: This is the path to a directory containing the files you want to archive.</li><li>*: This is a wildcard character that matches any file or directory within the specified path (io/github/aparnatati471/mylibrary/1.0.0).</li></ul><p><strong>Here are the instructions for publishing the component:</strong></p><ul><li>Go to Maven Central Portal → open the namespace tab → click the <strong>Publish Component</strong> button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JYhZdYJYobeCEnjh.png" /></figure><ul><li>Fill in all the deployment details, like the name and the description, and upload the zip file → click the Publish Component button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BUTHh4XAKdGN83dK.png" /></figure><ul><li>Enter a “Deployment Name.” This will help you identify what you’re attempting to publish (e.g., given that you’re publishing to Maven Central, you could add your coordinates, i.e., “your.groupId:your.artifactId:0.0.your-version”). You can also provide a longer, optional “Description”. Scroll to the bottom of the popup to find the <strong>Choose File</strong> button.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JA64mSHNDaLXZPD6.png" /></figure><ul><li>Click the <strong>Choose File</strong> button → choose a file from your computer → click the <strong>Publish Component</strong> button to begin the upload.</li><li>When you publish the components, Maven Central will validate the component, and the portal will show the status V<strong>alidating.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T864avIeEv1cRQrc.png" /></figure><ul><li>Validation will fail if your components do not meet any requirements. If this happens, you can drop deployment components.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*goFat_67ecnopdIZ.png" /></figure><ul><li>Once Maven Central successfully validates components and the state changes from <strong>Validating</strong> to <strong>Validated</strong>, click the Publish button to publish the components and make them available to the portal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yhaCOalS52GpBFnm.png" /></figure><ul><li>Once the publishing process is completed, the state of your components will be changed from <strong>Publishing</strong> to <strong>Published</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MNaI5AG2ya5Q2xtd.png" /></figure><ul><li>Once you’ve successfully published the library on Maven, it’s time to find your component on <a href="https://central.sonatype.com/"><strong>Maven Central Portal</strong></a>.</li></ul><h3><strong>Conclusion</strong></h3><p><strong>Maven Central</strong> is a great way to contribute your open-source artifacts, which developers can easily consume in their projects. By adhering to the outlined steps and best practices, you can successfully share your Android libraries on Maven Central, making them readily available for others to incorporate into their projects.</p><blockquote><strong><em>For more updates on the latest tools and technologies, follow the </em></strong><a href="https://medium.com/simform-engineering"><strong><em>Simform Engineering</em></strong></a><strong><em> blog.</em></strong></blockquote><blockquote><strong><em>Follow Us: </em></strong><a href="https://twitter.com/simform"><strong><em>Twitter</em></strong></a><strong><em> | </em></strong><a href="https://www.linkedin.com/company/simform/"><strong><em>LinkedIn</em></strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=515c5d54f566" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/publishing-library-in-maven-central-part-2-515c5d54f566">Publishing Library in Maven Central [Part 2]</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publishing Library in Maven Central [Part 1]]]></title>
            <link>https://medium.com/simform-engineering/publishing-library-in-maven-central-part-1-994c5fe0c004?source=rss-9d33a4281005------2</link>
            <guid isPermaLink="false">https://medium.com/p/994c5fe0c004</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[maven]]></category>
            <category><![CDATA[gpg]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[maven-central]]></category>
            <dc:creator><![CDATA[Aparna Tati]]></dc:creator>
            <pubDate>Mon, 08 Apr 2024 06:39:35 GMT</pubDate>
            <atom:updated>2024-04-08T06:39:35.692Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A step-by-step approach to streamline your deployments</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z1Uh8KNy7FoBJdmmX_CTWQ.png" /></figure><p>The Maven Central portal allows open-source projects to host their artifacts (such as JAR, AAR, and any executable files) in the Maven Central Repository.</p><p>However, recent updates to Maven Central have made it difficult for newcomers to configure Gradle quickly and publish library packages.</p><p>In our two-series article, we’ll walk you through publishing Android library packages to Maven Central (from our GitHub repository).</p><p>This part will cover steps from creation to configuration; further steps will be presented in <a href="https://medium.com/simform-engineering/publishing-library-in-maven-central-part-2-515c5d54f566">part 2.</a></p><h4><strong>Table of Contents</strong></h4><ol><li><a href="#9302">Create a Maven Central Portal account</a></li><li><a href="#28a1">Namespace overview and guidance</a></li><li><a href="#cfa0">Add the namespace</a></li><li><a href="#2c48">Verify the namespace</a></li><li><a href="#79ad">Configure gradle files using the Maven-Publish plugin</a></li></ol><h3><strong>Step 1: Create a Maven Central Portal account</strong></h3><p>To create a Maven Central Portal account, click on the <strong>Sign In</strong> link at the top right of the <a href="https://central.sonatype.com/"><strong>Maven Central Portal</strong></a>.</p><p>If you don’t have an account, you’ll need to create one by providing a username, a valid email address, and a password. Afterwards, click on “Continue.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*iGTUj2nnbwgriqaeyttfHQ.jpeg" /></figure><p>Alternatively, you can use social logins via Google or GitHub. If you opt for a social login, Maven Central will access the email address associated with your social account.</p><p>Upon successful account creation, you’ll receive an account verification link via email. Click on the link to verify your account.</p><h3><strong>Step 2: Namespace overview and guidance</strong></h3><p>In this step, we will understand about namespace and guidance on choosing the namespace.</p><h4><strong>Namespace overview</strong></h4><p>The namespace, also known as a groupId in the Maven ecosystem, uniquely identifies the library across all libraries. It’s one of the three coordinates required to describe any component published to Maven Central (groupId, artifactId, and version).</p><ol><li><strong>groupId</strong>: The groupId identifies the library uniquely across all libraries. It can be the organization’s name or any other.</li><li><strong>artifactId</strong>: The name of the library.</li><li><strong>version</strong>: The version of the library.</li></ol><p>These three coordinates (groupId:artifactId:version) form a dependency. You will get this dependency once you successfully publish the library on Maven Central.</p><p>If you are new to the Maven central portal, you will have no verified namespaces and will see a prompt to view instructions for verifying namespaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLfeeusE7POLJYc-bfNEjQ.png" /></figure><p>Let’s understand how to choose a namespace. The section below gives some guidance on choosing a namespace.</p><h4><strong>Guidance on choosing a namespace</strong></h4><p>Maven Central provides two options to choose a namespace.</p><p><strong>1. Use domain name</strong></p><p>Maven Central allows the use of a domain name in a reversed manner. If you are the owner or maintainer of your domain, you can use any groupId starting with the reverse domain name and as many subsections as you made.</p><p>You need to add a DNS TXT record as proof of the domain during the namespace verification process. For detailed steps, refer to the <a href="#b85c">Verify Namespace</a> section.</p><p>For example, if your domain is example.com, you can use groupId starting with com.example, such as: com.example.domain, com.example.testsupport and so on.</p><p><strong>2. Use code hosting services with a personal group ID</strong></p><p>If you don’t have a domain name or find it impractical for a small project, you can choose this option.</p><p>You need to verify your ownership of the code hosting account. For detailed steps, refer to the <a href="#b85c">Verify Namespace section</a>.</p><p>The Maven Central supports the below code hosting services. For example, for the user <strong>myusername, </strong>the namespaces look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JNTz9h4aDX-NoBlJYHHn4w.png" /></figure><p><strong>Note</strong>: The username is the code hosting account username.</p><p>Let’s understand how to add a namespace. The next step describes the instructions for adding a namespace.</p><h3><strong>Step 3: Add a namespace</strong></h3><p>To add a namespace, follow these steps:</p><ul><li>Click on your profile at the top right corner of the portal page and select “View Namespaces.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hLfRjZuuJy00Cg7z3dImg.png" /></figure><ul><li>Click on the “Add Namespace” button, enter the chosen namespace based on the guidance provided, and click “Submit.”</li></ul><p>Here, we chose code hosting services for the namespace and added the namespace <strong>io.github.aparnatati471.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_zflsc2vK47TZaY5NiPkKg.png" /></figure><ul><li>Ensure that the namespace is not already registered with Maven Central. Or else, it will give an “The namespace is already registered” error.</li><li>If the namespace is valid and unregistered, a namespace request will be created but remain unverified until verification.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeGdqIf1AG7TTekBzg_ZQw.png" /></figure><ul><li>Now it’s time to verify the namespace. Without a verified namespace, Maven Central will not allow library publishing.</li></ul><h3>Step 4: Verify the namespace</h3><p>Once you add the namespace, you need to verify it. Verifying the namespace differs from verifying the domain name and personal group ID of various code hosting services. It depends on whether it’s done via DNS or code hosting services:</p><h4><strong>1. By DNS</strong></h4><p>To verify the namespace by DNS, Maven Central needs you to prove domain ownership by adding a DNS TXT record. Follow the instructions below to verify the namespace using DNS.</p><ul><li>Click the Verify Namespace button, and you will be asked to confirm whether you’re ready for the verification of the namespace.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*CRe9cEur1TrrK_nvwF3rfQ.png" /></figure><p>The above popup says to prove domain ownership by adding a DNS TXT record with a value set to the Verification Key we assigned to your namespace request.</p><ul><li>Click the <strong>Confirm</strong> button. It will move your request to the <strong>Verification Pending</strong> state.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*E6wMxn0W2RMJishA5ShqDw.png" /></figure><ul><li>Click the clipboard icon next to the Verification Key to copy the value to your computer’s clipboard.</li><li>You can then use this value to set up the DNS TXT record with your DNS registrar or web hosting provider.</li></ul><blockquote>Please see this <a href="https://central.sonatype.org/faq/how-to-set-txt-record/"><strong>FAQ</strong></a> for instructions on setting up DNS TXT records with popular DNS registrars and hosting providers.</blockquote><h4><strong>2. By code hosting services</strong></h4><p>To verify the namespace by code hosting service, prove the account ownership by creating a temporary, public repository with a name and the value set to the Verification Key Maven Central assigned to your namespace request.</p><p>For example, if you want to use io.github.myusername, you must create a public repository at <strong>github.com/myusername/verification-key</strong> specified location.</p><p>Follow the instructions below to verify the namespace using the code hosting service.</p><ul><li>Click the Verify Namespace button, and you will be asked to confirm whether you’re ready for the verification of the namespace.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hSSIkfhVqlrX6rQVn5_eQw.png" /></figure><p>Here, we choose namespace by code hosting services. So for the verification, I need to create a “<strong>sprtltdacq” </strong>repository at the specified location<strong> </strong><a href="https://github.com/aparnatati471"><strong><em>https://github.com/aparnatati471</em></strong></a></p><ul><li>Clicking the <strong>Confirm </strong>button<strong> </strong>will move your request to the <strong>Verification Pending</strong> state. Next to the Verification Key, click the clipboard icon to copy the value to your computer’s clipboard and create a repository at the specified location.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*urFCJ6hGcv87zuWJ2PqqIQ.png" /></figure><ul><li>The same applies to the other Hosting Services, e.g. if you want to use <strong>com.gitee.myusername</strong> you must create the public repository at <strong>gitee.com/myusername/verification-key</strong>.</li><li>When your namespace is verified, you can simply delete the empty repository at the end of the process. It is only needed during the validation phase.</li></ul><p><strong>Note:</strong> If you have set up your DNS TXT record correctly or followed the correct instructions for code hosting services for personal group ID, it should only take a few minutes for us to verify your namespace. You can refresh the Namespace page to see if the verification status has changed to <strong>Verified.</strong> If verification takes more than a few minutes to complete or returns an error, please e-mail <a href="/service/mailto:central-support@sonatype.com">central-support@sonatype.com</a> and provide as much supporting information as possible (e.g., screenshots, logs, steps to reproduce).</p><p>Once verification is completed, the namespace state changes to “Verified,” enabling you to publish components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nhjvil3lyLEY9wsmvO0NHg.png" /></figure><h3><strong>Step 5: Configure gradle files using the Maven-Publish plugin</strong></h3><p>Configuring Gradle files is crucial for publishing the library on Maven Central. Follow these steps:</p><h4>Configure plugins</h4><p>Add the <strong>maven-publish </strong>plugin in the plugins block of build.gradle.kts file of the library.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40d471ef4c153f89a6f656ea58a86cdd/href">https://medium.com/media/40d471ef4c153f89a6f656ea58a86cdd/href</a></iframe><h4><strong>Configure publication variant</strong></h4><p>Configure a component with a single publication variant created from the release build variant and add the source JAR as a secondary artifact. You can also configure <a href="https://developer.android.com/build/publish-library/configure-pub-variants"><strong>multiple publication variants</strong></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3cde45105f5457be5719a758d1f51d2/href">https://medium.com/media/e3cde45105f5457be5719a758d1f51d2/href</a></iframe><h4><strong>Configure the coordinates</strong></h4><p>Configure the project coordinates to determine the actual location of your library in the repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8568fbaf6d5c9f2f6a4b4bd24cc6f24b/href">https://medium.com/media/8568fbaf6d5c9f2f6a4b4bd24cc6f24b/href</a></iframe><p>Let’s understand the above code.</p><ol><li><strong>afterEvaluate</strong>: Adds an action to execute immediately after the project is evaluated.</li><li><strong>publishing</strong>: The configuration of how to “publish” the different components of a project.</li><li><strong>publications: </strong>A description of the files and metadata that should be published to a repository as a single entity.</li><li><strong>MavenPublication</strong>: It is the representation/configuration of how Gradle should publish something in Maven format.</li><li><strong>create&lt;MavenPublication&gt;(“release”)</strong>: Creates a Maven publication named “release.”</li><li><strong>from(components[“release”])</strong>: Provides the software component that should be published.</li></ol><h4><strong>Configure POM</strong></h4><p>POM stands for Project Object Model. It contains metadata about the project and its dependencies. Let’s understand the step-by-step configuration of the POM.</p><p><strong>1. Project name, description and URL</strong></p><p>For some human-readable information about your project, you need to provide the packaging, name, description, URL, and year of inception.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fce85aaebd1242a451f6b44f3ef734c6/href">https://medium.com/media/fce85aaebd1242a451f6b44f3ef734c6/href</a></iframe><p><strong>2. License information</strong></p><p>You need to provide the license information used to distribute your components. You can use the Apache License or the MIT license. Here, I have used the MIT license.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/940f258c6440d4577f4b8e67c2f05a03/href">https://medium.com/media/940f258c6440d4577f4b8e67c2f05a03/href</a></iframe><p><strong>3. Developer information</strong></p><p>You need to add developer information to the publications. Developer information includes ID, name, email, roles, organization details, etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b7aa230a93be1bd1e7a6e5c52b91214/href">https://medium.com/media/3b7aa230a93be1bd1e7a6e5c52b91214/href</a></iframe><p><strong>4. SCM Information</strong></p><p>You need to add SCM(Source Control Management) information. The SCM section of the POM provides information about the version control system used to manage the project&#39;s source code. It helps establish a clear connection between the released artifacts and the source code from which they were built.</p><p>The SCM information includes the connection and developer connection URLs for accessing the repository and the URL for browsing the repository.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f84a1011b034ab6a190eeedaa2140c3/href">https://medium.com/media/9f84a1011b034ab6a190eeedaa2140c3/href</a></iframe><p>Here is the complete gradle configuration:-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/015cc6ad2d63f0fe64b71c60c549911e/href">https://medium.com/media/015cc6ad2d63f0fe64b71c60c549911e/href</a></iframe><p>After configuring Gradle, you’ll have access to various Gradle tasks related to publishing, such as generating metadata and POM files, and publishing locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vPUP_Cg2PX4Iu9xxf-InIA.png" /></figure><p>Let’s understand the tasks of publishing.</p><ol><li><strong>generateMetadataFileForReleasePublication</strong></li></ol><p>This creates a JSON file for the publication named <em>PubName</em>, including metadata such as publish component information, file details, gradle version, and dependencies.</p><p>The default location for the POM file is <em>build/publications/$pubName/module.json </em>in your project section of Android Studio.</p><p><strong>2. generatePomFileFor<em>PubName</em>Publication</strong></p><p>This creates a POM file for the publication named <em>PubName, including </em>metadata such as project name, version, and dependencies.</p><p>The default location for the POM file is <em>build/publications/$pubName/pom-default.xml</em> in your project section of Android Studio.</p><p><strong>3. publish</strong></p><p>This aggregate task publishes all defined publications to all defined repositories.</p><p><strong>4. publishReleasePublicationToMavenLocal</strong></p><p>This copies the <em>PubName</em> publication to the local Maven cache — typically <em>&lt;home directory of the current user&gt;/.m2/repository</em> — along with the publication’s POM file and other metadata.</p><p><strong>5. publishToMavenLocal</strong></p><p>This copies all defined publications to the local Maven cache, including their metadata (POM files, etc.).</p><p>You can publish the components locally by the following command:</p><blockquote>./gradlew publishToMavenLocal</blockquote><p>This will publish all your modules configured for Maven into local Maven.</p><p>Once your Gradle is configured, you need to publish components locally on your computer by clicking the publishToMavenLocal gradle task. Your artifacts are located in the repository directory of the .m2 folder directory, which is in the current user’s home directory.</p><blockquote>In <a href="https://medium.com/@aparnatati47/publishing-library-in-maven-central-part-2-515c5d54f566"><strong>Part 2</strong></a>, we will cover the next steps in publishing the library to Maven Central. This section includes configuring and installing GPG, signing the artifacts, generating checksum files, and uploading the bundle.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=994c5fe0c004" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/publishing-library-in-maven-central-part-1-994c5fe0c004">Publishing Library in Maven Central [Part 1]</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>