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

Expo Detach后React Native项目Android Studio构建报错求助

Fixing Common Errors When Building Detached Expo Project in Android Studio

Hey there, let's work through these issues you're facing after running exp detach on your Expo project—they're super common when moving from Expo's managed workflow to the bare one, so don't stress!

1. Incompatible Annotation Processing Plugin Error

This usually happens because the detached project might still be using outdated annotation processing tools (like the old android-apt plugin) that don't play nice with newer Android Studio versions. Here's how to fix it:

  • Open your app's module-level build.gradle file (not the project-level one).
  • Look for any references to apply plugin: 'android-apt' at the top—remove that line entirely.
  • Replace any apt dependencies in the dependencies block with annotationProcessor. For example:
    // Before
    apt 'com.google.dagger:dagger-compiler:2.x'
    // After
    annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
    
  • Sync your project with Gradle files (click the sync icon in Android Studio) and try building again.

2. "compile" Configuration is Deprecated Warning/Error

Google phased out the compile dependency configuration a while back, replacing it with implementation and api. Here's what you need to do:

  • Go through both your project-level and module-level build.gradle files.
  • Replace every instance of compile with either implementation or api:
    • Use implementation for most dependencies—it keeps the dependency private to your module, which is more efficient.
    • Use api only if you need other modules in your project to access this dependency (rare for most Expo detached apps).
      Example change:
    // Before
    compile 'com.facebook.react:react-native:+'
    // After
    implementation 'com.facebook.react:react-native:+'
    
  • Once you've made all replacements, sync Gradle and rebuild.

This error typically pops up when your project's target SDK version doesn't match what's installed in your Android SDK Manager. Follow these steps:

  • Open your module-level build.gradle file, find the android block, and check the values for compileSdkVersion, targetSdkVersion, and minSdkVersion.
  • Update these to a stable SDK version that you have installed (you can check available versions in the SDK Manager). For example:
    android {
        compileSdkVersion 34
        defaultConfig {
            targetSdkVersion 34
            minSdkVersion 21 // Keep this as per your app's minimum supported version
        }
    }
    
  • Open the SDK Manager (click the SDK icon in Android Studio's toolbar), make sure you've downloaded the SDK Platform for the version you set as compileSdkVersion, plus the corresponding Build Tools.
  • Sync your project and try building again.

After working through these three fixes, your project should build successfully in Android Studio!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 03:26:37