Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] Upgraded to android studio 4, now reports that main activity ‘is not accessible from class android.app.Instrumentation’

Posted on November 14, 2022

Solution 1 :

I managed to get this to run (although I have new problems now) by changing onCreate from ‘public’ to ‘protected’.
What I think happened is that either the permissions in the parent class inside the android library changed or the rules governing access levels became more strict – public should have worked either way.

Problem :

This happens every time I upgrade, usually for different reasons:
I just upgraded to Android Studio 4, I’m targeting android 5/Api21 upwards.
This time my activity crashes on start up with claiming that my main activity ‘is not accessible from class android.app.Instrumentation’

I’m not sure what ‘android.app.Instrumentation’ is or whether there’s some requirement in my code, a dependency or android studio that’s requiring it. My main class is public so it should be able to see it.

My class declaration looks like this:

public class AnthracitePlayer extends AppCompatActivity

and AppCompatActivity, which I believe is something I used to remove the title bar is declared like this:

public class AppCompatActivity extends FragmentActivity implements AppCompatCallback,
        TaskStackBuilder.SupportParentable, ActionBarDrawerToggle.DelegateProvider {

and my create method starts like this:

Override
    public void onCreate(Bundle savedInstanceState)
    {
        Log.d(TAG,"Entered onCreate");
        super.onCreate(savedInstanceState);
        Display display = getWindowManager().getDefaultDisplay();

        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        String displayName = display.getName();

I’m not sure if any of those is upsetting this instrumentation thing.
The error follows:

07-12 14:32:26.251 20528-20528/totga.anthraciteplayerapi21 D/ResourcesManager: creating new AssetManager and set to /data/app/totga.anthraciteplayerapi21-2/base.apk
07-12 14:32:26.341 20528-20528/totga.anthraciteplayerapi21 D/AndroidRuntime: Shutting down VM
07-12 14:32:26.341 20528-20528/totga.anthraciteplayerapi21 E/AndroidRuntime: FATAL EXCEPTION: main
Process: totga.anthraciteplayerapi21, PID: 20528
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{totga.anthraciteplayerapi21/totga.anthraciteplayerapi21.AnthracitePlayer}: java.lang.IllegalAccessException: totga.anthraciteplayerapi21.AnthracitePlayer() is not accessible from class android.app.Instrumentation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2515)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalAccessException: totga.anthraciteplayerapi21.AnthracitePlayer() is not accessible from class android.app.Instrumentation
at java.lang.Class.newInstance(Class.java:1647)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723) 
at android.app.ActivityThread.access$900(ActivityThread.java:172) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5832) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 

Comments

Comment posted by Luther

I’ve tried deriving from basic ‘Activity’ too but no joy – something still wants… something. I honestly have no idea. The android platform is like quicksand sometimes.

READ  [ANSWERED] Where to declare views in android studio java code? Whether the declaration should be done outside or inside onCreate function
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress