The development environment

  1. Android Studio can be downloaded from Android Studio website OR Android Studio Chinese community
  2. HBuilderX

The hBuilder X version and SDK version have always been 3.1.22

  1. App offline SDK download: Latest Android PLATFORM SDK download

3.1.10 Application for Appkey is required, please clicklink

> keytool -genkey -v -keystore helloUniApp.store -alias helloUniApp  -keyalg RSA -validity 20000 -keystore ~/keystores/helloUniApp.store 

 Aa1234 
Copy the code

SDK Directory Description

| - HBuilder - | - HBuilder Hello App offline packaging demo application - both - AS the simplest example of integrated uni - App SDK library file directory | | - SDK - Feature - Android. XLS Android platform details of the corresponding expansion Feature API | -- Readme. TXT release notes documents and matters needing attention | - UniPlugin - Hello - AS uni native plug-in development exampleCopy the code

Prepare project

Method 1: New project

Open Android Studio and create a new blank project

Select Empty Activity and click Next.

Minimum API Level 21 or higher is recommended

Package name is used as an application flag and involves the application of third-party platform accounts. Generally, you are not advised to change the Package name. In general, set the Package name to the reverse domain name, for example, io.dcloud.hBuilder

Click Finish to complete the creation.

Note: The App offline SDK does not support Kotlin

Method 2: Import project TODO

After 2.7.0, hBuilder-integrate-as project will be provided. Hbuilder-integrate-as project can be imported directly and simpleDemo project can be run directly.

The configuration of engineering

  1. Base library Configuration

    Copy lib.5plus.base-release.aar, [email protected], uniapp-v8-release.aar and oaid_sdk_1.0.25.aar to libs directory

maven {
    url 'https://maven.aliyun.com/repository/google/'
}
maven {
    url 'https://maven.aliyun.com/repository/jcenter/'
}
Copy the code

Add resource references in build.gradle

~~~ 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" 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 "implementation". Com. Making bumptech. Glide: glide: 4.9.0 ' Implementation 'com. Alibaba: fastjson: 1.1.46. Android' ~ ~ ~ uni - app configuration need to be in the build. When adding aaptOptions gradle configuration ~ ~ ~ aaptOptions { additionalParameters '--auto-add-overlay' ignoreAssetsPattern "! .svn:! .git:.*:! CVS:! thumbs.db:! picasa.ini:! *.scc:*~"} ~~~ ** Note: Updating the SDK requires updating both the AAR /jar file and the build.gradle configuration **Copy the code

Error message:

Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with this: Refactor > Migrate to AndroidX… Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

Solutions:

Refactor > Migrate to AndroidX…

After completion, the content becomes:

 
// https://nativesupport.dcloud.net.cn/AppDocs/usesdk/android
implementation fileTree(dir: 'libs'.include: ['*.aar'.'*.jar'].exclude: [])
implementation 'androidx. Legacy: legacy support - v4:1.0.0'
implementation 'androidx. Appcompat: appcompat: 1.0.0'
implementation 'androidx. Recyclerview: recyclerview: 1.0.0'
implementation 'com. Facebook. Fresco ": the fresco" : 1.13.0'
implementation "Com. Facebook. Fresco" : animated - GIF: 1.13.0"
implementation 'com. Making. Bumptech. Glide: glide: 4.9.0'
implementation 'com. Alibaba: fastjson: 1.1.46. Android'
Copy the code
  1. Application configuration

    • Configuration Appkey

    3.1.10 Need to apply for Appkey, please applyreference

    Open androidmanifest.xml, navigate to Application node, create meta-data node, name is dcloud_appkey, value is the applied AppKey as follows:

    <application ... > <meta-data android:name="dcloud_appkey" android:value=" Appkey" />Copy the code

+ Set the application version

Added the following configuration:

VersionCode indicates the application version number (integer value), which is used to determine the upgrade of each application market. It is recommended that the value be consistent with the version -> code value in manifest.json. VersionName indicates the application version name (string), which is displayed in the system application management program. You are advised to use the version -> name value in manifest.json. ApplicationId indicates the package name of the application. You are not advised to change it. It is recommended to set targetSdkVersion to 25 or above. App offline SDK minSdkVersion Supports a minimum of 21. If the minSdkVersion is smaller than 21, it cannot be used on some models with a minimum of 5.0. The full build.gradle version can be found below.Copy the code
apply plugin: 'com.android.application' android { compileSdkVersion 29 defaultConfig { applicationId "com.example.myapplication" MinSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" multiDexEnabled true NDK {abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) implementation 'com. Making. Bumptech. Glide: glide: 4.9.0' / / base to rely on implementation 'com. Android. Support: support - v4:28.0.0' implementation 'com. Alibaba: fastjson: 1.1.46. Android'}Copy the code

Note: If the third-party SDK to be integrated has so library files, you only need to add armeabi-v7a, arm64-V8a and x86 folders, otherwise it will not run on some phones.

  • Configuring the Application Name

    Open app-> SRC -> main -> res -> values -> strings. XML file and change the value of app_name, which is the name of the app installed on the mobile desktop. It is recommended to correspond to name (application name in basic configuration) in manifest.json.

    • Configure the application startup page and the Provider node

    Add the following to the application node of androidmanifest.xml

    Note: The new project will have a MainActivity node by default, which must be deleted!

<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>
        <! -- Provider node must be added -->
<provider
    android:name="io.dcloud.common.util.DCloud_FileProvider"
    android:authorities="${apk.applicationId}.dc.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/dcloud_file_provider" />
</provider>
Copy the code

Note: ${apk.applicationId} must be replaced with the package name of the current application

If you need to rewrite the Application during the integration of the offline SDK, you must inherit the DCloudApplication; otherwise, the service logic in the SDK cannot run properly. Configure the corresponding application to androidmanifest.xml (below) and add tools:replace=" Android :name" to prevent conflicts.Copy the code
    <application  
        android:name="io.dcloud.test.TestApplication"  
        android:icon="@drawable/icon"  
        android:label="@string/app_name"  
        tools:replace="android:name">
    </application>
Copy the code
  • Configure the app icon and startup screen

    PNG indicates the application icon. PNG is the icon of the push message. PNG is the icon of the application startup page.Copy the code

    PNG, push. PNG and splash. PNG into drawable, drawalbe-LDPI, drawable- MDPI, drawable- hdPI, drawable-xhdpi, drawable-xxhdpi folder. Different file folders correspond to different picture sizes, please refer to the documentation

    Modify the icon attribute of the application node in androidmanifest.xml to @drawable/icon. The diagram below:

    Note: Splash. PNG displays differently on different devices. To prevent stretching, you are advised to use Android Studio to generate

  1. The allocation of resources

    The Default Android Studio project does not have assets folder. You need to create the assets folder manually, and create it in the same location as the Java directory.

    • Create a data folder and copy the resources

    Copy the SDK-> Assets ->data folder to the newly created assets folder as shown below:

    Note: When the SDK is upgraded, resources under data need to be updated at the same time.

    • Create the apps folder and copy the resources

    Export the project in HBuilderX and copy the exported resource to Assets -> Apps as shown below:

    Exporting APP Resources

    • Modify the dcloud_control. XML file

    Change the appID in dcloud_control. XML to the ID of the copied UNI-app, and make sure that the APPID in dcloud_control. XML is the same as the ID and folder name in manifest.json, as shown in the following figure:

    To generate a custom base, add debug=”true” and syncDebug=”true” under the root node, as shown below:

    Custom base supports hot update. Debug -server-release.aar needs to be typed into APK, which can be deleted when generating formal package.

    See the link for detailed steps

run

Connect the phone, click the button and run.

Set the signature

www.cnblogs.com/details-666…

Resolve “AppKey not configured or configured incorrectly” AppKey is not configured or configured INCORRECTLY **