zk998
zk998
  • 发布:2021-08-19 10:46
  • 更新:2021-08-19 16:20
  • 阅读:595

andorid本地打包出错

分类:HBuilderX

环境
====================
OS:WIN10
AndoridStudio版本 2020.3.1
Java: 1.8.0.241
HbuildX版本:3.2.2.200210818

问题描述
=================================================
已将lib.5plus.base-release.aar、android-gif-drawable-release@1.2.17.aar、uniapp-v8-release.aar和oaid_sdk_1.0.25.aar拷贝到libs目录下

已将SDK->assets->data文件夹拷贝到assets文件夹下

已将HBuilderX中的项目导出,将导出的资源复制到assets->apps下

因为测试,所以未配置启动icon和splash

在build.gradle文件中设置如下

plugins {  
    id 'com.android.application'  
}  

android {  
    compileSdk 30  

    defaultConfig {  
        applicationId "com.myapp.android"  
        minSdk 18  
        targetSdk 30  
        versionCode 1  
        versionName "1.0"  

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  
    }  

    buildTypes {  
        release {  
            minifyEnabled false  
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'  
        }  
    }  
    compileOptions {  
        sourceCompatibility JavaVersion.VERSION_1_8  
        targetCompatibility JavaVersion.VERSION_1_8  
    }  
}  

dependencies {  

    implementation 'androidx.appcompat:appcompat:1.2.0'  
    implementation 'com.google.android.material:material:1.3.0'  
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'  
    testImplementation 'junit:junit:4.+'  
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'  
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'  

    implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])  
    implementation "com.android.support:support-v4:30.0.0"  
    implementation "com.android.support:appcompat-v7:30.0.0"  
    implementation 'com.android.support:recyclerview-v7:30.0.0'  
    implementation 'com.facebook.fresco:fresco:1.13.0'  
    implementation "com.facebook.fresco:animated-gif:1.13.0"  
    implementation 'com.github.bumptech.glide:glide:4.9.0'  
    implementation 'com.alibaba:fastjson:1.1.46.android'  
}  

系统提示错误:
Cannot fit requested classes in a single dex file (# methods: 73350 > 65536)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
Caused by: com.android.tools.r8.internal.b: Cannot fit requested classes in a single dex file (# methods: 73350 > 65536)

Execution failed for task ':app:mergeDexDebug'.

A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
There was a failure while executing work items
A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

然后在build.gradle的 defaultConfig 中加入
multiDexEnabled true
可以编译通过

但在虚拟机和真机上提示app安装成功,但一直停留在启动页面,一直是loading状态。

2021-08-19 10:46 负责人:无 分享
已邀请:
DCloud_Android_DQQ

DCloud_Android_DQQ

报错信息 像是 单个dex超限了。 百度一下 多个dex配置

该问题目前已经被锁定, 无法添加新回复