升级buildToolsVersion至27.0.3后,找不到FingerprintManager字节码如何解决?
Hey there, let's tackle that frustrating error you're hitting after updating your buildToolsVersion to 27.0.3. This issue usually pops up when there's a misalignment between your build configurations, or stale build artifacts are causing framework class references to break. Here's how to fix it step by step:
Step 1: Align your compileSdkVersion with buildToolsVersion
Your buildToolsVersion and compileSdkVersion need to be in sync. Since you're using buildToolsVersion '27.0.3', make sure your compileSdkVersion is set to 27 in your app-level build.gradle file. Mismatched versions can make the build tools look for framework classes in the wrong SDK directory:
android { compileSdkVersion 27 buildToolsVersion '27.0.3' // Rest of your Android config }
Step 2: Clean up stale build caches
Old build artifacts often cause weird reference issues like this. Let's wipe them out and rebuild from scratch:
- In Android Studio, go to
Build > Clean Project - Then run
Build > Rebuild Project
Or use the command line for a more thorough clean:
./gradlew clean assembleDebug
Step 3: Check for dependency conflicts
Third-party libraries might be pulling in conflicting framework stubs or outdated fingerprint-related dependencies. Run this command in your project root to inspect your dependency tree:
./gradlew app:dependencies
If you spot any libraries that seem to be overriding or excluding the fingerprint framework classes, use the exclude rule to remove the conflicting part. For example:
implementation('some-conflicting-library') { exclude group: 'com.android.support', module: 'support-fingerprint' }
Step 4: Verify AGP and Gradle compatibility
You're using Android Gradle Plugin 3.1.1 with Gradle 4.4, which is a valid compatible pair (AGP 3.1.x works with Gradle 4.4-4.7). But if the above steps don't work, try updating to a slightly newer compatible pair (like AGP 3.2.1 with Gradle 4.6) to rule out any bugs in the older versions.
Step 5: Migrate to BiometricPrompt (optional but recommended)
Since FingerprintManager is deprecated starting from API 28, migrating to the AndroidX BiometricPrompt library will not only prevent future issues but also give users a more consistent biometric authentication experience across devices. Add this dependency to your app-level build.gradle:
implementation 'androidx.biometric:biometric:1.1.0'
Then refactor your authentication code to use BiometricPrompt instead of the deprecated FingerprintManager class.
内容的提问来源于stack exchange,提问作者Dima Siryk

