Expo Detach后React Native项目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.gradlefile (not the project-level one). - Look for any references to
apply plugin: 'android-apt'at the top—remove that line entirely. - Replace any
aptdependencies in thedependenciesblock withannotationProcessor. 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.gradlefiles. - Replace every instance of
compilewith eitherimplementationorapi:- Use
implementationfor most dependencies—it keeps the dependency private to your module, which is more efficient. - Use
apionly 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:+' - Use
- Once you've made all replacements, sync Gradle and rebuild.
3. Android SDK Build Target Related Errors
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.gradlefile, find theandroidblock, and check the values forcompileSdkVersion,targetSdkVersion, andminSdkVersion. - 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

