本文主要是介绍解决: is not accessible from java.lang.Class android.app.AppComponentFactory,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
堆栈如下:
Caused by: java.lang.IllegalAccessException: java.lang.Class<com.MainActivity> is not accessible from java.lang.Class<android.app.AppComponentFactory>at java.lang.Class.newInstance(Native Method)at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)at android.app.Instrumentation.newActivity(Instrumentation.java:1215)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2862)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3079) 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:1836) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6702)
原因:
你的activity 不是public 的 !
有问题的声明方式:
class MainActivity extends BaseActivity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main_layout);}
}
需要改成下面这样:
public class MainActivity extends BaseActivity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main_layout);}
}
这篇关于解决: is not accessible from java.lang.Class android.app.AppComponentFactory的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!