React Native生成APK发布版本失败,调试模式运行正常
Hey, I’ve dealt with this exact headache before—debug builds working fine but release APKs failing because of that missing lint-gradle dependency? Let’s get this sorted out step by step.
First, let’s break down why this happens: Debug builds often skip strict lint checks or use a different dependency resolution flow, but release builds trigger full lint validation, and your project can’t locate the required com.android.tools.lint:lint-gradle:26.1.0 package. Here’s how to fix it:
1. Update Your Root Build.gradle to Include Google’s Repository
The com.android.tools.lint:lint-gradle dependency is hosted in Google’s Maven repository, so make sure your root-level build.gradle (not the app module one) has this configured correctly:
buildscript { repositories { google() // Ensure this line is present jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.0' // Match this to a version compatible with lint-gradle 26.1.0 // ... other project dependencies } } allprojects { repositories { mavenLocal() google() // This needs to be here too jcenter() maven { url "$rootDir/../node_modules/react-native/android" } } }
Double-check that google() is listed in both buildscript and allprojects repositories—this is the most common fix for missing Google-hosted dependencies.
2. Adjust Lint Settings (Temporary Workaround or Permanent Tweak)
If you need to get the build working quickly, you can disable lint’s abort-on-error behavior in your app module’s build.gradle:
android { // ... other Android configuration lintOptions { abortOnError false // Lets the build continue even if lint finds issues // Optional: Keep lint warnings visible without stopping the build warning 'InvalidPackage' } }
Note: This is a workaround—long-term, you should address the actual lint-related warnings (like the deprecated API notes from react-native-maps) to keep your codebase healthy. Updating react-native-maps to a newer version might resolve those deprecation messages too.
3. Clean and Rebuild Your Project
After making the above changes, clear your build cache and trigger a fresh release build:
./gradlew clean ./gradlew assembleRelease
This ensures old cached dependencies are cleared and the new repository settings take full effect.
内容的提问来源于stack exchange,提问作者Kevin Georget

