0

so I have method that looks like this :

 public void testSingleGames() throws InterruptedException {

               try {

                    Log.d("TEST","JSON");

                } catch (JSONException e) {
                    e.printStackTrace();
                    fail("JSONException!!");
                }

I simply want to call that method elsewhere : testSingleGames();

though it says : Unhandled Exception.java.lang.InterruptedException.

I tried the suggested fix android studio gave me , which is :

    try {
        testSingleGames();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

my app crashes when I do though. So how do I call this mehod properly ?

EDIT :

here some STACKTRACES :

I think this one is the "main cause" since text was marked red:

    Process: com.test.test, PID: 4097
     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.test/com.test.test.MainActivity}: java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
         at android.app.ActivityThread.-wrap11(Unknown Source:0)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
         at android.os.Handler.dispatchMessage(Handler.java:105)
         at android.os.Looper.loop(Looper.java:164)
         at android.app.ActivityThread.main(ActivityThread.java:6541)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
      Caused by: java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
         at android.support.test.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)
         at android.support.test.InstrumentationRegistry.getContext(InstrumentationRegistry.java:75)
         at com.test.test.MainActivity.setUp(MainActivity.java:61)
         at com.test.test.MainActivity.testSingleGames(MainActivity.java:69)
         at com.test.test.MainActivity.onCreate(MainActivity.java:122)
         at android.app.Activity.performCreate(Activity.java:6975)
         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
         at android.app.ActivityThread.-wrap11(Unknown Source:0) 
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
         at android.os.Handler.dispatchMessage(Handler.java:105) 
         at android.os.Looper.loop(Looper.java:164) 
         at android.app.ActivityThread.main(ActivityThread.java:6541) 
         at java.lang.reflect.Method.invoke(Native Method) 
         at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)  

Edit 2 : Ok I googled this line : No instrumentation registered! Must run under a registering instrumentation.

Previously I had a problem dependencies:

Conflict with dependency 'com.android.support.test:runner' in project ':app'. Resolved versions for app (0.5) and test app (1.0.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

I "fixed" it by changeing :

androidTestImplementation 'com.android.support.test:runner:1.0.1'

to Implementation 'com.android.support.test:runner:1.0.1'

so the error went away .

Maybe this is the root cause ?

I hope someone can make sense of this o.O , since I just tried to dabble abit with some api which is throwing all kinds of problems at me -.- ...

Leo Aso
  • 11,898
  • 3
  • 25
  • 46
Medy
  • 55
  • 1
  • 6
  • 1
    Please post exception stacktrace – Tuby Dec 17 '17 at 20:52
  • Sry im fairly new to programming . what do I need to do ? – Medy Dec 17 '17 at 21:01
  • See if [this](https://stackoverflow.com/a/33123156/6413377) helps with stack trace. – pirho Dec 17 '17 at 21:09
  • I added a Stacktrace ... to clarify : the method I call is from a external libarly (api wrapper), so I have really no clue whats exactly going wrong there... https://github.com/igdb/api-android-java or can someone at least tell me if my method call(stated in my post) was correct or not. – Medy Dec 17 '17 at 22:15
  • oh that's simple! first handle the exception using generic Exception handler like try{ }catch(Exception e){ e.printStackTrace(); } it will stop the crash and give you also the full stack trace and can you elaborate a little actually what is this code for? just a little context – Rizwan Atta Dec 27 '17 at 11:41

0 Answers0