[Android Q&A, Help & Troubleshooting] ShaDisNX255:
Background:

I created a script that pretty much factory resets the phone and starts deleting apps from system/app and system/priv-app.

My problem pretty much is that when I try to add those apps back

When I add them via another flashable zip and I reboot, the apps don't start up and start crashing upon trying to open them up

I extracted the whole folder located in system/priv-app from the system.img of a previous firmware version

When I extract the folder of my current firmware version, it works. Which makes me believe that these apps are firmware specific?

The only problem is that I am trying to share these zips with other people and since they have different firmware versions (usually due to some carriers taking longer to release firmware or stuff like that)

Problem:

Anyway, here's the deal (I will use Samsung's Gallery app as an example). I have this script to add the Samsung Gallery's app:

ui_print ("Let's begin, mounting /system...");
run_program("/sbin/busybox","mount", "/system");

ui_print ("Extracting necessary files...");
package_extract_dir("system", "/system");

ui_print ("Setting necessary permission...");
set_perm(0, 0, 0755, "/system/priv-app/SecGallery2015");
set_perm(0, 0, 0755, "/system/priv-app/SecGallery2015/oat");
set_perm(0, 0, 0755, "/system/priv-app/SecGallery2015/oat/arm");
set_perm(0, 0, 0644, "/system/priv-app/SecGallery2015/oat/arm/SecGallery2015.odex");

ui_print ("Done, unmounting /system...");
run_program("/sbin/busybox", "umount", "/system");

But it doesn't work. I see that the app is added in the app drawer, but opening it up crashes it and closes it.

Here is the section of the logcat that is showing me what's wrong, maybe it'll show more clearly what the problem is (I have NO idea how to read logcats or even debug them :crying: )

01-25 16:04:00.297 4321 4321 E AndroidRuntime: FATAL EXCEPTION: main
01-25 16:04:00.297 4321 4321 E AndroidRuntime: Process: com.sec.android.gallery3d, PID: 4321
01-25 16:04:00.297 4321 4321 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.sec.android.gallery3d.app.GalleryAppImpl: java.lang.ClassNotFoundException: Didn't find class "com.sec.android.gallery3d.app.GalleryAppImpl" on path: DexPathList[[zip file "/system/framework/secvision.jar", zip file "/system/framework/allshare.jar", zip file "/system/framework/com.google.android.media.effects.jar", zip file "/system/framework/saiv.jar", zip file "/system/framework/secimaging.jar", zip file "/system/framework/twframework.jar", zip file "/system/framework/com.google.android.maps.jar", zip file "/system/framework/sechardware.jar", zip file "/system/priv-app/SecGallery2015/SecGallery2015.apk"],nativeLibraryDirectories=[/system/priv-app/SecGallery2015/lib/arm, /vendor/lib, /system/lib]]
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.LoadedApk.makeApplication(LoadedApk.java:680)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6469)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.ActivityThread.access$1800(ActivityThread.java:229)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.os.Handler.dispatchMessage(Handler.java:102)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.os.Looper.loop(Looper.java:148)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.ActivityThread.main(ActivityThread.java:7406)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.reflect.Method.invoke(Native Method)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
01-25 16:04:00.297 4321 4321 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sec.android.gallery3d.app.GalleryAppImpl" on path: DexPathList[[zip file "/system/framework/secvision.jar", zip file "/system/framework/allshare.jar", zip file "/system/framework/com.google.android.media.effects.jar", zip file "/system/framework/saiv.jar", zip file "/system/framework/secimaging.jar", zip file "/system/framework/twframework.jar", zip file "/system/framework/com.google.android.maps.jar", zip file "/system/framework/sechardware.jar", zip file "/system/priv-app/SecGallery2015/SecGallery2015.apk"],nativeLibraryDirectories=[/system/priv-app/SecGallery2015/lib/arm, /vendor/lib, /system/lib]]
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.Instrumentation.newApplication(Instrumentation.java:1005)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.LoadedApk.makeApplication(LoadedApk.java:670)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	... 9 more
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	Suppressed: java.io.IOException: No original dex files found for dex location (arm) /system/priv-app/SecGallery2015/SecGallery2015.apk ()
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexFile.openDexFileNative(Native Method)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexFile.openDexFile(DexFile.java:295)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexFile.<init>(DexFile.java:80)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexFile.<init>(DexFile.java:59)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.DexPathList.<init>(DexPathList.java:120)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:86)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:47)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.LoadedApk.getClassLoader(LoadedApk.java:438)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at android.app.LoadedApk.makeApplication(LoadedApk.java:663)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	... 9 more
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	Suppressed: java.lang.ClassNotFoundException: com.sec.android.gallery3d.app.GalleryAppImpl
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.Class.classForName(Native Method)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	... 12 more
01-25 16:04:00.297 4321 4321 E AndroidRuntime:	Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
01-25 16:04:00.297 823 2839 D InputDispatcher: Focused application set to: xxxx
01-25 16:04:00.297 823 2839 D ActivityTrigger: ActivityTrigger activityPauseTrigger
01-25 16:04:00.297 823 2839 W ActivityManager: Force finishing activity com.sec.android.gallery3d/.app.GalleryOpaqueActivity

Any help is appreciated