权限被拒绝:android.Manifest.Permission.READ\u外部存储

权限被拒绝:android.Manifest.Permission.READ\u外部存储,android,gradle,permissions,build.gradle,android-external-storage,Android,Gradle,Permissions,Build.gradle,Android External Storage,我读过所有类似的问题,但找不到解决办法。它是安卓10。 我需要你的帮助 file.isFile返回true。 但是file.canRead返回false。因此,FileInputStreamfile导致以下错误:; android.system.ErrnoException:打开失败:EACCES权限被拒绝 清单文件: <manifest xmlns:android="http://schemas.android.com/apk/res/android"

我读过所有类似的问题,但找不到解决办法。它是安卓10。 我需要你的帮助

file.isFile返回true。 但是file.canRead返回false。因此,FileInputStreamfile导致以下错误:; android.system.ErrnoException:打开失败:EACCES权限被拒绝

清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.CAMERA" />
    
        <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    
   <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="MyApp"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"

    android:name="androidx.multidex.MultiDexApplication">

    <activity android:name=".allresults"/>

    <activity android:name=".DiagnoseActivity">
        <intent-filter>
            <action android:name="com.dailystudio.deeplab.MainActivity" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".profileActivity" />

    <activity android:name=".LoginActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".MainActivity" />

    <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
        android:theme="@style/Base.Theme.AppCompat"/> 

    
    </manifest>
请尝试将android:requestLegacyExternalStorage=true属性添加到AndroidManifest.xml文件中的应用程序标记:


您还应该在运行时请求该权限,请检查。

当我添加这一行时,它表示该属性仅在API级别29和更高的当前最小值23中使用。这没关系,请尝试添加它并检查它是否有效。@Member add tools:targetApi=q以及android:requestLegacyExternalStorage=true。警告将消失…工具:不相关。这只是工具,谢谢你,谢尔盖
android {
    compileSdkVersion 29 // <====
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.HT1"
        minSdkVersion 23  // minSdkVersion 16  // <====
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        multiDexEnabled true

    }
buildscript {
    ext.kotlin_version = '1.3.72' //'1.3.61'
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
<application
    ...
    android:requestLegacyExternalStorage="true">