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

升级至Android Studio Flamingo后Dagger项目编译失败求助

Fixes for Dagger Compilation Error After Android Studio Upgrade

1. Add JVM Export Flags to Compiler Args

In your app-level build.gradle file, add the following under the compileOptions block to grant access to the required internal JDK modules:

android {
    compileOptions {
        // Match source/target compatibility to your project's JDK version
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
        
        compilerArgs.add('--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED')
        compilerArgs.add('--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED')
    }
}

2. Verify JDK Consistency Across Machines

  • Open Android Studio → File → Project Structure → SDK Location
  • Confirm the JDK location matches the path used on the working machine.
  • Ensure both machines run the same JDK version (e.g., OpenJDK 11 or Oracle JDK 11).

3. Enable Dagger's Aggregating Task

Add this to your app-level build.gradle to resolve annotation processing conflicts:

android {
    annotationProcessorOptions {
        arguments += [
            "dagger.compiler.experimental.enableAggregatingTask": "true"
        ]
    }
}

4. Clear Gradle Daemon Cache

Corrupted daemon cache can cause inconsistent behavior. Run these commands in your project root:

./gradlew clean
./gradlew --stop
rm -rf ~/.gradle/caches # macOS/Linux
# Windows: rmdir /s /q %USERPROFILE%\.gradle\caches

Then re-sync and rebuild the project.

5. Check Third-Party Plugin Compatibility

Ensure all custom/third-party Gradle plugins are updated to versions compatible with Gradle 7.4.2 and your Android Studio version. Temporarily disable non-essential plugins to rule out conflicts.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 20:42:15