ko2ic / image_downloader

Flutter plugin that downloads images and movies on the Internet and saves to Photo Library on iOS or specified directory on Android.
https://pub.dartlang.org/packages/image_downloader#-readme-tab-
MIT License
92 stars 115 forks source link

Can't compile, Kotlin error #58

Closed lalo-vergel closed 4 years ago

lalo-vergel commented 4 years ago

Hi. When trying to run the app both on Android Simulator or a physical Android device, I get the following error that won't let the build finish:

e: /Users/carlosvergel/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/image_downloader-0.19.1/android/src/main/kotlin/com/ko2ic/imagedownloader/ImageDownloaderPlugin.kt: (354, 41): Unresolved reference: random

FAILURE: Build failed with an exception.

I am running on AndroidX, and I have many other packages that require AndroidX and run well. Both my android simulator and physical device run Android 9.

I read that invalidating and restarting the caches in Android Studio might help. Did it. No use.

Package works great for iOS.

lalo-vergel commented 4 years ago

This seems to be the culprit (I have no experience with Kotlin, I need help):

val db = TemporaryDatabase(context)
                val allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz0123456789"
                val id = (1..20)
                    .map { allowedChars.random() }
                    .joinToString("")
                contentValues.put(MediaStore.Images.Media._ID, id)
                db.writableDatabase.insert(TABLE_NAME, null, contentValues)
                return id
ko2ic commented 4 years ago

@lalo-vergel Please refer to the following. https://github.com/ko2ic/image_downloader/wiki#compilation-error-in-kotlin-random