On the Nexus One studio emulator with android 4.2.2 and api 17 everything works, and on the Asus K012 tablet with android 5.0 and api 21 here is such a heresy:

 05-09 08:35:32.204 12166-12166/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.studio.morpheus.morpheusholodos, PID: 12166 java.lang.VerifyError: Rejecting class com.studio.morpheus.morpheusholodos.MainMenu because it failed compile-time verification (declaration of 'com.studio.morpheus.morpheusholodos.MainMenu' appears in /data/app/com.studio.morpheus.morpheusholodos-2/base.apk) at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.Class.newInstance(Class.java:1572) at android.app.Instrumentation.newActivity(Instrumentation.java:1065) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2217) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376) at android.app.ActivityThread.access$800(ActivityThread.java:147) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5253) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 

I read on the Internet about this problem. People who had it, described it with incredibly abstruse words, which I could not even read, and solutions were offered to them even less intelligible. But my program is not one of which you can say something like that, everything in it is extremely simple. Why do I need it?

UPD Everything that is in the code, in a simplified version

 Button blahblahbut; public static String[]blahblah= new String[666]; public static Drawable[]blahblahblah= new Drawable[666]; public static Drawable[]blahblahblah2= new Drawable[666]; public static String[][] blaaahblah= new String[666][]; SharedPreferences prefs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_menu); setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); String[] otherblahblah={"some","items","..."}; blahblah[0]=this.getString(R.string.somestring); blaaahblah[0]=otherblahblah blahblahblah[0]=ResourcesCompat.getDrawable(getResources(), R.drawable.петросян_точка_жпг, null); System.arraycopy(blahblahblah, 0, blahblahblah2, 0, blahblahblah.length); StringTokenizer getsomemoreblahblah= new StringTokenizer(blahblah[0],"•"); blahblah[0]=getsomemoreblahblah.nextToken().replace("\n", ""); blahblahbut.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.blahblahbut: Intent blahintent= new Intent(this, blahblahactivity.class); AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom)); builder.setTitle("Бла бла бла!") .setMessage("Что ж тут может не работать?") .setCancelable(false) .setNegativeButton("Хз :(", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); prefs = PreferenceManager.getDefaultSharedPreferences(MainMenu.this); if (prefs.getString(blahblah[0], "").isEmpty) {blahintent.putExtra("blahblah",blahblah);startActivity(blahintent);}else{ Toast.makeText(this, "Не бла бла :(", Toast.LENGTH_SHORT).show();} break; 
  • 3
    It just so happens that here, basically, they also cannot, like you, read incredibly abstruse words like shta. Try to describe your problem in simple understandable language. - pavlofff
  • @pavlofff Well, I described: "On the Nexus One studio emulator with android 4.2.2 and api 17, everything works, and on the Asus K012 tablet with android 5.0 and api 21, that's such a heresy:" What else can I tell you about what is happening? ; O - i am so lame
  • one
    First, delete the contents of the ./build and ./app/build folders and try again. Which JDK are you using? Not 1.8 hour? If yes, try on 1.7. In general, you need more information. - VAndrJ
  • @VAndrJ, tried, did not help. What other information can I provide? - i am so lame
  • one
    Well ... They also propose cutting long methods into parts, breaking them into sub-methods. It is also advised to check whether standard Java or open-source is used. - Yuriy SPb

2 answers 2

Options for why drops can be many, as well as solutions. Here is what you can try:

  1. Cut long methods into parts, breaking into sub-methods, because Java can not digest the abundance of entities that should be stored in memory (local variables, for example)

  2. Manual removal of the contents of the ./build and ./app/build folders may help. For, perhaps, the studio itself could not clean them and new changes in the code conflict with the cached ones.

  3. It may also fall due to a synchronized inside a try-catch block. The solution is to synchronized outside of try-catch .

  4. Also check that you are not using open source and not on Java, because you may be trying to call a class / method of them, but in Android there are no such. Solution - use JDK 1.7 from Oracle

    They also propose to cut long methods into parts, breaking them into submethods - YuriySPb

    Here is a solution. Who will face a similar problem - know.