初次使用打包

  1. 使用 Android Studio 创建一个 Empty Activity
  2. app/src/main/java 清空, /app/src/main/res/drawable 只存放 icon.pngpush.pngsplash.pngapp/src/main/res/values 只保留 strings.xml
  3. lib.5plus.base-release.aar 复制到 libs 目录下
  4. 编辑工程目录的 build.gradle,参考后面 build.gradle 关键信息
  5. 编辑 Androidmanifest.xml 参考后面 bAndroidmanifest.xml 关键信息
  6. 将 sdk 中 assets 复制 /app/src/main/assets
  • build.gradle
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.web.app"
        minSdkVersion 22
        targetSdkVersion 23   // todo::关键 修改工程的targetSdkVersion大于等于21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
//        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
// todo::关键
    lintOptions {
        checkReleaseBuilds false  
        abortOnError false
    }
}
// todo::待确定
// repositories {
//    flatDir {
//        dirs 'libs'
//    }
//}
dependencies {
    implementation fileTree(include: ['*.aar'], dir: 'libs')

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//    testImplementation 'junit:junit:4.12'
//    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
//    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}
  • Androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="io.dcloud.HelloH5">

    <!-- 基座删除的部分权限 -->
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-feature android:name="android.hardware.camera.autofocus" />

    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />

    <uses-feature android:name="android.hardware.camera" />

    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.READ_SMS" />

    <application
        android:name="io.dcloud.application.DCloudApplication"
        android:allowClearUserData="true"
        android:debuggable="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:largeHeap="true"
        tools:ignore="HardcodedDebugMode">

        <activity
            android:name="io.dcloud.PandoraEntry"
            android:configChanges="orientation|keyboardHidden|keyboard|navigation"
            android:hardwareAccelerated="true"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="user"
            android:theme="@style/TranslucentTheme"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        <provider
            android:name="io.dcloud.common.util.DCloud_FileProvider"
            android:authorities="io.dcloud.HelloH5.dc.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/dcloud_file_provider" />
        </provider>


        <activity
            android:name="io.dcloud.PandoraEntryActivity"
            android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard"
            android:hardwareAccelerated="true"
            android:launchMode="singleTask"
            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>
参考资料

关键参数目录

请联系我 商务合作、广告投放、题目勘误、侵权投诉

点赞(1)

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部