Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 2553
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 1, 20222022-06-01T05:50:59+00:00 2022-06-01T05:50:59+00:00

kotlin – Permissions on AAR Android 11 adding external library

  • 0

[ad_1]

I am developing an application that makes use of a third party SDK, this SDK comes in an example project.
I only copied the contents of the libs folder to a new project,
Add the library in the build.gradle and it loads without problems, since I can see it in code and use its classes without any exceptions, the problem is that it gives me a permissions error in the Log.

I/DeviceAPI: UHF device = C72_6765

I/DeviceAPI: UHF_Init———–>DEVICE_C72_6765

D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 165 0111000100,
gpiolen=18

E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied

D/DeviceAPI: [mt_gpio_ioctl] platform=6765, gpio=set 21 0111000100,
gpiolen=17

E/DeviceAPI: [mt_gpio_ioctl] open error: [13]: Permission denied
W/_solutions.rfid: type=1400 audit(0.0:1956): avc: denied { read write
} for name=”mt_gpio” dev=”sysfs” ino=35345
scontext=u:r:untrusted_app:s0:c172,c256,c512,c768
tcontext=u:object_r:mt_gpio:s0 tclass=file permissive=0
app=com.computx_solutions.rfid

I/DeviceAPI: UHF_Init———–>DevIsOpen = 1

I/DeviceAPI: UHF_OpenAndConnect: uart = /dev/ttyS1

D/DeviceAPI_SerialPort: [SerialPort_Open] [13]: Permission denied

All Permission Denied errors do not appear in the sample application.

Working App build.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}
android {
    compileSdkVersion 31
//    buildToolsVersion "30.0.3"
    defaultConfig {
        applicationId "com.android.uhftest"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        //testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                abiFilters "armeabi"//abi体系结构下的so库
            }
        }
        vectorDrawables {
            useSupportLibrary true
        }
    }

    signingConfigs {
        debug {
            File strFile = new File("/chainway.keystore")
            storeFile file(strFile)
            storePassword "123456"
            keyPassword "123456"
            keyAlias "chainway"
        }
        release {
            File strFile = new File("/chainway.keystore")
            storeFile file(strFile)
            storePassword "123456"
            keyPassword "123456"
            keyAlias "chainway"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget="1.8"
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation files('libs/DeviceAPI_ver20220323_release.aar')


    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

}

Working manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.uhf"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:screenOrientation="portrait"
        android:theme="@style/CustomTheme">
        <activity
            android:name=".MainActivity"
            android:label="Main Acitivity"
            android:theme="@style/CustomTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activity.UHFMainActivity"
            android:label="@string/app_name" />
    </application>

</manifest>

NOT Working build.gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.computx_solutions.rfid"
        minSdk 27
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget="1.8"
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"


    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation files('libs/DeviceAPI_ver20220323_release.aar')
}

NOT working manifest

<?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.computx_solutions.rfid">

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.RFIDInventory"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.RFIDInventory">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I also tried to put the same sdk in both projects and it didn’t work.
Is there any other file that involves permissions or configurations of the external libraries that you are not considering?

It is worth mentioning that this error only occurs with android 11 since previously I was using a device with android 8 and it did not give me permission errors, I also tried to grant full write and read permissions and it did not work, besides that I have access to the code that works and nowhere does it use the permissions request and even in android it shows that it does not have any special permissions.

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 2 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 4 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 3 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.