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

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

Closed
shoheikawano opened this issue Nov 28, 2018 · 7 comments

Comments

@shoheikawano
Copy link

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
Copy link

l2dev commented Jan 17, 2019

@shaunkawano did you manage to solve this?

@jbrunton
Copy link

jbrunton commented Jan 31, 2019

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

@l2dev
Copy link

l2dev commented Jan 31, 2019

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
Copy link

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

@shoheikawano
Copy link
Author

shoheikawano commented Feb 1, 2019

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

@xuuhaoo
Copy link

xuuhaoo commented Jun 2, 2020

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
Copy link

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

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

5 participants