Empty_Android
Empty_Android
采纳率100%
2016-08-18 07:25

Android Studio could not find class

已采纳

图片说明
一个CheckBox 多选按钮实现程序,layout预览没有问题,启动APK不能运行。

build.gradle
图片说明

logcat:

08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.820 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.840 3020-3020/com.example.administrator.myapplication12 E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.administrator.myapplication12.MainActivity.access$super
08-18 05:15:38.900 3020-3020/com.example.administrator.myapplication12 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.administrator.myapplication12, PID: 3020
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.myapplication12/com.example.administrator.myapplication12.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.administrator.myapplication12.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • FFZ2009 FFZ2009 5年前

    你的Activity中是否有以下的方法
    onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState)
    onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState)

    PersistableBundle是API 21引入的,如果你的app运行在低于API21的设备中,有可能就会报错。
    可以改为对低版本也适用的方法:
    onSaveInstanceState(Bundle outState)
    onPostCreate(Bundle savedInstanceState)

    点赞 1 评论 复制链接分享
  • xiaoshiyiqie 笑释一切 5年前

    少导入或者引入什么类或者jar包了?

    点赞 评论 复制链接分享
  • Allisonton tesfen 5年前

    没有导入PersistableBundle,和MediaController这两个类

    点赞 评论 复制链接分享

为你推荐