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

Priority.PRIORITY_BALANCED_POWER_ACCURACY无法识别报错问题求助

问题解决方案
  • 确认依赖版本:保证Google Play Services Location依赖版本在18.0.0及以上,这是Priority类引入的最低版本。在模块级build.gradle中检查依赖:

    implementation 'com.google.android.gms:play-services-location:18.0.0+'
    
  • 导入正确的Priority类:在代码顶部添加正确的导入语句,避免类找不到的问题:

    import com.google.android.gms.location.Priority;
    
  • 使用推荐的LocationRequest创建方式:建议用LocationRequest.create()替代旧的new LocationRequest(),配合Priority常量使用:

    LocationRequest locationRequest = LocationRequest.create();
    locationRequest.setPriority(Priority.PRIORITY_BALANCED_POWER_ACCURACY);
    
  • 排查混淆配置:如果项目开启了代码混淆,需确保Priority类未被混淆,在proguard-rules.pro中添加:

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

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 16:42:35