Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

AndroidJavaException: java.lang.NoClassDefFoundError #45

Open
DmitryMaksimenko opened this issue Jan 18, 2022 · 8 comments
Open

AndroidJavaException: java.lang.NoClassDefFoundError #45

DmitryMaksimenko opened this issue Jan 18, 2022 · 8 comments

Comments

@DmitryMaksimenko
Copy link

  1. Create empty unity android project
  2. Import AppMetrica
  3. Import External Dependency Manager
  4. Enable "Custom Main Gradle Template" in Player Settings/Publishing Settings
  5. Resolve dependencies on Assets/External Dependency Manager/Android Resolver/Forse Resolve
  6. Run Build
  • Unity version 2020.3.26f1
  • AppMetrica version 4.1.0
  • External Dependency Manager version 1.2.168
2022-01-18 20:44:36.180 12970-12993/? E/Unity: AndroidJavaException: java.lang.NoClassDefFoundError: com.yandex.metrica.impl.ob.uf
    java.lang.NoClassDefFoundError: com.yandex.metrica.impl.ob.uf
        at com.yandex.metrica.impl.ob.uf.a(SourceFile:1)
        at com.yandex.metrica.YandexMetrica.resumeSession(SourceFile:1)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
        at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:255)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
        at com.yandex.metrica.impl.ob.d0.<init>(SourceFile:9)
        at com.yandex.metrica.impl.ob.d0.<init>(Unknown Source:2)
        at com.yandex.metrica.impl.ob.X.<init>(SourceFile:17)
        at com.yandex.metrica.impl.ob.X.<init>(SourceFile:7)
        at com.yandex.metrica.impl.ob.X.g(SourceFile:5)
      at com.yandex.metrica.impl.ob.u
@ghost
Copy link

ghost commented Jan 18, 2022 via email

@kbobnis
Copy link

kbobnis commented Jan 19, 2022

@DmitryMaksimenko this is because metrica plugin doesn't use dependency.xml file that helps the External Dependency Manager resolve native libraries. This results in plain removal of those needed libraries during resolve.

@DmitryMaksimenko
Copy link
Author

@kbobnis AppMetrica devs should add xml with dependencies to the plugin to avoid such problems

@kbobnis
Copy link

kbobnis commented Jan 20, 2022

I have created the dependency.xml File and local maven repo by myself. (I have not tested it on device yet, but I saw that the mobmetricalib.aar library was properly regenerated by external dependency manager).

How I did it:

  • Created directories <package_root>/m2repository/mobmetrica/mobmetricalib/4.1.1/
  • Created file <package_root>/m2repository/mobmetrica/mobmetricalib/maven-metadata.xml with contents

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>mobmetrica</groupId>
<artifactId>mobmetricalib</artifactId>
<versioning>
<release>4.1.1</release>
<versions>
<version>4.1.1</version>
</versions>
</versioning>
</metadata>
 

  • Renamed mobmetricalib-4.1.1.aar to  mobmetricalib-4.1.1.srcaar and moved it to directory  <package_root>/m2repository/mobmetrica/mobmetricalib/4.1.1/
     

  • Created file <package_root>/m2repository/mobmetrica/mobmetricalib/4.1.1/mobmetricalib-4.1.1.pom with contents:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>mobmetrica</groupId>
    <artifactId>mobmetricalib</artifactId>
    <version>4.1.1</version>
    <packaging>srcaar</packaging>
    </project>

  • Created file <package_root>/Editor/AppMetricaDependencies.xml with contents:
    <?xml version="1.0" encoding="UTF-8"?>
    <dependencies>

    <androidPackages>
    <androidPackage spec="mobmetrica:mobmetricalib:4.1.1">
    <repositories>
    <repository>Assets/AppMetrica/m2repository</repository>
    </repositories>
    </androidPackage>
    </androidPackages>
    </dependencies>

@mopsicus
Copy link

mopsicus commented Feb 9, 2022

Have the same issue. As a temporary solution, add this to your dependency.xml
...
<androidPackage spec="com.android.installreferrer:installreferrer:2.2">
<androidSdkPackageIds>
<androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
</androidSdkPackageIds>
<repositories>
<repository>https://maven.google.com</repository>
</repositories>
</androidPackage>
<androidPackage spec="com.google.android.gms:play-services-appset:16.0.2">
<androidSdkPackageIds>
<androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
</androidSdkPackageIds>
<repositories>
<repository>https://maven.google.com</repository>
</repositories>
</androidPackage>
<androidPackage spec="org.jetbrains:annotations:13.0" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32" />
...

@Ka33yC
Copy link

Ka33yC commented Feb 9, 2022

Same
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; com.yandex.metrica.impl.ob.d0.<init>(SourceFile:9) com.yandex.metrica.impl.ob.d0.<init>(Unknown Source:2) com.yandex.metrica.impl.ob.X.<init>(SourceFile:17) com.yandex.metrica.impl.ob.X.<init>(SourceFile:7) com.yandex.metrica.impl.ob.X.g(SourceFile:5) com.yandex.metrica.impl.ob.uf.<clinit>(SourceFile:2) com.yandex.metrica.YandexMetrica.activate(SourceFile:1) com.unity3d.player.UnityPlayer.nativeRender(Native Method) com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) android.os.Handler.dispatchMessage(Handler.java:102) android.os.Looper.loop(Looper.java:246) com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics ... 13 more UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0) UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0) YandexAppMetricaAndroid.ActivateWithConfiguration (YandexAppMetricaConfig config) (at <00000000000000000000000000000000>:0) AppMetrica.SetupMetrica () (at <00000000000000000000000000000000>:0)
and
java.lang.NoClassDefFoundError: com.yandex.metrica.impl.ob.uf com.yandex.metrica.impl.ob.uf.a(SourceFile:1) com.yandex.metrica.YandexMetrica.pauseSession(SourceFile:1) com.unity3d.player.UnityPlayer.nativePause(Native Method) com.unity3d.player.UnityPlayer.access$1900(Unknown Source:0) com.unity3d.player.UnityPlayer$24.run(Unknown Source:2) android.os.Handler.handleCallback(Handler.java:914) android.os.Handler.dispatchMessage(Handler.java:100) android.os.Looper.loop(Looper.java:225) com.unity3d.player.UnityPlayer$e.run(Unknown Source:20) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics; com.yandex.metrica.impl.ob.d0.<init>(SourceFile:9) com.yandex.metrica.impl.ob.d0.<init>(Unknown Source:2) com.yandex.metrica.impl.ob.X.<init>(SourceFile:17) com.yandex.metrica.impl.ob.X.<init>(SourceFile:7) com.yandex.metrica.impl.ob.X.g(SourceFile:5) com.yandex.metrica.impl.ob.uf.<clinit>(SourceFile:2) com.yandex.metrica.impl.ob.uf.a(SourceFile:1) com.yandex.metrica.YandexMetrica.activate(SourceFile:1) com.unity3d.player.UnityPlayer.nativeRender(Native Method) com.unity3d.player.UnityPlayer.access$300(Unknown Source:0) com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95) android.os.Handler.dispatchMessage(Handler.java:103) ... 2 more Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics ... 14 more UnityEngine.AndroidJNISafe.CheckException () (at <00000000000000000000000000000000>:0) UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) (at <00000000000000000000000000000000>:0) YandexAppMetricaAndroid.PauseSession () (at <00000000000000000000000000000000>:0)

@ghost
Copy link

ghost commented Feb 10, 2022

Попробуйте, пожалуйста, добавить следующие зависимости в файл: Assets/Plugin/Editor/Dependencies.xml:

<androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
<androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />

Если файла нет, то необходимо его создать. Полный файл будет выглядеть следующим образом:

<dependencies>
    <androidPackages>
        <androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
        <androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
        <androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />
    </androidPackages>
</dependencies>


Please try adding the following dependencies to the file: Assets/Plugin/Editor/Dependencies.xml:

<androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
<androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />

If there is no file, you need to create it. The full file will be like this:

<dependencies>
    <androidPackages>
        <androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
        <androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
        <androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />
    </androidPackages>
</dependencies>

@trumdu
Copy link

trumdu commented Apr 7, 2022

Попробуйте, пожалуйста, добавить следующие зависимости в файл: Assets/Plugin/Editor/Dependencies.xml:

<androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
<androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />

Если файла нет, то необходимо его создать. Полный файл будет выглядеть следующим образом:

<dependencies>
    <androidPackages>
        <androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
        <androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
        <androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />
    </androidPackages>
</dependencies>

Попробуйте добавить в файл следующие зависимости: Assets/Plugin/Editor/Dependencies.xml:

<androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
<androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />

Если файла нет, нужно его создать. Полный файл будет выглядеть так:

<dependencies>
    <androidPackages>
        <androidPackage spec="com.google.android.gms:play-services-appset:16.0.0" />
        <androidPackage spec="com.android.installreferrer:installreferrer:2.2" />
        <androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib:1.4.32" />
    </androidPackages>
</dependencies>

Помогло для ошибки com.yandex.metrica.impl.ob.uf при сборке для huawei hms.

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

No branches or pull requests

5 participants