title: AndroidX Jetifier unable/failed to transform 3rd-party transitive dependency that still use Support Library
body: <p>I've recently migrated my project to use <strong>AndroidX</strong></p>
  
  <p>My apps crashes, after I migrate to <strong>AndroidX</strong>, due to library still using <strong>Support Library</strong>. Here's a list of my 3rd-party dependencies/library, that failed to transform into <strong>AndroidX</strong>:</p>
  
  <ol>
  <li><code>com.clevertap.android:clevertap-android-sdk:3.4.2</code></li>
  <li><code>com.readystatesoftware.chuck:library:1.1.0</code></li>
  <li><code>com.ncapdevi:frag-nav:2.4.0</code></li>
  <li><code>jp.wasabeef:recyclerview-animators:2.3.0</code></li>
  <li><code>com.github.chivorns:smartmaterialspinner:1.1.6</code></li>
  <li><code>com.facebook.android:facebook-android-sdk:5.0.1</code></li>
  <li><code>com.github.PierfrancescoSoffritti:AndroidYouTubePlayer:7.0.1</code> (I still cannot upgrade it to 10.x.x, because major API changes)</li>
  <li><code>com.github.nikartm:image-support:1.0.5</code></li>
  </ol>
  
  <p>My Setups:</p>
  
  <pre><code>AS &amp; AGP: 3.6.2
  targetSdk: 29
  minSdk: 16
  Data &amp; View Binding: Both enabled
  Gradle DSL: Kotlin
  Gradle: gradle-6.0.1-all
  </code></pre>
  
  <p>What I've done so far:</p>
  
  <ol>
  <li>Using <code>Refactor -&gt; Migrate to AndroidX</code> tools from <strong>Android Studio</strong>, but ended-up force close it, because takes a long time</li>
  <li><code>android.enableJetifier=true</code> &amp; <code>android.useAndroidX=true</code></li>
  <li>Using the shell scripts to manually mapping <a href="https://gist.github.com/mochadwi/d233e4996f3e498f08f57d073e366c9b" rel="nofollow noreferrer">artifact, class and imports</a> from <strong>Support Library</strong> to <strong>AndroidX</strong>, <a href="https://blog.danlew.net/2018/11/14/the-reality-of-migrating-to-androidx/" rel="nofollow noreferrer">thanks @Danlew</a>, also <a href="https://youtu.be/Hyt7LR5mXLc?t=584" rel="nofollow noreferrer">@Danlew mentioned in ADS '19 talks here</a></li>
  <li>Already checked my <code>:app:dependencies</code> that 3rd-party dependencies already migrated to use <strong>AndroidX</strong> artifacts, but only a few of them (failed for the above dependencies list)</li>
  <li>Deleting <code>./root_project/.idea</code>, <code>./root_project/.gradle</code> &amp; <code>~/.gradle/caches</code> (to fix compile-error/IDE error, references: <a href="https://stackoverflow.com/questions/52518935/androidx-migrate-dependency-libraries">AndroidX migrate dependency / libraries</a></li>
  <li>Understanding the jetifier: <a href="https://stackoverflow.com/questions/51680671/what-is-jetifier">What is Jetifier?</a> &amp; <a href="https://developer.android.com/jetpack/androidx/releases/jetifier" rel="nofollow noreferrer">official android docs</a></li>
  <li>Did a workaround to use <strong>AndroidX</strong> for annotation processor like: <a href="https://github.com/bumptech/glide/issues/3080#issuecomment-495430590" rel="nofollow noreferrer">Glide &amp; Dagger</a></li>
  <li>Checking the <code>~/.gradle</code> directories for the <code>jetified-*</code> libs <a href="https://i.stack.imgur.com/a9CNV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a9CNV.png" alt="screenshot of my &lt;code&gt;~/.gradle&lt;/code&gt; contents"></a> the <code>jetified</code> aar exist, unfortunately it's failed for <code>clevertap</code> &amp; others libs listed above.</li>
  </ol>
  
  <p>My conclusions, the <code>jetifier</code> works by rewriting the binary <code>.class</code> of our 3rd-party library if <strong>Support Library</strong> imports/class detected, and modify (jetified/mapping it) into <strong>AndroidX</strong> respectively.</p>
  
  <p>But in my case, the <strong>dependencies listed above</strong> doesn't use correct <strong>AndroidX</strong> imports and resulting runtime crash, due to having a transitive dependent for <strong>Support Library</strong>.</p>
  
  <p>Does jetifier currently doesn't support transitive dependency inside 3rd-party library as well? But, strangely it works for a few library (unlisted from above)</p>
  
  <p><strong>[UPDATED 1]</strong></p>
  
  <p>In the meantime (quickfix):</p>
  
  <ol>
  <li>I did downloading all the transitive dependencies of the libraries exhaustively one-by-one</li>
  <li>Using <a href="https://github.com/bumptech/glide/issues/3080#issuecomment-495430590" rel="nofollow noreferrer"><code>jetifier-standalone</code></a> commands instead for the libraries <code>aar</code></li>
  <li>Manually adding the libraries <code>aar</code> and its dependencies to <code>app/build.gradle.kts</code> as <code>flatDirs</code></li>
  </ol>
  
  <p>Is this really a workaround, is there anything better I can do?</p>
  
  <p><strong>[UPDATED 2]</strong></p>
  
  <p>I've using a maintained version of chuck as well. But found this same issue as well:</p>
  
  <pre><code>cannot generate view binders com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.support.v7.widget.AppCompatImageView not found
  </code></pre>
  
  <p>After checking my 3rd-party libs, I also ended-up manually adding the <code>aar</code> after I use <code>jetifier-standalone</code> for this library:</p>
  
  <ol>
  <li><code>com.clevertap.android:clevertap-android-sdk:3.4.2</code></li>
  <li><code>com.github.nikartm:image-support:1.0.5</code></li>
  </ol>
  
  <p>Many also recommends to use <a href="https://stackoverflow.com/a/48811145/3763032"><code>api</code> instead of <code>implementation</code></a> but for me, I don't want to bloated my project with transitive dependency</p>
  
  <p>In <a href="https://stackoverflow.com/a/53503768/3763032">other SO</a> also recommends below:</p>
  
  <ol>
  <li>either remove the library, </li>
  <li>forked it to support androidx / waiting for the author to upgrade it</li>
  <li>manually using <code>jetifier-standalone</code> for those specicif libs, and include as local aar (this is my best approach, right now)</li>
  </ol>
  
  <p>Unless the <code>jetifier</code> able to state this into official documentation, for its limitation: <a href="https://developer.android.com/jetpack/androidx/releases/jetifier" rel="nofollow noreferrer">https://developer.android.com/jetpack/androidx/releases/jetifier</a></p>
  
  <p>Seems like there's the least we can do, and hope, many of the 3rd-party authors will upgrade to <strong>AndroidX</strong> soon.</p>
  
  <p>Here's a bonus article for references:</p>
  
  <ol>
  <li>You can use <a href="https://github.com/plnice/can-i-drop-jetifier/" rel="nofollow noreferrer">can-i-drop-jetifier</a> libs to <a href="https://proandroiddev.com/the-state-of-jetification-in-early-2019-plus-a-bonus-gradle-plugin-aac5854af910" rel="nofollow noreferrer">detects does your libs (transitively) needs jetifier enabled or not</a></li>
  <li><a href="https://medium.com/@markchristopherng/the-time-is-right-move-to-android-x-now-6de2c608135a" rel="nofollow noreferrer">The time is right to migrate to <strong>AndroidX</strong> with this baby-steps</a></li>
  <li><a href="https://proandroiddev.com/jetpack-series-1-androidx-a-headache-for-a-better-package-structure-62c3608596fd" rel="nofollow noreferrer">Better structure packaging with <strong>AndroidX</strong> and also a headache along the way</a></li>
  </ol>