This article solves the error message that occurs when you try to wrap a Line of Business (LOB) app by using the Microsoft Intune App Wrapping Tool for Android.
Original product version: Microsoft Intune
Original KB number: 4469909
Symptoms
When you wrap a LOB app by using the Microsoft Intune App Wrapping Tool for Android, the tool crashes, and you receive an error message that resembles the following:
DBG [APKTool] Finish encoding directory into APK file:<path of .apk>
WRN Verbose logs can be found at: <path of .apk logfile>.
ERR The application could not be wrapped.
org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method <method name>
org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:825)
org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:268)
org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:246)
brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
brut.androlib.Androlib.buildSourcesSmali(Androlib.java:417)
brut.androlib.Androlib.buildSources(Androlib.java:348)
brut.androlib.Androlib.build(Androlib.java:300)
com.microsoft.intune.mam.apppackager.utils.APKToolWrapper.encodeAPK(APKToolWrapper.java:172)
com.microsoft.intune.mam.apppackager.AppPackager.packageApp(AppPackager.java:111)
com.microsoft.intune.mam.apppackager.PackagerMain.mainInternal(PackagerMain.java:213)
com.microsoft.intune.mam.apppackager.PackagerMain.main(PackagerMain.java:57)
org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x13
org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1098)
org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:821)
org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:268)
org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:246)
brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
brut.androlib.Androlib.buildSourcesSmali(Androlib.java:417)
brut.androlib.Androlib.buildSources(Androlib.java:348)
brut.androlib.Androlib.build(Androlib.java:300)
com.microsoft.intune.mam.apppackager.utils.APKToolWrapper.encodeAPK(APKToolWrapper.java:172)
com.microsoft.intune.mam.apppackager.AppPackager.packageApp(AppPackager.java:111)
com.microsoft.intune.mam.apppackager.PackagerMain.mainInternal(PackagerMain.java:213)
com.microsoft.intune.mam.apppackager.PackagerMain.main(PackagerMain.java:57)
org.jf.util.ExceptionWithContext: Unsigned short value out of range: <65536 or a value that's greater than 65536>
org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:348)
org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1058)
Cause
The problem occurs if the LOB app reaches or nearly reaches the 64K method reference limit of DEX files. In this scenario, the Microsoft Intune Wrapping Tool can't add the necessary Intune code to the app without exceeding this limit.
Resolution
To fix this problem, follow these steps:
- Install the latest version of the Microsoft Intune App Wrapping Tool for Android.
- Enable multidex for your Android app.
Test whether the problem is fixed. If the problem persists, try the methods that are provided in the next section.
Workaround
To work around this problem, try the following methods in the given order:
-
Examine the multidex configuration to see whether you specify any classes in the primary DEX file. You may experience problems if too many classes are added to the primary DEX file. For more information, see https://developer.android.com/studio/build/multidex#keep.
To work around this problem, reduce the number of classes that are specified in the primary DEX file.
-
Enable code shrinking by using ProGuard. For more information, see https://developer.android.com/studio/build/shrink-code#shrink-code
Note
Some third-party libraries may require additional ProGuard configuration.
Microsoft documentation: https://docs.microsoft.com/en-us/troubleshoot/mem/intune/application-could-not-be-wrapped
Comments
0 comments
Article is closed for comments.