83 lines
16 KiB
HTML
83 lines
16 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>AndroidXMigration · React Native Camera</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="<h1><a class="anchor" aria-hidden="true" id="androidx-migration"></a><a href="#androidx-migration" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>AndroidX Migration</h1>
|
|
"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="AndroidXMigration · React Native Camera"/><meta property="og:type" content="website"/><meta property="og:url" content="undefined/react-native-camera/"/><meta property="og:description" content="<h1><a class="anchor" aria-hidden="true" id="androidx-migration"></a><a href="#androidx-migration" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>AndroidX Migration</h1>
|
|
"/><meta property="og:image" content="undefined/react-native-camera/img/undraw_online.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="undefined/react-native-camera/img/undraw_tweetstorm.svg"/><link rel="shortcut icon" href="/react-native-camera/img/community.png"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"/><link rel="stylesheet" href="/css/code-block-buttons.css"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script><script type="text/javascript" src="/js/code-blocks-buttons.js"></script><script src="/react-native-camera/js/scrollSpy.js"></script><link rel="stylesheet" href="/react-native-camera/css/prism.css"/><link rel="stylesheet" href="/react-native-camera/css/main.css"/><script src="/react-native-camera/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/react-native-camera/"><img class="logo" src="/react-native-camera/img/community.png" alt="React Native Camera"/><h2 class="headerTitleWithLogo">React Native Camera</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class=""><a href="/react-native-camera/docs/installation" target="_self">Docs</a></li><li class=""><a href="/react-native-camera/docs/expo_usage" target="_self">Guides</a></li><li class=""><a href="/react-native-camera/docs/api" target="_self">API</a></li><li class=""><a href="/react-native-camera/docs/qa" target="_self">Help</a></li><li class=""><a href="https://github.com/react-native-community/react-native-camera" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="container mainContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/react-native-community/react-native-camera/master/docs/AndroidXMigration.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 class="postHeaderTitle">AndroidXMigration</h1></header><article><div><span><h1><a class="anchor" aria-hidden="true" id="androidx-migration"></a><a href="#androidx-migration" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>AndroidX Migration</h1>
|
|
<p>AndroidX is the replacement for Google Support Libraries. It is the open-source project that the Android team uses to
|
|
develop, test, package, version and release libraries within Jetpack. Moving forward, all new Android development
|
|
will be in AndroidX, the Support Libraries are depreciated.</p>
|
|
<blockquote>
|
|
<p>AndroidX is a major improvement to the original Android Support Library. Like the Support Library, AndroidX ships separately from the Android OS and provides backwards-compatibility across Android releases. AndroidX fully replaces the Support Library by providing feature parity and new libraries.</p>
|
|
</blockquote>
|
|
<p>See: <a href="https://developer.android.com/jetpack/androidx/">https://developer.android.com/jetpack/androidx/</a></p>
|
|
<h2><a class="anchor" aria-hidden="true" id="migration-via-android-studio"></a><a href="#migration-via-android-studio" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Migration via Android studio</h2>
|
|
<p>You can follow the instructions <a href="https://developer.android.com/jetpack/androidx/migrate">here</a> to migrate you existing
|
|
project.</p>
|
|
<h2><a class="anchor" aria-hidden="true" id="manual"></a><a href="#manual" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Manual</h2>
|
|
<h4><a class="anchor" aria-hidden="true" id="update-the-android-section-android-app-buildgradle-to"></a><a href="#update-the-android-section-android-app-buildgradle-to" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Update the android section <code>android/app/build.gradle</code> to</h4>
|
|
<pre><code class="hljs"><span class="hljs-attr">android</span> <span class="hljs-string">{</span>
|
|
<span class="hljs-attr">compileSdkVersion</span> <span class="hljs-string">28</span>
|
|
<span class="hljs-attr">buildToolsVersion</span> <span class="hljs-string">"28.0.3"</span>
|
|
|
|
<span class="hljs-attr">defaultConfig</span> <span class="hljs-string">{</span>
|
|
<span class="hljs-attr">...</span>
|
|
<span class="hljs-attr">minSdkVersion</span> <span class="hljs-string">16</span>
|
|
<span class="hljs-attr">targetSdkVersion</span> <span class="hljs-string">28</span>
|
|
<span class="hljs-attr">}</span>
|
|
<span class="hljs-attr">...</span>
|
|
</code></pre>
|
|
<p>If you have any <code>dependencies {</code> that are using the old Google Support Libraries, you'll need to update them
|
|
to use the androidx version. Can check the full migration list <a href="https://developer.android.com/jetpack/androidx/migrate">here</a>.</p>
|
|
<h4><a class="anchor" aria-hidden="true" id="update-android-app-src-main-androidmanifestxml"></a><a href="#update-android-app-src-main-androidmanifestxml" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Update <code>android/app/src/main/AndroidManifest.xml</code></h4>
|
|
<p>remove</p>
|
|
<pre><code class="hljs css language-xml"><span class="hljs-tag"><<span class="hljs-name">uses-sdk</span> <span class="hljs-attr">android:minSdkVersion</span>=<span class="hljs-string">"16"</span> <span class="hljs-attr">android:targetSdkVersion</span>=<span class="hljs-string">"26"</span> /></span>
|
|
</code></pre>
|
|
<h4><a class="anchor" aria-hidden="true" id="update-android-buildgradle"></a><a href="#update-android-buildgradle" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Update <code>android/build.gradle</code></h4>
|
|
<pre><code class="hljs"><span class="hljs-keyword">buildscript</span> {
|
|
<span class="hljs-keyword">repositories</span> {
|
|
google()
|
|
jcenter()
|
|
}
|
|
<span class="hljs-keyword">dependencies</span> {
|
|
<span class="hljs-keyword">classpath</span> <span class="hljs-string">'com.android.tools.build:gradle:3.2.1'</span>
|
|
|
|
<span class="hljs-comment">// <span class="hljs-doctag">NOTE:</span> Do not place your application dependencies here; they belong</span>
|
|
<span class="hljs-comment">// in the individual module build.gradle files</span>
|
|
}
|
|
}
|
|
|
|
<span class="hljs-keyword">allprojects</span> {
|
|
<span class="hljs-keyword">repositories</span> {
|
|
mavenLocal()
|
|
google()
|
|
jcenter()
|
|
maven { url <span class="hljs-string">"https://jitpack.io"</span> }
|
|
maven {
|
|
<span class="hljs-comment">// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm</span>
|
|
url <span class="hljs-string">"$rootDir/../node_modules/react-native/android"</span>
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
compileSdkVersion = <span class="hljs-number">28</span>
|
|
buildToolsVersion = <span class="hljs-string">'28.0.3'</span>
|
|
}
|
|
|
|
<span class="hljs-keyword">subprojects</span> { subproject ->
|
|
afterEvaluate{
|
|
<span class="hljs-keyword">if</span>((subproject.plugins.hasPlugin(<span class="hljs-string">'android'</span>) || subproject.plugins.hasPlugin(<span class="hljs-string">'android-library'</span>))) {
|
|
android {
|
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</code></pre>
|
|
<h4><a class="anchor" aria-hidden="true" id="update-android-gradleproperties"></a><a href="#update-android-gradleproperties" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Update <code>android/gradle.properties</code></h4>
|
|
<p>add</p>
|
|
<pre><code class="hljs"><span class="hljs-attr">android.enableJetifier</span> = <span class="hljs-literal">true</span><span class="hljs-comment">;</span>
|
|
<span class="hljs-attr">android.useAndroidX</span> = <span class="hljs-literal">true</span><span class="hljs-comment">;</span>
|
|
</code></pre>
|
|
<h4><a class="anchor" aria-hidden="true" id="update-android-gradle-wrapper-gradle-wrapperproperties"></a><a href="#update-android-gradle-wrapper-gradle-wrapperproperties" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Update <code>android/gradle/wrapper/gradle-wrapper.properties</code></h4>
|
|
<p>make sure your gradle <code>distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip</code></p>
|
|
</span></div></article></div><div class="docLastUpdate"><em>Last updated on 2019-6-2 by Greg Alexander</em></div><div class="docs-prevnext"></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#migration-via-android-studio">Migration via Android studio</a></li><li><a href="#manual">Manual</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/react-native-camera/" class="nav-home"><img src="/react-native-camera/img/community.png" alt="React Native Camera" width="66" height="58"/></a><div><h5>Docs</h5><a href="/react-native-camera/docs/en/installation.html">Getting Started</a><a href="/react-native-camera/docs/en/expo_usage.html">Guides</a><a href="/react-native-camera/docs/en/api.html">API Reference</a></div><div><h5>Community</h5><a href="/react-native-camera/en/users.html">User Showcase</a><a href="https://stackoverflow.com/questions/tagged/react-native-camera" target="_blank" rel="noreferrer noopener">Stack Overflow</a><a href="https://spectrum.chat/">Project Chat</a></div><div><h5>More</h5><a href="https://github.com/react-native-community/react-native-camera">GitHub</a><a class="github-button" href="https://github.com/react-native-community/react-native-camera" data-icon="octicon-star" data-count-href="/facebook/docusaurus/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Stars</a></div></section><a href="https://opensource.facebook.com/" target="_blank" rel="noreferrer noopener" class="fbOpenSource"><img src="/react-native-camera/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/></a><section class="copyright">Copyright © 2019</section></footer></div></body></html> |