Search Unity

I can´t export my APK..

Discussion in 'Android' started by Bydark, Oct 19, 2017.

  1. Bydark

    Bydark

    Joined:
    Oct 9, 2013
    Posts:
    10
    Hello everyone, I've been trying to export my game for two days in an APK, but Unity gives me an error.

    The keystore is correct, I tried different versions of Android Studio, but the problem persists.

    This is the error that comes out in console.

    "Failed to re-package resources. See the Console for details:"

    CommandInvokationFailure: Failed to re-package resources.
    C: \ Users \ Bydark \ AppData \ Local \ Android \ sdk \ build-tools \ 23.0.1 \ aapt.exe package --auto-add-overlay -v -f -m -J "gen" -M "AndroidManifest. xml "-S" res "-I" C: / Users / Bydark / AppData / Local / Android / sdk \ platforms \ android-22 \ android.jar "-F bin / resources.ap_

    stderr [
    AndroidManifest.xml: 5: error: Error: String types not allowed (at 'configChanges' with value' mcc | mnc | locale | touchscreen | keyboard | keyboardHidden | navigation | orientation | screenLayout | uiMode | screenSize | smallestScreenSize | fontScale | layoutDirection | density ').

    ]
    stdout [
    Configurations:
    (default)
    v14
    v21
    mdpi-v4
    xhdpi-v4

    Files:
    drawable \ app_banner.png
    Src: (xhdpi-v4) res \ drawable-xhdpi \ app_banner.png
    drawable \ app_icon.png
    Src: (mdpi-v4) res \ drawable-mdpi \ app_icon.png
    values \ strings.xml
    Src: () res \ values \ strings.xml
    values \ styles.xml
    Src: () res \ values \ styles.xml
    Src: (v14) res \ values-v14 \ styles.xml
    Src: (v21) res \ values-v21 \ styles.xml
    AndroidManifest.xml
    Src: () AndroidManifest.xml

    Resource Dirs:
    Type drawable
    drawable \ app_banner.png
    Src: (xhdpi-v4) res \ drawable-xhdpi \ app_banner.png
    drawable \ app_icon.png
    Src: (mdpi-v4) res \ drawable-mdpi \ app_icon.png
    Type values
    values \ strings.xml
    Src: () res \ values \ strings.xml
    values \ styles.xml
    Src: () res \ values \ styles.xml
    Src: (v14) res \ values-v14 \ styles.xml
    Src: (v21) res \ values-v21 \ styles.xml
    Including resources from package: C: \ Users \ Bydark \ AppData \ Local \ Android \ sdk \ platforms \ android-22 \ android.jar
    applyFileOverlay for drawable
    applyFileOverlay for layout
    applyFileOverlay for anim
    applyFileOverlay for animator
    applyFileOverlay for interpolator
    applyFileOverlay for transition
    applyFileOverlay for xml
    applyFileOverlay for raw
    applyFileOverlay for color
    applyFileOverlay for menu
    applyFileOverlay for mipmap
    Processing image: res \ drawable-xhdpi \ app_banner.png
    Processing image: res \ drawable-mdpi \ app_icon.png
    (processed image res \ drawable-mdpi \ app_icon.png: 94% size of source)
    (processed image res \ drawable-xhdpi \ app_banner.png: 93% size of source)
    (new resource id app_banner from xhdpi-v4 \ drawable \ app_banner.png #generated)
    (new resource id app_icon from mdpi-v4 \ drawable \ app_icon.png #generated)
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg)
    UnityEditor.Android.PostProcessor.Tasks.BuildResources.CompileResources (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.Tasks.BuildResources.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEngine.GUIUtility: ProcessEvent (Int32, IntPtr)
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    You have selected target SDK level 22 (or that is the latest that you have installed). Make sure you have android API 24 or newer installed and selected as a target sdk (if not using auto option). The problem is that aapt tool does not allow density value for the configChanges until API level 24. https://issuetracker.google.com/issues/67580651
     
  4. Bydark

    Bydark

    Joined:
    Oct 9, 2013
    Posts:
    10
    Thanks for your answer, but when I update and click "build", I get this error

    CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct.
    C:/Program Files/Java/jdk-9.0.1\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir="C:/Users/Bydark/AppData/Local/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity 2017.3.0b5\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

    stderr[
    Error:Invalid command android
    ]
    stdout[

    ]
    exit code: 64
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
    Last edited: Oct 20, 2017
  5. Bydark

    Bydark

    Joined:
    Oct 9, 2013
    Posts:
    10
    Ok, I've managed to go one step further, I've done what it says on this link and I can export to Android 7.0, but when I open it on my phone, I get the following message: "An error occurred while parsing the package".

    I guess it's because my phone uses Android 6.0. The problem is that I want to export my game, and that it is compatible from Android 4.1 to 8.0.

    When I try to export for Android 6.0 or 5.0 (or any other than 7.0) I get this error:

    CommandInvokationFailure: Failed to re-package resources.
    C:\Users\Bydark\AppData\Local\Android\sdk\build-tools\26.0.2\aapt.exe package --auto-add-overlay -v -f -m -J "gen" -M "AndroidManifest.xml" -S "res" -I "C:/Users/Bydark/AppData/Local/Android/sdk\platforms\android-23\android.jar" -F bin/resources.ap_

    stderr[
    AndroidManifest.xml:5: error: Error: String types not allowed (at 'configChanges' with value 'mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density').

    ]
    stdout[
    Configurations:
    (default)
    v14
    v21
    mdpi-v4
    xhdpi-v4

    Files:
    drawable\app_banner.png
    Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
    drawable\app_icon.png
    Src: (mdpi-v4) res\drawable-mdpi\app_icon.png
    values\strings.xml
    Src: () res\values\strings.xml
    values\styles.xml
    Src: () res\values\styles.xml
    Src: (v14) res\values-v14\styles.xml
    Src: (v21) res\values-v21\styles.xml
    AndroidManifest.xml
    Src: () AndroidManifest.xml

    Resource Dirs:
    Type drawable
    drawable\app_banner.png
    Src: (xhdpi-v4) res\drawable-xhdpi\app_banner.png
    drawable\app_icon.png
    Src: (mdpi-v4) res\drawable-mdpi\app_icon.png
    Type values
    values\strings.xml
    Src: () res\values\strings.xml
    values\styles.xml
    Src: () res\values\styles.xml
    Src: (v14) res\values-v14\styles.xml
    Src: (v21) res\values-v21\styles.xml
    Including resources from package: C:\Users\Bydark\AppData\Local\Android\sdk\platforms\android-23\android.jar
    applyFileOverlay for drawable
    applyFileOverlay for layout
    applyFileOverlay for anim
    applyFileOverlay for animator
    applyFileOverlay for interpolator
    applyFileOverlay for transition
    applyFileOverlay for xml
    applyFileOverlay for raw
    applyFileOverlay for color
    applyFileOverlay for menu
    applyFileOverlay for font
    applyFileOverlay for mipmap
    Processing image: res\drawable-xhdpi\app_banner.png
    Processing image: res\drawable-mdpi\app_icon.png
    (processed image res\drawable-mdpi\app_icon.png: 90% size of source)
    (processed image res\drawable-xhdpi\app_banner.png: 93% size of source)
    (new resource id app_banner from xhdpi-v4\drawable\app_banner.png #generated)
    (new resource id app_icon from mdpi-v4\drawable\app_icon.png #generated)
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg)
    UnityEditor.Android.PostProcessor.Tasks.BuildResources.CompileResources (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.Tasks.BuildResources.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Any idea? :(
     
  6. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    So you are running into two different issues here. The first one is that Unity does not work with JDK9 for now, so please use JDK8 instead (you can find more info here https://forum.unity.com/threads/java-9-jdk-9-support-by-unity-android.499354/ ). The other issue is exactly what I've said before
    This means that selecting Target SDK Level from 21 to 23 will fail. So you should select 24 or higher. Please note, that "target sdk level" doesn't mean the only version where your application works. It means that this is the latest version which you have tested, but your application will run on older Android versions as well (see more info here https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#target ). So setting the latest available (or auto) is fine.