[Android Software/Hacking General [Developers Only]] osm0sis:
So far not so good.. :eek::(

I built a new apktool_2.2.2-dexed.jar, baksmali-2.2b4-dexed.jar, and smali-2.2b4-dexed.jar since we'll definitely need the latest versions for proper Nougat support.

Then there was an error from baksmali and smali that just indicated they had their "main" class missing; it was renamed to "Main", so that part was easy, but then I tried using the full bootclasses for sdk-23 as a start to see if it would work at all:

target=ContactsProvider.apk

ap=/tmp/apkpatcher;
bin=$ap/tools;
baksmali=$bin/baksmali-*-dexed.jar;
smali=$bin/smali-*-dexed.jar;
apktool=$bin/apktool_*-dexed.jar;

test -f /system/system/build.prop && root=/system;
sysfile=`find $root/system -mindepth 2 -name $target`;
cp -fp $sysfile $ap;
cd $ap;

bootclasses=/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar;

ANDROID_DATA=$ap ANDROID_ROOT=/system LD_LIBRARY_PATH=/system/lib dalvikvm -Xbootclasspath:$bootclasses -classpath $baksmali org.jf.baksmali.Main -o classout $target;

ANDROID_DATA=$ap ANDROID_ROOT=/system LD_LIBRARY_PATH=/system/lib dalvikvm -Xbootclasspath:$bootclasses -classpath $apktool brut.apktool.Main d --frame-path $ap/framework --no-src -o resout $target;

and bak/smali pretty much immediately gives the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/nio/file/Path;
at com.beust.jcommander.internal.DefaultConverterFactory.<clinit>(DefaultConverterFactory.java:66)
at com.beust.jcommander.JCommander.<clinit>(JCommander.java:167)
at org.jf.baksmali.Main.main(Main.java:78)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.nio.file.Path" on path: DexPathList[[zip file "/tmp/apkpatcher/tools/baksmali-2.2b4-dexed.jar"],nativeLibraryDirectories=[/system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 3 more
Suppressed: java.lang.ClassNotFoundException: java.nio.file.Path
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 4 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Which it turns out is very bad news indeed for this project, because like "Files", "Path" is also not an available class on Android.

Apktool seems to make it a little further but then gives the following error:

I: Using Apktool 2.2.2 on ContactsProvider.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /tmp/apkpatcher/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Copying raw classes.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector;
at org.yaml.snakeyaml.introspector.PropertyUtils.getPropertiesMap(PropertyUtils.java:63)
at org.yaml.snakeyaml.introspector.PropertyUtils.createPropertySet(PropertyUtils.java:110)
at org.yaml.snakeyaml.introspector.PropertyUtils.getProperties(PropertyUtils.java:102)
at org.yaml.snakeyaml.introspector.PropertyUtils.getProperties(PropertyUtils.java:94)
at org.yaml.snakeyaml.representer.Representer.getProperties(Representer.java:246)
at org.yaml.snakeyaml.representer.Representer$RepresentJavaBean.representData(Representer.java:50)
at org.yaml.snakeyaml.representer.BaseRepresenter.representData(BaseRepresenter.java:105)
at org.yaml.snakeyaml.representer.BaseRepresenter.represent(BaseRepresenter.java:64)
at org.yaml.snakeyaml.Yaml.dumpAll(Yaml.java:242)
at org.yaml.snakeyaml.Yaml.dump(Yaml.java:221)
at brut.androlib.meta.MetaInfo.save(MetaInfo.java:54)
at brut.androlib.meta.MetaInfo.save(MetaInfo.java:63)
at brut.androlib.Androlib.writeMetaFile(Androlib.java:245)
at brut.androlib.ApkDecoder.writeMetaFile(ApkDecoder.java:305)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:162)
at brut.apktool.Main.cmdDecode(Main.java:166)
at brut.apktool.Main.main(Main.java:81)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.beans.Introspector" on path: DexPathList[[zip file "/tmp/apkpatcher/tools/apktool_2.2.2-dexed.jar"],nativeLibraryDirectories=[/system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 17 more
Suppressed: java.lang.ClassNotFoundException: java.beans.Introspector
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

So it seems things have changed in the jars themselves where they worked before (I had only ever tested and had it confirmed working with Apktool 2.0.3 and bak/smali 2.1.1), so they no longer work on Android. Perhaps [MENTION=1299419]JesusFreke[/MENTION] and/or [MENTION=3924617]iBotPeaches[/MENTION] would be willing to help resolve these Android issues? Hopefully so since I still think this concept has a lot of merit for the modding community... technically it could all work with only Apktool and an aapt binary for each NDK architecture.

Here was my todo before I hit this roadblock:

- test currently required bootclass jars for minimal execution, make bootclasspath dependent on detected API version
- test newest apktool classes.dex unpack (would remove need for bak/smali)
- investigate ImageIO error with framework-res.apk (6.0.1 sdk 23) issue
- fix lib64 vs lib issue on 64-bit devices
- handle missing APKs gracefully
- add busybox environment for execution
- ?add APK re-signing
- ?reflash to uninstall
- ?add su.img and Magisk support (maybe as pull request from djb77?)

All I can think to do now is to work out with what version Apktool stopped working to hopefully help a fix get included.

Edit

: And turns out Apktool 2.0.3 was the last working version.. and 2.1.3 for bak/smali (last before the 2.2 betas).