红日地产 發表於 2022-3-17 10:18:00

Android Studio运行、离线打包uni-app项目

<div>首先需要下载Android Studio<br>下载HBuilderX<br>下载Android离线打包SDK(https://nativesupport.dcloud.net.cn/AppDocs/download/android)</div>
<div><ol>
<li>&nbsp;创建android项目</li>
</ol>
<p>    <img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317095834562-1733064277.png"></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317095951318-968727626.png"></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100022404-569479785.png">   </p>
<p>  2.&nbsp; 配置项目</p>
<div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 将Android离线打包SDK中的lib.5plus.base-release.aar、android-gif-drawable-release@.arr、uniapp-v8-release.aar、oaid_sdk_.aar拷贝到android项目的app的libs中(为你下载的最新的版本号)</div>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100235459-989441244.png">
<p>&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100303198-1180105824.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;打开app -&gt; build.gradle<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;在android下面添加</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">aaptOptions {&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;additionalParameters '--auto-add-overlay'&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
}
</pre>
</div>
<p>  在dependencies下面添加</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p>
<div class="cnblogs_code">
<pre>implementation fileTree(dir: <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">libs</span><span style="color: rgba(128, 0, 0, 1)">'</span>, include: [<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">*.aar</span><span style="color: rgba(128, 0, 0, 1)">'</span>, <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">*.jar</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">], exclude: [])
implementation </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">com.github.bumptech.glide:glide:4.11.0</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
implementation </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">com.alibaba:fastjson:1.1.46.android</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
implementation </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">com.google.code.gson:gson:2.8.6</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
implementation </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">com.facebook.fresco:fresco:1.13.0</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">
implementation </span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">com.facebook.fresco:animated-gif:1.13.0</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
implementation </span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">androidx.recyclerview:recyclerview:1.1.0</span><span style="color: rgba(128, 0, 0, 1)">'</span></pre>
</div>
<p>&nbsp; &nbsp; &nbsp; &nbsp;打开app -&gt; src -&gt; main -&gt; AndroidManifest.xml将默认生成在application标签内的全部注释</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100505585-1724307033.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;在application内添加</p>
<div class="cnblogs_code">
<pre>&lt;<span style="color: rgba(0, 0, 0, 1)">activity&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">io.dcloud.PandoraEntry</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:configChanges</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">orientation|keyboardHidden|keyboard|navigation</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:label</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">@string/app_name</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:launchMode</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">singleTask</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
&nbsp;&nbsp;&nbsp;&nbsp;android:hardwareAccelerated</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">true</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:theme</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">@style/TranslucentTheme</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:screenOrientation</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">user</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:windowSoftInputMode</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">adjustResize</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;<span style="color: rgba(0, 0, 0, 1)">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;intent-filter&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;<span style="color: rgba(0, 0, 0, 1)">action
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">android.intent.action.MAIN</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;<span style="color: rgba(0, 0, 0, 1)">category
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">android.intent.category.LAUNCHER</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/intent-filter&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;
</span>&lt;/activity&gt;
&lt;<span style="color: rgba(0, 0, 0, 1)">activity&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">io.dcloud.PandoraEntryActivity</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:launchMode</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">singleTask</span><span style="color: rgba(128, 0, 0, 1)">"</span>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;android:configChanges=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:hardwareAccelerated</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">true</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;
&nbsp; &nbsp; android:permission</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">com.miui.securitycenter.permission.AppPermissionsEditor</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;
&nbsp; &nbsp; android:screenOrientation</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">user</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:theme</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">@style/DCloudTheme</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;android:windowSoftInputMode</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">adjustResize</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;intent-filter&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;<span style="color: rgba(0, 0, 0, 1)">category
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">android.intent.category.DEFAULT</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;<span style="color: rgba(0, 0, 0, 1)">category
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">android.intent.category.BROWSABLE</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;<span style="color: rgba(0, 0, 0, 1)">action
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">android.intent.action.VIEW</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;<span style="color: rgba(0, 0, 0, 1)">data
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:scheme</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">h56131bcf</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;!--provider节点必须添加--&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;
</span>&lt;<span style="color: rgba(0, 0, 0, 1)">provider
&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">io.dcloud.common.util.DCloud_FileProvider</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
&nbsp;&nbsp;&nbsp;&nbsp;android:authorities</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">${apk.applicationId}.dc.fileprovider</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
&nbsp;&nbsp;&nbsp;&nbsp;android:exported</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">false</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
&nbsp;&nbsp;&nbsp;&nbsp;android:grantUriPermissions</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">true</span><span style="color: rgba(128, 0, 0, 1)">"</span>&gt;<span style="color: rgba(0, 0, 0, 1)">&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&lt;meta-<span style="color: rgba(0, 0, 0, 1)">data
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:name</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">android.support.FILE_PROVIDER_PATHS</span><span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(0, 0, 0, 1)">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android:resource</span>=<span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">@xml/dcloud_file_provider</span><span style="color: rgba(128, 0, 0, 1)">"</span>/&gt;
&lt;/provider&gt;</pre>
</div>
<p>&nbsp;</p>
<p>&nbsp; &nbsp;注意:要将provider中的${apk.applicationId}修改为你的应用包名。可以在AndroidManifest.xml的跟标签下查看 &nbsp;&nbsp;</p>
<p>&nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100617386-964576529.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp;创建asstes文件夹</p>
<p>&nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100639003-259079601.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100647095-881198463.png"></p>
<p>&nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100702476-127800612.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp;&nbsp;</p>
<p>&nbsp; &nbsp;将Android离线打包SDK中assets下的data拷贝到项目中新建好的assets下<br>&nbsp; &nbsp;HBuilderX导出项目</p>
<div class="image-package">&nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100731445-1109618001.png">
<p>&nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100738867-384010924.png"></p>
<p>&nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100757325-325399500.png"></p>
<p>&nbsp; &nbsp; <span style="font-style: italic">将导出的__UNI__E085701文件夹拷贝到项目中assets文件夹下(这个文件夹名是uni-app的appId,不是固定的! 不是固定的! 不是固定的!)</span></p>
<div>
<div>&nbsp; &nbsp; 打开项目app -&gt; src -&gt; main -&gt; assets -&gt; data -&gt; dcloud_control.xml将appid改为自己导出的appid。</div>

</div>

</div>
<p>&nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100836335-1895397946.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp; 3. 运行</p>
<p>&nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317100953989-757515264.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp;4. 遇到问题</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;1)&nbsp;&nbsp;Android Studio编译报错:Error: Invoke-customs are only supported starting with Android O (--min-api&nbsp;26)</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;build.gradle文件中android节点下增加:</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101126461-1864551049.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp;2)&nbsp;&nbsp;Android Studio编译出现Installed Build Tools revision 31.0.0 is corrupted解决方法&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;设置步骤:</p>
<ol>
<li>顶部栏选Tools</li>
<li>SDK Manager</li>
<li>去除Android API 31的勾选并apply</li>
<li>按需勾选SDK Platforms,如Android 11.0®,并apply</li>

</ol>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101427066-400765837.png">&nbsp;</p>
<h2>&nbsp; &nbsp; &nbsp; <span style="font-family: 仿宋">设置build.gradle文件</span></h2>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101444196-185035587.png"></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101613853-733148955.png"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp; 3)&nbsp;&nbsp;Compatible side by side NDK version was not found.</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<code>File</code>-&gt;<code>Settings</code>-&gt;<code>Appearance...</code>-&gt;<code>Android SDK</code>-&gt;<code>SDK Tools</code>-&gt;<code>NDK(Side by side)</code>-&gt;<code>Apply</code></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101657674-245189826.png"></p>
<p>&nbsp; &nbsp;5.&nbsp; 打包</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101942301-1570194204.png"></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317101953363-868699103.png"></p>
<p>  点击打开打包之后apk存放的文件夹。目录为app -&gt; build -&gt; outputs -&gt; apk -&gt; debug</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;<img src="https://img2022.cnblogs.com/blog/1050391/202203/1050391-20220317102006165-1233436388.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</div>

</div>
<div id="MySignature" role="contentinfo">
    深度思考,全面总结,综合发展!!<br><br>
来源:https://www.cnblogs.com/strivegys/p/16016124.html
頁: [1]
查看完整版本: Android Studio运行、离线打包uni-app项目