Home > front end >  Application Crash on Android 12
Application Crash on Android 12

Time:07-20

Gredle file

compileSdkVersion 32
defaultConfig {
    applicationId "com"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode 165
    versionName "7.0.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    buildTypes {
        debug {
            versionNameSuffix ".debug"
            debuggable true
            applicationIdSuffix ".xxxx"
        }
        release {
            applicationIdSuffix ".xxxx"
            signingConfig signingConfigs.release
        }
    }
}

Manifest File

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.XXXXX.XXXXX">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />

<queries>
    <package android:name="com.google.android.apps.fitness" />
</queries>
<queries>
    <intent>
        <action android:name="android.media.action.IMAGE_CAPTURE" />
    </intent>
</queries>

<uses-feature
    android:name="android.hardware.bluetooth_le"
    android:required="true" />

<application
    android:name=".app.ApplicationClass"
    android:allowBackup="false"
    android:configChanges="orientation|screenSize|layoutDirection"
    android:icon="@mipmap/ic_smartscale_icon"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:networkSecurityConfig="@xml/network_security_config"
    android:requestLegacyExternalStorage="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true"
    tools:replace="android:allowBackup">


    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths" />
    </provider>

    <service
        android:name="com.clevertap.android.sdk.pushnotification.fcm.FcmMessageListenerService"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>


    <activity
        android:name=".app.BaseActivity"
        android:exported="true"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
        <nav-graph android:value="@navigation/nav_app" />
    </activity>

    <activity

        android:name=".share.ShareActivity"
        android:exported="true"
        android:screenOrientation="landscape">
        <intent-filter>
            <action android:name="com.actofit.share.smartscale" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.clevertap.android.sdk.InAppNotificationActivity"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="CLEVERTAP_ACCOUNT_ID"
        android:value="8R7-549-KR5Z" />
    <meta-data
        android:name="CLEVERTAP_TOKEN"
        android:value="c45-a2b" />
    <meta-data
        android:name="CLEVERTAP_USE_GOOGLE_AD_ID"
        android:value="1" />
    <meta-data
        android:name="FCM_SENDER_ID"
        android:value="948450444651" />

    <!--    <service-->
    <!--        android:name="com.qingniu.qnble.scanner.BleScanService"-->
    <!--        android:permission="android.permission.BIND_JOB_SERVICE" />-->
    <!--    <service-->
    <!--        android:name="com.qingniu.scale.measure.ble.ScaleBleService"-->
    <!--        android:permission="android.permission.BIND_JOB_SERVICE" />-->
    <!--    <service-->
    <!--        android:name="com.qingniu.scale.measure.broadcast.ScaleBroadcastService"-->
    <!--        android:permission="android.permission.BIND_JOB_SERVICE" />-->

    <service
        android:name="com.qingniu.qnble.scanner.BleScanService"
        android:permission="android.permission.BIND_JOB_SERVICE" />
    <service
        android:name="com.qingniu.scale.measure.ble.ScaleBleService"
        android:permission="android.permission.BIND_JOB_SERVICE" />
    <service
        android:name="com.qingniu.scale.measure.broadcast.ScaleBroadcastService"
        android:permission="android.permission.BIND_JOB_SERVICE" />
    <service
        android:name="com.qingniu.scale.wsp.ble.ScaleWspBleService"
        android:permission="android.permission.BIND_JOB_SERVICE" />
    <service
        android:name="com.qingniu.scale.measure.broadcast.ScaleFoodBroadcastService"
        android:permission="android.permission.BIND_JOB_SERVICE" />

    <service
        android:name=".biosense.BLeService"
        android:exported="false" />
    <service
        android:name=".util.fcm.FcmMessageListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <receiver
        android:name=".util.bluetooth.BluetoothBroadcastReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
        </intent-filter>
    </receiver>

    <activity
        android:name="com.actofit.smartscale.bot.activity.ChatBotActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.actofit.smartscale.payment.MakePaymentActivity"
        android:screenOrientation="portrait" />

    <!--        <provider-->
    <!--            android:name="androidx.core.content.FileProvider"-->
    <!--            android:authorities="com"-->
    <!--            android:exported="false"-->
    <!--            android:grantUriPermissions="true">-->
    <!--            <meta-data-->
    <!--                android:name="android.support.FILE_PROVIDER_PATHS"-->
    <!--                android:resource="@xml/file_paths" />-->
    <!--        </provider>-->
    <activity
        android:name="com.actofit.smartscale.share_report.ShareReportActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.actofit.smartscale.dite.ActivitySearchFood"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.actofit.smartscale.dite.ActivityFoodInfo"
        android:screenOrientation="portrait" />
    <activity
        android:name=".custom_webview.customCrome.WebviewActivity"
        android:screenOrientation="portrait" />

    <activity
        android:name=".kitchin_scale.KitchinScaleTakeReadingActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name="com.actofit.smartscale.offline_support.QuestionActivity"
        android:exported="true" />

    <activity
        android:name="com.actofit.smartscale.settings.GoalActivity"
        android:exported="true" />
    <activity
        android:name="com.actofit.smartscale.home.LogActivity"
        android:exported="true" />

    <activity
        android:name="com.actofit.smartscale.workout.OnBoardingActivity"
        android:configChanges="keyboardHidden|orientation|screenSize" />
    <activity
        android:name="com.actofit.smartscale.workout.GuidedWorkoutActivity"
        android:exported="true" />

    <activity
        android:name="com.actofit.smartscale.workout.RatingActivity"
        android:exported="true" />


    <meta-data
        android:name="CLEVERTAP_BACKGROUND_SYNC"
        android:value="1" />
    <receiver
        android:name=".util.fcm.NotificationBroadcastReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <action android:name="android.service.notification.NotificationListenerService" />
        </intent-filter>
    </receiver>
</application>

Exception

Fatal Exception: java.lang.SecurityException Permission Denial: starting Intent { act=android.bluetooth.adapter.action.REQUEST_ENABLE cmp=com.android.settings/.bluetooth.RequestPermissionActivity } from ProcessRecord{b25524d 23206:com.actofitSmartScale/u0a409} (pid=23206, uid=10409) requires android.permission.BLUETOOTH_CONNECT

CodePudding user response:

Defining the permissions in the Android Manifest is not enough. You need to request runtime permission.

Check: https://developer.android.com/training/permissions/requesting

CodePudding user response:

Not all permission is granted just because it is declared inside the AndroidManifest.

Make sure the app requests for BLUETOOTH_CONNECT permission as it is a runtime permission, follow this comprehensive guidline for requesting Bluetooth

  • Related