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

React Native旧项目GoNote安卓端启动崩溃问题求助

Fixing "GoNote keeps stopping" with Google Play Services Class Inaccessibility Error

Hey there, let's tackle this crash you're hitting with your GoNote React Native app. That error about com.google.android.gms.location.ActivityRecognitionResult extending an inaccessible class is almost always tied to mismatched or outdated Google Play Services dependencies—super common in projects that haven't been touched in a year. Here's how to fix it step by step:

1. Unify Google Play Services Dependency Versions

The biggest culprit here is usually different modules in your project pulling in conflicting versions of Google Play Services. Let's standardize them:

  • Open your project's root build.gradle file.
  • Add or update the ext block to define a single version for all Google Play Services dependencies:
    buildscript {
        ext {
            googlePlayServicesVersion = "21.0.1" // Use a stable version compatible with your RN version
            // ... other variables like reactNativeVersion
        }
        // ... rest of buildscript
    }
    
  • Now, go to your app-level build.gradle and make sure all Google Play Services-related dependencies use this variable. For example:
    implementation "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
    implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
    

This ensures no conflicting versions are being pulled in.

2. Clean Caches & Rebuild from Scratch

Old cached files often cause weird dependency issues, especially after syncing an older project:

  • In Android Studio, run Build > Clean Project
  • Open your terminal and run these commands to clear React Native and Gradle caches:
    npx react-native start --reset-cache
    ./gradlew clean
    
  • Sync your project again (File > Sync Project with Gradle Files) and try building/running the app.

3. Verify React Native & Google Play Services Compatibility

Since your project is a year old, your React Native version might not play nice with the latest Google Play Services releases. Check the React Native official docs for the recommended Google Play Services version for your RN version. If needed:

  • Either downgrade Google Play Services to a version that matches your RN version, or
  • Gradually upgrade your React Native version (note: this might require updating other dependencies too, so proceed carefully).

4. Hunt Down Dependency Conflicts

If unifying versions doesn't work, some third-party dependency might be sneaking in a conflicting Google Play Services version. To find out:

  • Run this command in your terminal to generate a full dependency tree:
    ./gradlew app:dependencies
    
  • Look for entries under com.google.android.gms:play-services-location or related modules—if you see multiple versions listed, identify which dependency is pulling in the old one.
  • Exclude the conflicting version from that dependency in your app-level build.gradle. For example:
    implementation('com.example:some-third-party-lib:1.0.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-location'
    }
    

5. Adjust ProGuard/R8 Rules (If Obfuscation is Enabled)

If you have code obfuscation turned on, ProGuard might be accidentally stripping the required classes. Add these rules to your proguard-rules.pro file:

-keep class com.google.android.gms.internal.zzbfm { *; }
-keep class com.google.android.gms.location.ActivityRecognitionResult { *; }

If you want a broader rule (not ideal for app size, but useful for testing), you can use:

-keep class com.google.android.gms.** { *; }

Start with step 1 and 2 first—those usually resolve this specific error. If not, work your way through the other steps.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 08:10:03