microsoftconnect / intune-app-wrapping-tool-android

Use the Intune App Wrapping Tool for Android to enable Android apps to be managed by Microsoft Intune
29 stars 11 forks source link

Unable to wrap release builds of the app #16

Closed liamheneghan closed 3 years ago

liamheneghan commented 6 years ago

The latest version of the app wrapping tool succesfully wraps my debug build types but release types fail with the following error:

The application could not be wrapped.
        org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Landroid/arch/core/execu
tor/DefaultTaskExecutor;-><init>()V
                org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:824)
                org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:267)
                org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:245)
                brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
                brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
                brut.androlib.Androlib.buildSourcesSmali(Androlib.java:412)
                brut.androlib.Androlib.buildSources(Androlib.java:343)
                brut.androlib.Androlib.build(Androlib.java:299)
                com.microsoft.intune.mam.apppackager.utils.APKToolWrapper.encodeAPK(APKToolWrapper.java:166)
                com.microsoft.intune.mam.apppackager.AppPackager.packageApp(AppPackager.java:138)
                com.microsoft.intune.mam.apppackager.PackagerMain.mainInternal(PackagerMain.java:200)
                com.microsoft.intune.mam.apppackager.PackagerMain.main(PackagerMain.java:56)
        org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0xb
                org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1091)
                org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:820)
                org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:267)
                org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:245)
                brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
                brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
                brut.androlib.Androlib.buildSourcesSmali(Androlib.java:412)
                brut.androlib.Androlib.buildSources(Androlib.java:343)
                brut.androlib.Androlib.build(Androlib.java:299)
                com.microsoft.intune.mam.apppackager.utils.APKToolWrapper.encodeAPK(APKToolWrapper.java:166)
                com.microsoft.intune.mam.apppackager.AppPackager.packageApp(AppPackager.java:138)
                com.microsoft.intune.mam.apppackager.PackagerMain.mainInternal(PackagerMain.java:200)
                com.microsoft.intune.mam.apppackager.PackagerMain.main(PackagerMain.java:56)
        org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65797
                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:1051)
                org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:820)
                org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:267)
                org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:245)
                brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
                brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
                brut.androlib.Androlib.buildSourcesSmali(Androlib.java:412)
                brut.androlib.Androlib.buildSources(Androlib.java:343)
                brut.androlib.Androlib.build(Androlib.java:299)
                com.microsoft.intune.mam.apppackager.utils.APKToolWrapper.encodeAPK(APKToolWrapper.java:166)
                com.microsoft.intune.mam.apppackager.AppPackager.packageApp(AppPackager.java:138)
                com.microsoft.intune.mam.apppackager.PackagerMain.mainInternal(PackagerMain.java:200)
                com.microsoft.intune.mam.apppackager.PackagerMain.main(PackagerMain.java:56)
Application wrapping in progress. App Wrapping Tool Version: 1.0.2116.2
Using Apktool 2.3.0 on app-production-release.apk
thomasvsundert commented 5 years ago

We are running into the exact same issue. @liamheneghan did you find a solution? This is currently blocking us from releasing our application.

liamheneghan commented 5 years ago

Unfortunately not @thomasvsundert. We have since stopped pursuing using the Intune SDK.

thomasvsundert commented 5 years ago

@msintuneappsdk any ideas on this issue? Could it be an issue with the APKTool? I saw they only recently added support for Android P, maybe this version is not yet packaged in the wrapper?

aanavath commented 5 years ago

Hi @thomasvsundert, are you working with a natively built Android app? Does the app build without being wrapped? What is the target Android SDK version set for this app?

thomasvsundert commented 5 years ago

Hi @aanavath, this is indeed a native Android app, everything works perfectly when not using the wrapper. The target SDK is 27

aanavath commented 5 years ago

Hi folks, the 'Unsigned short value out of range' error sounds like its related to enabling Multidex. From our documentation: (Optional) Enable Multidex within the input app. Sometimes an app may hit the Dalvik Executable (DEX) size limit due to the Intune MAM SDK classes that are added during wrapping. DEX files are a part of the compilation of an Android app. In this scenario, best practice would be to enable Multidex within the app itself. In certain organizations, this may require working with whoever compiles the app (ie. the app build team).

msintuneappsdk commented 5 years ago

@liamheneghan @thomasvsundert Please let us know if you are still experiencing this issue.

patlewis-MSFT commented 4 years ago

@thomasvsundert : I wrote an article regarding this a while back. See the following https://support.microsoft.com/sl-si/help/4469909/the-application-could-not-be-wrapped-when-wrapping-an-android-app