[Sony Cross-Device General] IgorEisberg:
EDIT: The latest oat2dex solves this issue altogether.

WTF IS THE PROBLEM?

The OpenGL and Google Play Store refuse to work because baksmali inside the oat2dex tool misinterprets some fields in a single smali file and breaks "services.jar" when deodexing, and the main problem it causes is mistakenly setting your OpenGL version to 0 (instead of 3), basically disabling it.

oat2dex, for some reason, flips just a few specific fields (name and type) when deodexing, as if there is an ambiguity between 2 fields on the same offset.

When you flash the deodexed services.jar back to your phone and clear dalvik-cache, Android re-optimizes it (takes the "classes.dex" inside your new JAR file, does

dex2oat

on it, and saves it in /data/dalvik-cache/arm/). The deodexed file is broken, so that optimized file is broken too.

You take that broken odex file from dalvik-cache and deodex it again. Since it contains those flipped field names, this time it flips them again but to the correct fields.

The result DEX file you get by that second deodexing is a properly working DEX file, and if you rename it to "classes.dex" and replace "classes.dex" inside your broken "services.jar", you'll get a working "services.jar" and all your OpenGL and Google Play Store problems will disappear immediately.

HOW TO QUICKLY GET A WORKING DEX?

* Extract classes.dex from the JARs, rename them to framework.dex and services.dex.

* Copy them to your internal SD.

* Enable "USB debugging" in Developer options.

* Connect your device to your PC and open Command Prompt:

[B]adb shell[/B] (confirm ADB on your device)
[B]su[/B] (confirm SU on your device)
[B]dex2oat --dex-file=/sdcard/framework.dex --oat-file=/sdcard/framework.odex[/B]
[B]dex2oat --dex-file=/sdcard/services.dex --oat-file=/sdcard/services.odex[/B]

* Copy these odex files to your PC and deodex them again with oat2dex.

* Rename the new framework.dex and services.dex to classes.dex and add them to their JARs, replacing the broken classes.dex.

JARS AFFECTED BY THIS BUG

framework.jar/classes.dex --- only a single non-critical error in NumberPicker.smali (classes2.dex is fine)

http://xdaforums.com/attachment.php?attachmentid=3338076&d=1432918042

services,jar/classes.dex --- Total of 8 errors, described below...

http://xdaforums.com/attachment.php?attachmentid=3335118&d=1432772056

BUG REPRODUCTION

Requirements:

1) Java installed

2) oat2dex_bug.zip

ZIP contents:

* baksmali.jar

* oat2dex.jar

* boot.oat --- taken from /framework/arm/

* services.dex --- this is "classes.dex" from the deodexed "services.jar" (which breaks OpenGL)

* services-from-dcache.odex --- this is the odex file taken from "/data/dalvik-cache/arm/" that was created by Android after flashing the broken deodexed "services.jar" and clearing dalvik-cache

Reproduction steps:

1) Open "oat2dex_bug" folder, right-click inside it and then select "Open command window here".

2) Write the following lines exactly as follows:

java -jar oat2dex.jar boot boot.oat

java -jar oat2dex.jar services-from-dcache.odex odex

java -jar baksmali.jar -o services-from-dcache services-deodex.dex

java -jar baksmali.jar -o services services.dex

3) With WinMerge, compare folders "services" and "services-from-dcache".

You'll see that only one file has differences, and it's "ActivityManagerService.smali", that's the file you need to fix.

In the above images are the only affected areas you need to fix.