You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Android] Fix Unity plugins using the AndroidJavaProxy. (mUnityPlayer error) (#908)
* Fix AndroidJavaProxy error: assign mUnityPlayer in the MainActivity.
* Add MainActivity modifications to the readme.
* Adjust MainAcitivty modification documentation.
* Update some version numbers
Copy file name to clipboardExpand all lines: README.md
+57-8Lines changed: 57 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -183,28 +183,77 @@ android {
183
183
2. Depending on your gradle version, you might need to make sure the `minSdkVersion` set in `android\app\build.gradle` matches the version that is set in Unity.
184
184
Check the **Minimum API Level** setting in the Unity player settings, and match that version.
185
185
186
-
3. The Unity export script automatically sets the rest up for you. You are done with the Android setup.
186
+
3. (optional) Fixing Unity plugins.
187
+
The Unity widget will function without this step, but some Unity plugins like ArFoundation will throw `mUnityPlayer` errors on newer Unity versions.
188
+
189
+
This is needed for Unity 2020.3.46+, 2021.3.19 - 2021.3.20 and 2022.2.4 - 2022.3.18.
190
+
This requires a flutter_unity_widget version that is newer than 2022.2.1.
191
+
192
+
193
+
- 3.1. Open the `android/app/build.gradle` file and add the following:
194
+
195
+
```diff
196
+
dependencies {
197
+
+ implementation project(':flutter_unity_widget')
198
+
}
199
+
```
200
+
- 3.2. Edit your android MainActivity file.
201
+
The default location for Flutter is `android/app/src/main/kotlin/<app identifier>/MainActivity.kt`.
202
+
203
+
If you use the default flutter activity, change it to inherit `FlutterUnityActivity`:
5. Open the *android/app/build.gradle* file and change the following:
248
+
6. Open the *android/app/build.gradle* file and change the following:
200
249
201
250
```diff
202
251
dependencies {
203
252
+ implementation project(':unityLibrary')
204
253
}
205
254
```
206
255
207
-
6. open the *android/build.gradle* file and change the following:
256
+
7. open the *android/build.gradle* file and change the following:
208
257
209
258
```diff
210
259
allprojects {
@@ -218,7 +267,7 @@ allprojects {
218
267
}
219
268
```
220
269
221
-
7. If you need to build a release package, open the *android/app/build.gradle* file and change the following:
270
+
8. If you need to build a release package, open the *android/app/build.gradle* file and change the following:
222
271
223
272
```diff
224
273
buildTypes {
@@ -239,13 +288,13 @@ allprojects {
239
288
240
289
> The code above use the `debug` signConfig for all buildTypes, which can be changed as you well if you need specify signConfig.
241
290
242
-
8. If you use `minifyEnabled true` in your *android/app/build.gradle* file, open the *android/unityLibrary/proguard-unity.txt* and change the following:
291
+
9. If you use `minifyEnabled true` in your *android/app/build.gradle* file, open the *android/unityLibrary/proguard-unity.txt* and change the following:
243
292
244
293
```diff
245
294
+ -keep class com.xraph.plugin.** {*;}
246
295
```
247
296
248
-
9. If you want Unity in it's own activity as an alternative, open the *android/app/src/main/AndroidManifest.xml* and change the following:
297
+
10. If you want Unity in it's own activity as an alternative, open the *android/app/src/main/AndroidManifest.xml* and change the following:
249
298
250
299
```diff
251
300
+ <activity
@@ -341,7 +390,7 @@ Switch to version `4.2.2` or `4.4` to avoid this.
341
390
There seems to be a bug where a Unity export does not include all lib files. If they are missing, use Unity to build a standalone .apk
342
391
of your AR project, unzip the resulting apk, and copy over the missing .lib files to the `unityLibrary` module.
343
392
344
-
8. Repeat steps 4 and 5 from the Android <b>Platform specific setup</b> (editing build.gradle and settings.gradle), replacing `unityLibrary` with `arcore_client`, `unityandroidpermissions` and `UnityARCore`.
393
+
8. Repeat steps 5 and 6 from the Android <b>Platform specific setup</b> (editing build.gradle and settings.gradle), replacing `unityLibrary` with `arcore_client`, `unityandroidpermissions` and `UnityARCore`.
345
394
346
395
9. When using `UnityWidget` in Flutter, set `fullscreen: false` to disable fullscreen.
0 commit comments