Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Not working with Android Support v26.x.x libs #125

Open
djbozkosz opened this issue Dec 7, 2017 · 9 comments
Open

[Android] Not working with Android Support v26.x.x libs #125

djbozkosz opened this issue Dec 7, 2017 · 9 comments

Comments

@djbozkosz
Copy link

Dear developers,

I'm trying latest version (7.10.1) of SDK in Unity 5.6.2p3. Everything works fine with Android Support v25.x.x libs. But we need to target Android API 26 and use support libs of this version (due notification API changes). Unfortunately SDK doesn't work with this version and throws exceptions while plugin inits:

Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.app.SupportActivity>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/arch/lifecycle/LifecycleOwner;
at void com.facebook.internal.Validate.hasFacebookActivity(android.content.Context, boolean) (Validate.java:216)
at void com.facebook.FacebookSdk.sdkInitialize(android.content.Context, com.facebook.FacebookSdk$InitializeCallback) (FacebookSdk.java:265)
at void com.facebook.unity.FB.Init(java.lang.String) (FB.java:86)
at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
at boolean com.unity3d.player.UnityPlayer.c(com.unity3d.player.UnityPlayer) ((null):-1)
at boolean com.unity3d.player.UnityPlayer$c$1.handleMessage(android.os.Message) ((null):-1)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:98)
at void android.os.Looper.loop() (Looper.java:154)
at void com.unity3d.player.UnityPlayer$c.run() ((null):-1)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleOwner" on path: DexPathList[[zip file "/data/app/com.test.example-1/base.apk"],nativeLibraryDirectories=[/data/app/com.test.example-1/lib/arm, /data/app/com.test.example-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at void com.facebook.internal.Validate.hasFacebookActivity(android.content.Context, boolean) (Validate.java:216)
at void com.facebook.FacebookSdk.sdkInitialize(android.content.Context, com.facebook.FacebookSdk$InitializeCallback) (FacebookSdk.java:265)
at void com.facebook.unity.FB.Init(java.lang.String) (FB.java:86)
at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
at boolean com.unity3d.player.UnityPlayer.c(com.unity3d.player.UnityPlayer) ((null):-1)
at boolean com.unity3d.player.UnityPlayer$c$1.handleMessage(android.os.Message) ((null):-1)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:98)
at void android.os.Looper.loop() (Looper.java:154)
at void com.unity3d.player.UnityPlayer$c.run() ((null):-1)

Attaching list of used libs:

animated-vector-drawable-26.1.0.aar
appcompat-v7-26.1.0.aar
cardview-v7-26.1.0.aar
customtabs-26.1.0.aar
support-annotations-26.1.0.jar
support-compat-26.1.0.aar
support-core-ui-26.1.0.aar
support-core-utils-26.1.0.aar
support-fragment-26.1.0.aar
support-media-compat-26.1.0.aar
support-v4-26.1.0.aar
support-vector-drawable-26.1.0.aar

I checked Android Manifest after merge, all FB activities are included and checked DEX file and FB classes are included too.

I also tried to replace (just for test) FB Android SDK (v4.23.0) with v4.29.0 and I'm able to init plugin but login is not possible - or another dialog based action -> ends with similar set of exceptions.

Best regards
Tomáš Růžička.

@djbozkosz
Copy link
Author

Ok, for now we resolved issue by adding Lifecycle libs:

from android.arch.core:

common-1.0.0.jar
runtime-1.0.0.aar

from android.arch.lifecycle:

common-1.0.3.jar
compiler-1.0.0.jar
extensions-1.0.0.aar
reactivestreams-1.0.0.aar
runtime-1.0.3.aar

Note: for non Gradle builds in Unity you need to move all stuff with ${applicationId} from aar's manifests into your manifest with correct package name. And (probably too) remove target sdk version from FB manifests.

@haswalt
Copy link

haswalt commented Jan 2, 2018

I also have this issue, trying to make push notifications work.

an official fix / word on this would be ideal

@hashtagsheep
Copy link

Same here, would be nice to get this fixed

1 similar comment
@q3francy
Copy link

q3francy commented Feb 2, 2018

Same here, would be nice to get this fixed

@matias-leez
Copy link

I have the same problem.

@JimmyDeemo
Copy link

I think that #109 has your answer. The support libs added a dependency, which in regular Android projects can be downloaded using a remote repository. I don't think this step is added by default when building in Unity.

@jnbt
Copy link

jnbt commented Jul 11, 2018

I think the resolution should automatically download these dependencies, but there was a bug in the unity-jar-resolver which leads to overwritten libraries: googlesamples/unity-jar-resolver#97

This is exactly the case with android.arch.core.* and android.arch.lifecycle.*.

This is already fixed in recent releases BUT it seems to me that you need to delete the Temp folder, all already resolved dependencies from Plugins/Android and ProjectSettings/AndroidResolverDependencies.xml

@JimmyDeemo
Copy link

Thanks for the update @jnbt, so you are saying the the Jar Resolver plugin should be able to recognise the dependency, which comes from within an existing .aar file, and down load that in addition to the .aar dependencies?

To confirm, we should clear down all resolved dependencies and settings, update Jar Resolver and resolve?

@jnbt
Copy link

jnbt commented Jul 12, 2018

@JimmyDeemo I've tried again and it worked.

Maybe someone else can try the following steps:

  1. Close Unity (to prevent any auto-resolution by the Jar Resolver)
  2. Remove all dependencies managed by the Android Jar Resolver (every non-custom *.jar and *.aar file in Assets/Plugins/Android.
  3. Remove the Temp-folder completely
  4. Remove ProjectSettings/AndroidResolverDependencies.xml
  5. Open the project in Unity and wait for the Jar Resolver to do it's work (or in case you have disabled auto-resolution, Assets -> Android Resolver -> Resolve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants