AppsFlyerSDK / appsflyer-android-app

Other
33 stars 110 forks source link

java.lang.NoClassDefFoundError: com/appsflyer/r (wrong name: com/appsflyer/R) when running AndroidJUnit #5

Closed shoheikawano closed 5 years ago

shoheikawano commented 5 years ago

Hi, thank you for providing a useful SDK.

I have integrated AppsFlyer SDK in our Android app, but it turns out that after adding this SDK we encounter build failure when running AndroidJunit with Robolectric test locally, with exception NoClassDefFoundError thrown.

Here is the log:

java.lang.NoClassDefFoundError: com/appsflyer/r (wrong name: com/appsflyer/R)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
    at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:134)
    at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:111)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
    at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:110)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.appsflyer.AppsFlyerLib.<init>(:176)
    at com.appsflyer.AppsFlyerLib.<clinit>(:162)
    at 

...

org.robolectric.android.internal.ParallelUniverse.lambda$setUpApplicationState$0(ParallelUniverse.java:260)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:72)
    at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:260)
    at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:377)
    at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:252)
    at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
    at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

It would be helpful if you guys can give us feedback of this error if this is something new to you guys or this is something familiar and will be fixed soon.

Thanks!

l2dev commented 5 years ago

@shaunkawano did you manage to solve this?

jbrunton commented 5 years ago

Our team is seeing the same. Haven't found a solution. Any chance we could get an update?

l2dev commented 5 years ago

Updating the lib dependency has solved the issue for me.

This is what I have:

implementation 'com.appsflyer:af-android-sdk:4.8.19'
jbrunton commented 5 years ago

Ah, apparently we missed that update. That does seem to work. Thanks, @eurbon!

shoheikawano commented 5 years ago

@eurbon Sorry for the late response. Updating the library has also solved the issue for us! Thanks!

xuuhaoo commented 4 years ago

Updating the lib dependency has solved the issue for me.

This is what I have:

implementation 'com.appsflyer:af-android-sdk:4.8.19'

I try to upgrade SDK version to 4.9.0 , the issue still has.

bhagwandassoni1953 commented 3 years ago

Case1: root@localhost:/LIST/Test1/DEMO40# java TaxCode

Error: Could not find or load main class TaxCode Caused by: java.lang.NoClassDefFoundError: com/blogspot/radialmind/tax/TaxCode (wrong name: TaxCode) Case2: root@localhost:/LIST/Test1/DEMO40# java com.blogspot.radialmind.tax.TaxCode

Error: Could not find or load main class com.blogspot.radialmind.tax.TaxCode Caused by: java.lang.ClassNotFoundException: com.blogspot.radialmind.tax.TaxCode