Wrapping of apk fails.

Document ID : KB000030132
Last Modified Date : 14/02/2018
Show Technical Document Details

Problem:

Attempting to wrap an apk either through the web interface or manually fails.

When run manually the following is seen in step 3:


Step 3 of 4: Packaging instrumented APK.
invalid resource directory name: /tmp/AndroidWrapper_882795840066530680386647295879___1055214/apktoolExtract/res/drawable-xxxhdpi
invalid resource directory name: /tmp/AndroidWrapper_882795840066530680386647295879___1055214/apktoolExtract/res/drawable-ldrtl-xxxhdpi-v17
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [/opt/ca/emm/bin/android/linux/aapt, p, --min-sdk-version, 10, --target-sdk-version, 21, --version-code, 1, --version-name, 1.0, -F, /tmp/APKTOOL147353453197014597.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /tmp/AndroidWrapper_882795840066530680386647295879___1055214/apktoolExtract/res, -M, /tmp/AndroidWrapper_882795840066530680386647295879___1055214/apktoolExtract/AndroidManifest.xml]...........................

Cause:

Some Android apks declare resources in their manifest file but the actual resource is missing.

The Android tool apktool used to decompile the apk fails with this type of apk.

 

Solution:

The apktool option -nores prevents the decompile of resources and avoids this issue.

Manually wrapping the apk

To resolve this error:

versions before 15.2

  • edit the file wrap.sh
  • locate the line

    $JAVA_HOME/bin/java -jar $JAVA_DEBUG $JAR -apk "$APKFILE" -plist "$PLIST" -keystore $KEYSTORE -storepass $CERTPASS -keypass $KEYPASS -alias $ALIAS
  • add the -nores option

    $JAVA_HOME/bin/java -jar $JAVA_DEBUG $JAR -apk "$APKFILE" -plist "$PLIST" -keystore $KEYSTORE -storepass $CERTPASS -keypass $KEYPASS -alias $ALIAS -nores
  • save wrap.sh
  • retry the wrapping

15.2 and above

  • When calling wrap.sh use the optional parameter -r, this will instruct the wrapping utility to use the -nores option

Wrapping through the web interface

  • In the current version 14.4, it is not possible to utilize the -nores option and the manual solution is required.
  • In 15.2 and above the Web UI will automatically try with -nores if the wrapping fails without it.

 

Side Effects:

When using the -nores option the MAA wrapping process cannot modify the permissions within manifest.xml. If the app does not already have the permissions required this will prevent MAA from collecting the data associated with the permission.

The permissions required are:

  • INTERNET,
  • ACCESS_NETWORK_STATE,
  • WRITE_EXTERNAL_STORAGE,
  • READ_PHONE_STATE,
  • ACCESS_WIFI_STATE
  • ACCESS_COARSE_LOCATION