question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please help: NoFactoryFoundException

See original GitHub issue

Hi! I have a question. Why is this crashing? I have two files: MainActivity.kt and SomeInterface.kt:

ToothpickTest

Test project to highlight a NoFactoryFoundException https://github.com/jenmo917/ToothpickTest

MainActivity:

package my.toothpick.application

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import toothpick.Toothpick
import toothpick.config.Module
import javax.inject.Inject

class MainActivity : AppCompatActivity(), SomeInterface {

    @Inject
    lateinit var someInterface: SomeInterface

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        Toothpick.openRootScope()
                .installModules(object : Module() {
                    init {
                        bind(SomeInterface::class.java) to this@MainActivity
                    }
                })
                .inject(this)
    }

    override fun doSomething() {

    }
}

SomeInterface:

package my.toothpick.application

interface SomeInterface {
    fun doSomething()
}

Exception:

2019-11-01 09:43:50.424 11720-11720/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: is.defaul.myapplication, PID: 11720
    java.lang.RuntimeException: Unable to start activity ComponentInfo{is.defaul.myapplication/my.toothpick.application.MainActivity}: toothpick.locators.NoFactoryFoundException: No factory could be found for class my.toothpick.application.SomeInterface. Check that the class has either a @Inject annotated constructor or contains @Inject annotated members.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: toothpick.locators.NoFactoryFoundException: No factory could be found for class my.toothpick.application.SomeInterface. Check that the class has either a @Inject annotated constructor or contains @Inject annotated members.
        at toothpick.locators.FactoryLocator.getFactory(FactoryLocator.java:37)
        at toothpick.InternalProvider.get(InternalProvider.java:125)
        at toothpick.InternalScopedProvider.get(InternalScopedProvider.java:80)
        at toothpick.ScopeImpl.getInstance(ScopeImpl.java:93)
        at toothpick.ScopeImpl.getInstance(ScopeImpl.java:84)
        at my.toothpick.application.MainActivity__MemberInjector.inject(MainActivity__MemberInjector.java:10)
        at my.toothpick.application.MainActivity__MemberInjector.inject(MainActivity__MemberInjector.java:7)
        at toothpick.InjectorImpl.inject(InjectorImpl.java:37)
        at toothpick.Toothpick.inject(Toothpick.java:243)
        at toothpick.ScopeImpl.inject(ScopeImpl.java:140)
        at my.toothpick.application.MainActivity.onCreate(MainActivity.kt:24)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
     Caused by: java.lang.ClassNotFoundException: my.toothpick.application.SomeInterface__Factory
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at java.lang.Class.forName(Class.java:378)
        at toothpick.locators.FactoryLocator.getFactory(FactoryLocator.java:34)
        at toothpick.InternalProvider.get(InternalProvider.java:125) 
        at toothpick.InternalScopedProvider.get(InternalScopedProvider.java:80) 
        at toothpick.ScopeImpl.getInstance(ScopeImpl.java:93) 
        at toothpick.ScopeImpl.getInstance(ScopeImpl.java:84) 
        at my.toothpick.application.MainActivity__MemberInjector.inject(MainActivity__MemberInjector.java:10) 
        at my.toothpick.application.MainActivity__MemberInjector.inject(MainActivity__MemberInjector.java:7) 
        at toothpick.InjectorImpl.inject(InjectorImpl.java:37) 
        at toothpick.Toothpick.inject(Toothpick.java:243) 
        at toothpick.ScopeImpl.inject(ScopeImpl.java:140) 
        at my.toothpick.application.MainActivity.onCreate(MainActivity.kt:24) 
        at android.app.Activity.performCreate(Activity.java:7136) 
        at android.app.Activity.performCreate(Activity.java:7127) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
     Caused by: java.lang.ClassNotFoundException: Didn't find class "my.toothpick.application.SomeInterface__Factory" on path: DexPathList[[zip file "/data/app/is.defaul.myapplication-f3VGzw5Mx_vlhd_3_oJXmQ==/base.apk"],nativeLibraryDirectories=[/data/app/is.defaul.myapplication-f3VGzw5Mx_vlhd_3_oJXmQ==/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        ```


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
afaucogneycommented, Nov 1, 2019

Please give us the code.

Le ven. 1 nov. 2019 à 15:26, Jens Moser notifications@github.com a écrit :

Hi! Ok, I updated the example project a little. There are now three files MainActivity, MainFragment and SomeInterface.

I try to inject SomeInterface (which is implemented by MainActivity) into the MainFragment but it doesn’t work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/stephanenicolas/toothpick/issues/383?email_source=notifications&email_token=ABSAEWOJ5NVVQDOWBOVXN5TQRQ4BJA5CNFSM4JHX3LX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC3CHHI#issuecomment-548807581, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSAEWMCFXPVIO5NLEX2N7DQRQ4BJANCNFSM4JHX3LXQ .

0reactions
dlemurescommented, Nov 1, 2019

Awesome!! thx for the nice words 🥳

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toothpick NoFactoryFoundException - android - Stack Overflow
The app I'm working on is crashing in production and users are reporting the below stack trace. The problem is that I cannot...
Read more >
TokenMgrError (NetCDF-Java All API v5.5.3)
Returns a detailed message for the Error when it is thrown by the token manager to indicate a lexical error. Methods inherited from...
Read more >
NetcdfDataset.java example - Javatips.net
we have a simple url: e.g. http://... ; contact the server if (leadprotocol.equals("file")) { svctype ... msg = msg + " Please download...
Read more >
toothpick - bytemeta
Please help : NoFactoryFoundException · Previous Next. Make software development more efficient, Also welcome to join our telegram.
Read more >
A scope tree based Dependency Injection (DI) library for Java ...
Am I missing something during the build phase which I need to change? ... NoFactoryFoundException: No factory could be found for class ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found