<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # Android原生工程搭建 準備工作:到 [Android 離線SDK - 正式版](https://nativesupport.dcloud.net.cn/AppDocs/download/android) 下載最新的SDK ## 創建工程 首先創建一個空的Android工程: File | New | New Project... ![](https://kan.xiaoyulive.top/uniapp/001.png) 選擇Empty Activity ![](https://kan.xiaoyulive.top/uniapp/002.png) 為自己的工程取個名字,并配置包名、工程路徑等,點擊Finish。創建好的工程結構: ![](https://kan.xiaoyulive.top/uniapp/003.png) 修改 `app/build.gradle` ```groovy apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion '28.0.3' defaultConfig { applicationId "com.lizhiboxue.test" minSdkVersion 23 targetSdkVersion 28 versionCode 100 versionName "1.0.0" multiDexEnabled true ndk { abiFilters 'x86','armeabi-v7a' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } //使用uniapp時,需復制下面代碼 /*代碼開始*/ aaptOptions { additionalParameters '--auto-add-overlay' //noCompress 'foo', 'bar' ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" } /*代碼結束*/ } repositories { flatDir { dirs 'libs' } } dependencies { implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) implementation "com.android.support:support-v4:28.0.0" implementation "com.android.support:appcompat-v7:28.0.0" /*uniapp所需庫-----------------------開始*/ implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.facebook.fresco:fresco:1.13.0' implementation "com.facebook.fresco:animated-gif:1.13.0" /*uniapp所需庫-----------------------結束*/ // 基座需要,必須添加 implementation 'com.github.bumptech.glide:glide:4.9.0' implementation 'com.alibaba:fastjson:1.1.46.android' } ``` 包含以下改動: 1. 將其 targetSdkVersion 配置為28以下(為了適配Android Q,詳見[適配Android10 / Android Q(API 29)](https://ask.dcloud.net.cn/article/36199)) 2. 將其 targetSdkVersion 配置為21以上,建議此屬性值設為23,``io.dcloud.PandoraEntry` 作為apk入口時 必須設置 `targetSDKVersion>=21` 沉浸式才生效 3. minSdkVersion必須是19以上,uniapp才起作用 4. 添加 `ndk.abiFilters`,以支持指定的架構 5. 添加`aaptOptions`節點 6. 修改`dependencies` ## 引入依賴 首先導入`HBuilder-Integrate-AS`項目中的`simpleDemo`模塊 ![](https://kan.xiaoyulive.top/uniapp/004.png) ![](https://kan.xiaoyulive.top/uniapp/005.png) 可以看到以下結構: ![](https://kan.xiaoyulive.top/uniapp/006.png) 然后將`simpleDemo`模塊中的`libs`復制到`app`模塊中 ## 引入資源 先將我們自己創建的項目中的src刪掉,再將`simpleDemo`中的src復制覆蓋到app模塊中,可以看到以下目錄結構: ![](https://kan.xiaoyulive.top/uniapp/007.png) 接下來分別進行分析 ### 啟動圖及APP名稱 位于 `res`下的目錄結構: ![](https://kan.xiaoyulive.top/uniapp/008.png) 在`drawable`下: - `icon.png` 為應用的圖標。 - `push.png` 為推送消息的圖標。 - `splash.png` 為應用啟動頁的圖標。 在`values/string.xml`中,里面配置了應用的名稱: ```xml <resources> <string name="app_name">uniapp-android</string> </resources> ``` ### 應用配置 在`assets`中,apps下存放了所有的應用,以 `應用名/www` 的目錄結構存放。 ![](https://kan.xiaoyulive.top/uniapp/009.png) 可以看出,`www`目錄存放的都是一些編譯后的網頁資源(其實沒有編譯也行) 其中 `data` 目錄中的 `dcloud_control.xml` 可以指定特定的應用: ```xml <hbuilder> <apps> <app appid="HelloH5" appver=""/> </apps> </hbuilder> ``` ### AndroidManifest.xml `AndroidManifest.xml`為應用程序清單,需要將啟動頁面指定為`io.dcloud.PandoraEntry` ```xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="io.dcloud.simple"> <application android:allowBackup="true" android:allowClearUserData="true" android:icon="@drawable/icon" android:label="@string/app_name" android:largeHeap="true" android:supportsRtl="true"> <activity android:name="io.dcloud.PandoraEntry" android:configChanges="orientation|keyboardHidden|keyboard|navigation" android:label="@string/app_name" android:launchMode="singleTask" android:hardwareAccelerated="true" android:theme="@style/TranslucentTheme" android:screenOrientation="user" android:windowSoftInputMode="adjustResize" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="io.dcloud.PandoraEntryActivity" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard" android:hardwareAccelerated="true" android:permission="com.miui.securitycenter.permission.AppPermissionsEditor" android:screenOrientation="user" android:theme="@style/DCloudTheme" android:windowSoftInputMode="adjustResize"> <intent-filter> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <action android:name="android.intent.action.VIEW" /> <data android:scheme="h56131bcf" /> </intent-filter> </activity> </application> </manifest> ``` 之后集成各種資源的時候,還需要在 `AndroidManifest.xml` 中進行權限配置等操作。 ## 啟動程序 一切配置完畢,直接運行即可 ![](https://kan.xiaoyulive.top/uniapp/010.png) ![](https://kan.xiaoyulive.top/uniapp/011.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看