Skip to content

Commit

Permalink
Embedded proguard.txt file to AAR library which should get rid of Cla…
Browse files Browse the repository at this point in the history
…ssNotFoundExceptions automatically
  • Loading branch information
yasirkula committed Apr 12, 2021
1 parent c3137fa commit d42e281
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/AAR Source (Android)/proguard.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class com.yasirkula.unity.* { *; }
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ You can't. On iOS, these files are stored in an internal directory that we have

- **Can't access the Gallery, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGallery" in Logcat**

If your project uses ProGuard, try adding the following line to ProGuard filters: `-keep class com.yasirkula.unity.* { *; }`
If you are sure that your plugin is up-to-date, then enable **Custom Proguard File** option from *Player Settings* and add the following line to that file: `-keep class com.yasirkula.unity.* { *; }`

- **Android build fails, it says "error: attribute android:requestLegacyExternalStorage not found" in Console**

Expand Down
2 changes: 1 addition & 1 deletion Plugins/NativeGallery/Android/NGCallbackHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !UNITY_EDITOR && UNITY_ANDROID
#if UNITY_EDITOR || UNITY_ANDROID
using UnityEngine;

namespace NativeGalleryNamespace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !UNITY_EDITOR && UNITY_ANDROID
#if UNITY_EDITOR || UNITY_ANDROID
using UnityEngine;

namespace NativeGalleryNamespace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !UNITY_EDITOR && UNITY_ANDROID
#if UNITY_EDITOR || UNITY_ANDROID
using System.Threading;
using UnityEngine;

Expand Down
Binary file modified Plugins/NativeGallery/Android/NativeGallery.aar
Binary file not shown.
15 changes: 2 additions & 13 deletions Plugins/NativeGallery/Editor/NGPostProcessBuild.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
#if UNITY_IOS
using System.IO;
using UnityEditor;
using UnityEngine;
#if UNITY_IOS
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
#endif
Expand All @@ -19,17 +19,6 @@ public class NGPostProcessBuild
private const bool MINIMUM_TARGET_8_OR_ABOVE = false;
#endif

[InitializeOnLoadMethod]
public static void ValidatePlugin()
{
string jarPath = "Assets/Plugins/NativeGallery/Android/NativeGallery.jar";
if( File.Exists( jarPath ) )
{
Debug.Log( "Deleting obsolete " + jarPath );
AssetDatabase.DeleteAsset( jarPath );
}
}

#if UNITY_IOS
#pragma warning disable 0162
[PostProcessBuild]
Expand Down
2 changes: 1 addition & 1 deletion Plugins/NativeGallery/NativeGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using UnityEngine;
using Object = UnityEngine.Object;
#if !UNITY_EDITOR && ( UNITY_ANDROID || UNITY_IOS )
#if UNITY_ANDROID || UNITY_IOS
using NativeGalleryNamespace;
#endif

Expand Down
4 changes: 3 additions & 1 deletion Plugins/NativeGallery/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ b. Manual Setup for iOS
- insert "-weak_framework PhotosUI -weak_framework Photos -framework AssetsLibrary -framework MobileCoreServices -framework ImageIO" to the "Other Linker Flags" of Unity-iPhone Target (if your Deployment Target is at least 8.0, it is sufficient to insert "-weak_framework PhotosUI -framework Photos -framework MobileCoreServices -framework ImageIO")
- lastly, remove Photos.framework and PhotosUI.framework from Link Binary With Libraries of Unity-iPhone Target in Build Phases, if exists

IMPORTANT: If you are targeting iOS 14 or later, you need to build your app with Xcode 12 or later to avoid any permission issues.


3. FAQ
- How can I fetch the path of the saved image or the original path of the picked image on iOS?
Expand All @@ -34,7 +36,7 @@ You can't. On iOS, these files are stored in an internal directory that we have
"android:requestLegacyExternalStorage" attribute in AndroidManifest.xml fixes a rare UnauthorizedAccessException on Android 10 but requires you to update your Android SDK to at least SDK 29. If this isn't possible for you, you should open NativeGallery.aar with WinRAR or 7-Zip and then remove the "<application ... />" tag from AndroidManifest.xml.

- Can't access the Gallery, it says "java.lang.ClassNotFoundException: com.yasirkula.unity.NativeGallery" in Logcat
If your project uses ProGuard, try adding the following line to ProGuard filters: -keep class com.yasirkula.unity.* { *; }
If you are sure that your plugin is up-to-date, then enable "Custom Proguard File" option from Player Settings and add the following line to that file: -keep class com.yasirkula.unity.* { *; }

- Nothing happens when I try to access the Gallery on Android
Make sure that you've set the "Write Permission" to "External (SDCard)" in Player Settings.
Expand Down
2 changes: 1 addition & 1 deletion Plugins/NativeGallery/iOS/NGMediaReceiveCallbackiOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !UNITY_EDITOR && UNITY_IOS
#if UNITY_EDITOR || UNITY_IOS
using UnityEngine;

namespace NativeGalleryNamespace
Expand Down
2 changes: 1 addition & 1 deletion Plugins/NativeGallery/iOS/NGMediaSaveCallbackiOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !UNITY_EDITOR && UNITY_IOS
#if UNITY_EDITOR || UNITY_IOS
using UnityEngine;

namespace NativeGalleryNamespace
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.yasirkula.nativegallery",
"displayName": "Native Gallery",
"version": "1.6.2",
"version": "1.6.3",
"documentationUrl": "https://github.com/yasirkula/UnityNativeGallery",
"changelogUrl": "https://github.com/yasirkula/UnityNativeGallery/releases",
"licensesUrl": "https://github.com/yasirkula/UnityNativeGallery/blob/master/LICENSE.txt",
Expand Down

0 comments on commit d42e281

Please sign in to comment.