You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

集成Android Alarm Manager Plus后构建失败:appcompat-1.7.0.aar转换错误

集成Android Alarm Manager Plus插件时的构建错误问题

我开发了一款重复提醒应用Rem,在尝试集成Android Alarm Manager Plus Flutter插件时遇到构建错误。该插件的环境要求如下:

  • Flutter >=3.3.0
  • Dart >=2.18.0 <4.0.0
  • Android compileSDK 34
  • Java 17
  • Android Gradle Plugin(AGP)>=8.3.0
  • Gradle wrapper >=8.4

我已满足大部分要求:更新了Flutter版本,修改gradle-wrapper.properties中的distributionUrl为Gradle 8.4,在项目根目录的build.gradle的dependencies中添加classpath "com.android.tools.build:gradle:8.3.0"以更新AGP。此时项目构建正常,但添加插件相关代码后,构建失败,报错信息如下:

ERROR:/home/sidam/.gradle/caches/transforms-3/53066ed9dfa936b8cd76913b06100409/transformed/jetified-appcompat-resources-1.7.0-runtime.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
Running Gradle task 'assembleDebug'...                                
ERROR:/home/sidam/.gradle/caches/transforms-3/7038acadd030567fcf0c7254fa247a16/transformed/appcompat-1.7.0-runtime.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null
Running Gradle task 'assembleDebug'...                                

Running Gradle task 'assembleDebug'...                                
FAILURE: Build failed with an exception.
Running Gradle task 'assembleDebug'...                                

Running Gradle task 'assembleDebug'...                                
* What went wrong:
Running Gradle task 'assembleDebug'...                                
Execution failed for task ':app:mergeExtDexDebug'.
Running Gradle task 'assembleDebug'...                                
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Running Gradle task 'assembleDebug'...                                
   > Failed to transform appcompat-resources-1.7.0.aar (androidx.appcompat:appcompat-resources:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Running Gradle task 'assembleDebug'...                                
      > Execution failed for DexingNoClasspathTransform: /home/sidam/.gradle/caches/transforms-3/53066ed9dfa936b8cd76913b06100409/transformed/jetified-appcompat-resources-1.7.0-runtime.jar.
Running Gradle task 'assembleDebug'...                                
         > Error while dexing.
Running Gradle task 'assembleDebug'...                                
   > Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Running Gradle task 'assembleDebug'...                                
      > Execution failed for DexingNoClasspathTransform: /home/sidam/.gradle/caches/transforms-3/7038acadd030567fcf0c7254fa247a16/transformed/appcompat-1.7.0-runtime.jar.
Running Gradle task 'assembleDebug'...                                
         > Error while dexing.
Running Gradle task 'assembleDebug'...                                

Running Gradle task 'assembleDebug'...                                
* Try:
Running Gradle task 'assembleDebug'...                                
> Run with --stacktrace option to get the stack trace.
Running Gradle task 'assembleDebug'...                                
> Run with --info or --debug option to get more log output.
Running Gradle task 'assembleDebug'...                                
> Run with --scan to get full insights.
Running Gradle task 'assembleDebug'...                                
> Get more help at https://help.gradle.org.
Running Gradle task 'assembleDebug'...                                

Running Gradle task 'assembleDebug'...                                
BUILD FAILED in 36s
Running Gradle task 'assembleDebug'...                                  36.6s
Error: Gradle task assembleDebug failed with exit code 1

我的app模块build.gradle配置如下:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "rem.reminds.you"
    compileSdkVersion 34
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID
        applicationId "rem.reminds.you"
        minSdkVersion 24
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {}

我尝试过以下解决方案,但均未彻底解决问题:

  • 添加multidex支持
  • 尝试降级appcompat版本,但不知道具体操作方法
  • 将minSdkVersion从21升级到24,仅部分缓解错误

此外,VS Code弹出以下警告:

Project android: Unsupported Java Runtime: The Java version: 17, that is selected for the project is not supported by Gradle 7.2.The IDE will attempt to use Gradle 8.7 to gather the project information.
Possible solutions:
* Upgrade your Gradle version on your project
* Select Java Runtime 16 (or below), on Build > Gradle Execution settings, to avoid this problem!

我明明已经配置了Gradle 8.4,但警告显示项目使用的是Gradle 7.2,这可能是问题根源,但我不清楚具体原因。


内容的提问来源于stack exchange,提问作者ThisIsSidam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 06:17:12