Skip to content

Commit a97c719

Browse files
committed
📝 Update glide question.
1 parent 7539b53 commit a97c719

File tree

4 files changed

+128
-4
lines changed

4 files changed

+128
-4
lines changed

README-ZH.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Language: [English](README.md) | 中文简体
2323
* [使用方法](#使用方法-)
2424
* [简单的使用方法](#简单的使用方法)
2525
* [完整参数的使用方法](#完整参数的使用方法)
26+
* [常见问题](#常见问题)
2627
* [`File``Uint8List`创建`AssetEntity`的方法](#从file或uint8list创建assetentity的方法)
28+
* [控制台提示 'Failed to find GeneratedAppGlideModule'](#控制台提示-failed-to-find-generatedappglidemodule)
2729

2830
## 特性 ✨
2931

@@ -72,6 +74,49 @@ import 'package:wechat_assets_picker/wechat_assets_picker.dart';
7274

7375
应用至少需要声明三个权限:`INTERNET` `READ_EXTERNAL_STORAGE WRITE_EXTERNAL_STORAGE`
7476

77+
主项目组要实现 `AppGlideModule`。比如:
78+
`example/android/app/build.gradle`:
79+
```gradle
80+
apply plugin: 'com.android.application'
81+
apply plugin: 'kotlin-android'
82+
+ apply plugin: 'kotlin-kapt'
83+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
84+
85+
dependencies {
86+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
87+
+ implementation 'com.github.bumptech.glide:glide:4.11.0'
88+
+ kapt 'com.github.bumptech.glide:compiler:4.11.0'
89+
testImplementation 'junit:junit:4.12'
90+
}
91+
```
92+
93+
`example/android/app/src/main/kotlin/com/example/exampleapp/ExampleAppGlideModule.java`:
94+
```kotlin
95+
package com.example.exampleapp;
96+
97+
import com.bumptech.glide.annotation.GlideModule;
98+
import com.bumptech.glide.module.AppGlideModule;
99+
100+
@GlideModule
101+
public class ExampleAppGlideModule extends AppGlideModule {
102+
}
103+
```
104+
如果你使用了与该库不一样的`Glide`版本,请将以下内容添加到`build.gradle`
105+
```gradle
106+
rootProject.allprojects {
107+
subprojects {
108+
project.configurations.all {
109+
resolutionStrategy.eachDependency { details ->
110+
if (details.requested.group == 'com.github.bumptech.glide'
111+
&& details.requested.name.contains('glide')) {
112+
details.useVersion "4.11.0"
113+
}
114+
}
115+
}
116+
}
117+
}
118+
```
119+
75120
### iOS
76121

77122
将以下内容添加至`info.plist`
@@ -163,6 +208,8 @@ AssetPicker.pickAssets(
163208
});
164209
```
165210

211+
## 常见问题
212+
166213
### `File``Uint8List`创建`AssetEntity`的方法
167214

168215
如果需要使用此库结合一些拍照需求,可通过以下方法将`File``Uint8List`转为`AssetEntity`
@@ -179,4 +226,14 @@ final AssetEntity imageEntity = await PhotoManager.editor.saveImage(byteData); /
179226
final List<String> result = await PhotoManager.editor.deleteWithIds([entity.id]);
180227
```
181228

182-
参考文档: [flutter_photo_manager#insert-new-item](https://github.com/CaiJingLong/flutter_photo_manager#insert-new-item)
229+
参考文档: [flutter_photo_manager#insert-new-item](https://github.com/CaiJingLong/flutter_photo_manager#insert-new-item)
230+
231+
232+
### 控制台提示 'Failed to find GeneratedAppGlideModule'
233+
234+
```
235+
W/Glide (21133): Failed to find GeneratedAppGlideModule. You should include an annotationProcessor complie dependency on com.github.bumptech.glide:compiler in you application ana a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored.
236+
```
237+
238+
`Glide` 通过注解来保证单例,防止单例或版本之间的冲突,而因为`photo_manager`使用了`Glide`提供部分图片功能,所以使用它的项目必须实现自己的`AppGlideModule`。 请移步[Android](#android)部分了解如何实现。
239+

README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ An **assets picker** which looks like the one in WeChat, based on `photo_manager
2323
* [Usage](#usage-)
2424
* [Simple usage](#simple-usage)
2525
* [Complete param usage](#complete-param-usage)
26+
* [Frequent asked questions](#frequent-asked-question)
2627
* [Create `AssetEntity` from `File` or `Uint8List` (rawData)](#create-assetentity-from-file-or-uint8list-rawdata)
28+
* [Console warning 'Failed to find GeneratedAppGlideModule'](#glide-warning-failed-to-find-generatedappglidemodule)
2729

2830
## Features ✨
2931

@@ -70,6 +72,50 @@ import 'package:wechat_assets_picker/wechat_assets_picker.dart';
7072

7173
You need at lease three permissions: `INTERNET` `READ_EXTERNAL_STORAGE` `WRITE_EXTERNAL_STORAGE`.
7274

75+
Then the main project needs implementation of `AppGlideModule`. For example:
76+
`example/android/app/build.gradle`:
77+
```gradle
78+
apply plugin: 'com.android.application'
79+
apply plugin: 'kotlin-android'
80+
+ apply plugin: 'kotlin-kapt'
81+
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
82+
83+
dependencies {
84+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
85+
+ implementation 'com.github.bumptech.glide:glide:4.11.0'
86+
+ kapt 'com.github.bumptech.glide:compiler:4.11.0'
87+
testImplementation 'junit:junit:4.12'
88+
}
89+
```
90+
91+
`example/android/app/src/main/kotlin/com/example/exampleapp/ExampleAppGlideModule.java`:
92+
93+
```kotlin
94+
package com.example.exampleapp;
95+
96+
import com.bumptech.glide.annotation.GlideModule;
97+
import com.bumptech.glide.module.AppGlideModule;
98+
99+
@GlideModule
100+
public class ExampleAppGlideModule extends AppGlideModule {
101+
}
102+
```
103+
If you're using different versions of `Glide`, please add this to the `build.gradle`:
104+
```gradle
105+
rootProject.allprojects {
106+
subprojects {
107+
project.configurations.all {
108+
resolutionStrategy.eachDependency { details ->
109+
if (details.requested.group == 'com.github.bumptech.glide'
110+
&& details.requested.name.contains('glide')) {
111+
details.useVersion "4.11.0"
112+
}
113+
}
114+
}
115+
}
116+
}
117+
```
118+
73119
### iOS
74120

75121
Add following content to `info.plist`.
@@ -118,7 +164,7 @@ AssetPicker.pickAsset(context).then((List<AssetEntity> assets) {
118164

119165
### Complete param usage
120166

121-
```dart
167+
```dart
122168
List<AssetEntity> assets = <AssetEntity>{};
123169

124170
final List<AssetEntity> result = await AssetPicker.pickAssets(
@@ -160,6 +206,8 @@ AssetPicker.pickAssets(
160206
});
161207
```
162208

209+
## Frequent asked question
210+
163211
### Create `AssetEntity` from `File` or `Uint8List` (rawData)
164212

165213
In order to combine this package with camera shooting or something related, there's a wordaround about how to create an `AssetEntity` with `File` or `Uint8List` object.
@@ -176,4 +224,12 @@ If you don't want to keep the asset in your device, just delete it after you com
176224
final List<String> result = await PhotoManager.editor.deleteWithIds([entity.id]);
177225
```
178226

179-
ref: [flutter_photo_manager#insert-new-item](https://github.com/CaiJingLong/flutter_photo_manager#insert-new-item)
227+
ref: [flutter_photo_manager#insert-new-item](https://github.com/CaiJingLong/flutter_photo_manager#insert-new-item)
228+
229+
### Glide warning 'Failed to find GeneratedAppGlideModule'
230+
231+
```
232+
W/Glide (21133): Failed to find GeneratedAppGlideModule. You should include an annotationProcessor complie dependency on com.github.bumptech.glide:compiler in you application ana a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored.
233+
```
234+
235+
`Glide` needs annotation to keep singleton, prevent conflict between instances and versions, so while the photo manager uses `Glide` to implement image features, the project which import this should define its own `AppGlideModule`. See [Android](#android) section for implementation.

example/android/app/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if (flutterVersionName == null) {
2323

2424
apply plugin: 'com.android.application'
2525
apply plugin: 'kotlin-android'
26+
apply plugin: 'kotlin-kapt'
2627
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2728

2829
android {
@@ -60,7 +61,9 @@ flutter {
6061
}
6162

6263
dependencies {
63-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
65+
implementation 'com.github.bumptech.glide:glide:4.11.0'
66+
kapt 'com.github.bumptech.glide:compiler:4.11.0'
6467
testImplementation 'junit:junit:4.12'
6568
androidTestImplementation 'androidx.test:runner:1.1.1'
6669
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.example.example;
2+
3+
import com.bumptech.glide.annotation.GlideModule;
4+
import com.bumptech.glide.module.AppGlideModule;
5+
6+
@GlideModule
7+
public class ExampleAppGlideModule extends AppGlideModule {
8+
}

0 commit comments

Comments
 (0)