fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
900 stars 506 forks source link

Android 13 Download not working,Working till android 12 #840

Open BriceJoshy opened 1 year ago

BriceJoshy commented 1 year ago

This is manifest file

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

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion"/>

<queries>

<application android:label="MOSC \nExchange" android:name="${applicationName}" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">

        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <provider
        android:name="vn.hunghd.flutterdownloader.DownloadedFileProvider"
        android:authorities="${applicationId}.flutter_downloader.provider"
        android:exported="false"
         android:grantUriPermissions="true">
         <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
    </provider>
    <!-- Begin FlutterDownloader customization -->
    <!-- disable default Initializer -->
    <provider
        android:name="androidx.startup.InitializationProvider"
        android:authorities="${applicationId}.androidx-startup"
        android:exported="false"
        tools:node="merge">
        <meta-data
            android:name="androidx.work.WorkManagerInitializer"
            android:value="androidx.startup"
            tools:node="remove" />
    </provider>

    <!-- declare customized Initializer -->
    <provider
        android:name="vn.hunghd.flutterdownloader.FlutterDownloaderInitializer"
        android:authorities="${applicationId}.flutter-downloader-init"
        android:exported="false">
        <!-- changes this number to configure the maximum number of concurrent tasks -->
        <meta-data
            android:name="vn.hunghd.flutterdownloader.MAX_CONCURRENT_TASKS"
            android:value="5" />
    </provider>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>

This is build gradle

def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }

apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android { compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.hospital_app"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdkVersion 29
    targetSdkVersion 33
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
}

}

flutter { source '../..' }

dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:31.2.3')

// Add the dependencies for the In-App Messaging and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-inappmessaging-display'
implementation 'com.google.firebase:firebase-analytics-ktx'

}

781flyingdutchman commented 1 year ago

Try background_downloader and see if it meets your needs.

longsirhero commented 1 year ago

I also have this problem, the download task has been in the queue

device : pixel 4a, android 13

Flutter version 3.7.10 on channel stable

mohabbatta commented 1 year ago

i have the same problem
android 12

Alvish0407 commented 1 year ago

I thought same way for android and iOS both but after 2 days of hard-work I found out that my implementation was somewhat wrong. If you provide me with your implemented code, I'll do my best to assist you in resolving any issues you may be facing.

ucola commented 1 year ago

any progress? I try it on android 13 with pixel7a also not working... we always have the problem that hasStoragePermission is set to false

Alvish0407 commented 1 year ago

any progress? I try it on android 13 with pixel7a also not working... we always have the problem that hasStoragePermission is set to false

Set targetSdkVersion to 32

adham-ashraf77 commented 1 year ago

@Alvish0407 tried solution and download working now on android 13 but set target to 32 when you upload to play console need to upgrade to 33 is there a way that download working on targetSdkVersion 33 ?

Alvish0407 commented 1 year ago

@Alvish0407 tried solution and download working now on android 13 but set target to 32 when you upload to play console need to upgrade to 33 is there a way that download working on targetSdkVersion 33 ?

I have uploaded one app on play store having targetSdkVersion set to 32 though.

What error are using facing on console ? can you share ?

adham-ashraf77 commented 1 year ago

I think it will be problem in the neat future so I'm looking for a solution for download on api 33

Alvish0407 commented 1 year ago

I think it will be problem in the neat future so I'm looking for a solution for download on api 33

@781flyingdutchman has mentioned background_downloader above.

I haven't tried but maybe it might be what you are looking for. Let us know if you implement and make it work for 33.

781flyingdutchman commented 1 year ago

Staring August 31 all Android apps uploaded to the Play store must target API 33. The background_downloader package supports API 33.

MohammedSalehelShazly commented 1 year ago

see this solution it's work with me https://github.com/fluttercommunity/flutter_downloader/issues/866#issuecomment-1637088268