无法解决以下问题:Lcom / google / android / gms / common / internal / Preconditions;在Unity中

时间:2018-11-12 15:08:00

标签: java c# android unity3d location

我正在开发一个android sdk,可在其中获取用户位置。对于Android应用程序,它运行良好,现在我要使其与Unity兼容。

使用FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient(context);时出现此错误

E/Unity: AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions;
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/Preconditions;
    at com.google.android.gms.common.api.Api.<init>(Unknown Source:2)
    at com.google.android.gms.location.LocationServices.<clinit>(Unknown Source:22)
    at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source:0)
    at in.___.___..LocationManager.startLocationUpdates(LocationManager.java:43)
    at in.___.___..LocationManager.startLocation(LocationManager.java:33)
    at in.___.___.Main.initialize(Main.java:126)
    at in.___.___.Main.registerAPP(Main.java:83)
    at in.___.___.init(__.java:76)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source:151)
    at android.os

我添加了play-services-location,play-services-base等,但无法解决此错误。

1 个答案:

答案 0 :(得分:0)

最后,在这个问题上花了2天后,我解决了。实际上非常简单。当您将aar库添加到统一库时,您必须检查其依赖关系,它将在页面或pom文件中列出。因此,当我检查play-service-location时,我发现它与play-service-basement和play-service-tasks有依赖关系。因此,当我添加这些aar软件包时,一切正常。

您可以在here

中看到该列表