Android 中的位置权限

发布于 2025-01-10 04:58:21 字数 6937 浏览 0 评论 0原文

Android 应用程序有问题 - 在需要选择权限才能始终访问正常应用程序功能的位置的页面上。我尝试按元素查找答案,但找不到有效的答案。在位置问题中,如果我按“使用此应用程序时允许”或“使用应用程序时允许”,谁会选择“仅允许这次”、“使用应用程序时允许”和“不使用位置”,我们会发生应用程序崩溃( Androis 说“App Stay sttipoing”,Logcat 说错误 java.lang.NoSuchFieldError: No field NO_OPTIONS of type Lcom/google/android/gms/common/api/Api$ApiOptions$NoOptions; 在类 Lcom/google/android/gms/common/api/Api$ApiOptions; 或其超类中('com.google.android.gms 的声明) .common.api.Api$ApiOptions' 出现在/data/app/~~rQbKzCsxKTXKzmSHzMzCww==/com.tost.toster-_CfPHvOMOHPAcSMGw_dcVA==/base.apk)

2022-02-26 23:47:53.398 10573-10573/com.tost.toster E/AndroidRuntime: FATAL EXCEPTION: 
main
    Process: com.tost.toster, PID: 10573
    java.lang.NoSuchFieldError: No field NO_OPTIONS of type 
Lcom/google/android/gms/common/api/Api$ApiOptions$NoOptions; in class 
Lcom/google/android/gms/common/api/Api$ApiOptions; or its superclasses (declaration of 
'com.google.android.gms.common.api.Api$ApiOptions' appears in 
/data/app/~~rQbKzCsxKTXKzmSHzMzCww==/com.tost.toster-_CfPHvOMOHPAcSMGw_dcVA==/base.apk)
        at com.google.android.gms.location.FusedLocationProviderClient.<init> 
   (com.google.android.gms:play-services-location@@18.0.0:1)
        at 
   
 com.tost.toster.firedate.Start.RegisterActivity.LocationRequest(RegisterActivity.java:378)
        at 
com.tost.toster.firedate.Start.RegisterActivity.access$900(RegisterActivity.java:58)
        at 
com.tost.toster.firedate.Start.RegisterActivity$4.onGranted(RegisterActivity.java:310)
        at com.nabinbhandari.android.permissions.Permissions.check(Permissions.java:105)
        at 
 
 
 
 com.tost.toster.firedate.Start.RegisterActivity.LocationPremissionCheck(RegisterActivity.java:307)
        at com.tost.toster.firedate.Start.RegisterActivity.onCreate(RegisterActivity.java:112)
            at android.app.Activity.performCreate(Activity.java:8207)
        at android.app.Activity.performCreate(Activity.java:8191)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3819)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4022)
        at 
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at 
 
 android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at 
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8653)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
2022-02-26 23:52:51.201 10573-13164/com.tost.toster W/alia.cityoflov: Accessing hidden 
method Ldalvik/system/CloseGuard;->close()V (greylist,core-platform-api, linking, 
allowed)

这是 AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.tost.toster">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />

 <application
    android:name=".Main.Application"
    android:allowBackup="true"
    android:icon="@mipmap/flirt_icon"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/flirt_icon"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".Settings.NotificationActivity" />
    <activity android:name=".Start.RemindActivity" />
    <activity android:name=".Start.StartActivity" />
    <activity android:name=".Settings.SupportActivity" />
    <activity android:name=".Settings.PasswordActivity" />
    <activity android:name=".Settings.EmailActivity" />
    <activity android:name=".Settings.AccountActivity" />
    <activity android:name=".Settings.ReportActivity" />
    <activity android:name=".Profile.ProfileEditActivity" />
    <activity android:name=".Main.MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Start.LoginActivity" />
    <activity android:name=".Start.RegisterActivity" />
    <activity android:name=".Message.MessageActivity" />
    <activity android:name=".Profile.ProfileActivity" />
    <activity
        android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
        android:theme="@style/Base.Theme.AppCompat" />
    <activity android:name=".Settings.SettingsActivity" />
    <activity android:name=".Settings.PrivacyActivity" />
    <activity android:name=".Accounts.AccountsActivity" />
    <activity android:name=".Premium.PremiumActivity" />

    <service android:name=".Extra.ServiceClass" />

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />


    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="@string/admob_unit_id" />


    <activity
        android:name="com.facebook.FacebookActivity"
        
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" />
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>
</application>

</manifest>

知道如何解决这个问题吗?

谢谢你!

Have have a problem with Android app - On page where need select permission to always accees to location for normal app functionaly. I try find answer by element, but can't find working answer. In location question who hawe options "Allow only this time", "Allow while usign app" and "Don't use location" if i press "Allow while using this app" or "Allow while using app" we have a app crash (Androis say "App stay sttipoing" and Logcat say error java.lang.NoSuchFieldError: No field NO_OPTIONS of type Lcom/google/android/gms/common/api/Api$ApiOptions$NoOptions; in class Lcom/google/android/gms/common/api/Api$ApiOptions; or its superclasses (declaration of 'com.google.android.gms.common.api.Api$ApiOptions' appears in /data/app/~~rQbKzCsxKTXKzmSHzMzCww==/com.tost.toster-_CfPHvOMOHPAcSMGw_dcVA==/base.apk)

2022-02-26 23:47:53.398 10573-10573/com.tost.toster E/AndroidRuntime: FATAL EXCEPTION: 
main
    Process: com.tost.toster, PID: 10573
    java.lang.NoSuchFieldError: No field NO_OPTIONS of type 
Lcom/google/android/gms/common/api/Api$ApiOptions$NoOptions; in class 
Lcom/google/android/gms/common/api/Api$ApiOptions; or its superclasses (declaration of 
'com.google.android.gms.common.api.Api$ApiOptions' appears in 
/data/app/~~rQbKzCsxKTXKzmSHzMzCww==/com.tost.toster-_CfPHvOMOHPAcSMGw_dcVA==/base.apk)
        at com.google.android.gms.location.FusedLocationProviderClient.<init> 
   (com.google.android.gms:play-services-location@@18.0.0:1)
        at 
   
 com.tost.toster.firedate.Start.RegisterActivity.LocationRequest(RegisterActivity.java:378)
        at 
com.tost.toster.firedate.Start.RegisterActivity.access$900(RegisterActivity.java:58)
        at 
com.tost.toster.firedate.Start.RegisterActivity$4.onGranted(RegisterActivity.java:310)
        at com.nabinbhandari.android.permissions.Permissions.check(Permissions.java:105)
        at 
 
 
 
 com.tost.toster.firedate.Start.RegisterActivity.LocationPremissionCheck(RegisterActivity.java:307)
        at com.tost.toster.firedate.Start.RegisterActivity.onCreate(RegisterActivity.java:112)
            at android.app.Activity.performCreate(Activity.java:8207)
        at android.app.Activity.performCreate(Activity.java:8191)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3819)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4022)
        at 
android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at 
 
 android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at 
android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8653)
        at java.lang.reflect.Method.invoke(Native Method)
        at 
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
2022-02-26 23:52:51.201 10573-13164/com.tost.toster W/alia.cityoflov: Accessing hidden 
method Ldalvik/system/CloseGuard;->close()V (greylist,core-platform-api, linking, 
allowed)

Here is AndroidManifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.tost.toster">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />

 <application
    android:name=".Main.Application"
    android:allowBackup="true"
    android:icon="@mipmap/flirt_icon"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/flirt_icon"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".Settings.NotificationActivity" />
    <activity android:name=".Start.RemindActivity" />
    <activity android:name=".Start.StartActivity" />
    <activity android:name=".Settings.SupportActivity" />
    <activity android:name=".Settings.PasswordActivity" />
    <activity android:name=".Settings.EmailActivity" />
    <activity android:name=".Settings.AccountActivity" />
    <activity android:name=".Settings.ReportActivity" />
    <activity android:name=".Profile.ProfileEditActivity" />
    <activity android:name=".Main.MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Start.LoginActivity" />
    <activity android:name=".Start.RegisterActivity" />
    <activity android:name=".Message.MessageActivity" />
    <activity android:name=".Profile.ProfileActivity" />
    <activity
        android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
        android:theme="@style/Base.Theme.AppCompat" />
    <activity android:name=".Settings.SettingsActivity" />
    <activity android:name=".Settings.PrivacyActivity" />
    <activity android:name=".Accounts.AccountsActivity" />
    <activity android:name=".Premium.PremiumActivity" />

    <service android:name=".Extra.ServiceClass" />

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/facebook_app_id" />


    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="@string/admob_unit_id" />


    <activity
        android:name="com.facebook.FacebookActivity"
        
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" />
    <activity
        android:name="com.facebook.CustomTabActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:scheme="@string/fb_login_protocol_scheme" />
        </intent-filter>
    </activity>
</application>

</manifest>

Any idea how to fix this?

Thank You!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文