Search Unity

2019.1.0f2 apkanalyzer issue

Discussion in 'Android' started by YuriBazila, Apr 18, 2019.

  1. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    47
    I can't build for android because of the error at the end of build process.
    Unity tries to execute D:/AndroidSDK\tools\bin\apkanalyzer.bat but there is no such file.
    apkanalyzer does not have .bat

    apkanal.PNG
     
  2. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    47
    That is only happend when build & run
     
  3. AlonsyRC

    AlonsyRC

    Joined:
    Dec 31, 2012
    Posts:
    10
    I am having the same Issue, did you find a solution?
     
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Please submit a bug report with steps to reproduce and the project attached (could be a small one) and post the case number here. Thanks!
     
  5. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
  6. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Jeez, it's a duplicate of a bug that exists from March, 19th, 2018 !!!!

    https://issuetracker.google.com/issues/75981301

    I don't expect Google will fix it anytime soon...

    Edit: I tried a .bat I found online and it also didn't work.

    I also tried not using the builtin android sdk on unity 2019 and it also didn't work.

    @Yury-Habets is this apkanalyzer step important? It doesn't seem to happen on unity 2018, it's impossible to make a android build on windows with 2019.


    Edit2: I tried this bat :


    Code (CSharp):
    1. @echo off
    2.  
    3. ::##############################################################################
    4. ::##
    5. ::##  apkanalyzer start up script for Windows
    6. ::##
    7. ::##  converted by ewwink
    8. ::##
    9. ::##############################################################################
    10.  
    11. ::Attempt to set APP_HOME
    12.  
    13. SET SAVED=%cd%
    14. SET APP_HOME=F:\Programs\Unity\2019.1.0f2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools
    15. SET APP_NAME="apkanalyzer"
    16.  
    17. ::Add default JVM options here. You can also use JAVA_OPTS and APKANALYZER_OPTS to pass JVM options to this script.
    18. SET DEFAULT_JVM_OPTS=-Dcom.android.sdklib.toolsdir=%APP_HOME%
    19.  
    20. SET CLASSPATH=%APP_HOME%\lib\dvlib-26.0.0-dev.jar;%APP_HOME%\lib\util-2.2.1.jar;%APP_HOME%\lib\jimfs-1.1.jar;%APP_HOME%\lib\annotations-13.0.jar;%APP_HOME%\lib\ddmlib-26.0.0-dev.jar;%APP_HOME%\lib\repository-26.0.0-dev.jar;%APP_HOME%\lib\sdk-common-26.0.0-dev.jar;%APP_HOME%\lib\kotlin-stdlib-1.1.3-2.jar;%APP_HOME%\lib\protobuf-java-3.0.0.jar;%APP_HOME%\lib\apkanalyzer-cli.jar;%APP_HOME%\lib\gson-2.3.jar;%APP_HOME%\lib\httpcore-4.2.5.jar;%APP_HOME%\lib\dexlib2-2.2.1.jar;%APP_HOME%\lib\commons-compress-1.12.jar;%APP_HOME%\lib\generator.jar;%APP_HOME%\lib\error_prone_annotations-2.0.18.jar;%APP_HOME%\lib\commons-codec-1.6.jar;%APP_HOME%\lib\kxml2-2.3.0.jar;%APP_HOME%\lib\httpmime-4.1.jar;%APP_HOME%\lib\annotations-12.0.jar;%APP_HOME%\lib\bcpkix-jdk15on-1.56.jar;%APP_HOME%\lib\jsr305-3.0.0.jar;%APP_HOME%\lib\explainer.jar;%APP_HOME%\lib\builder-model-3.0.0-dev.jar;%APP_HOME%\lib\baksmali-2.2.1.jar;%APP_HOME%\lib\j2objc-annotations-1.1.jar;%APP_HOME%\lib\layoutlib-api-26.0.0-dev.jar;%APP_HOME%\lib\jcommander-1.64.jar;%APP_HOME%\lib\commons-logging-1.1.1.jar;%APP_HOME%\lib\annotations-26.0.0-dev.jar;%APP_HOME%\lib\builder-test-api-3.0.0-dev.jar;%APP_HOME%\lib\animal-sniffer-annotations-1.14.jar;%APP_HOME%\lib\bcprov-jdk15on-1.56.jar;%APP_HOME%\lib\httpclient-4.2.6.jar;%APP_HOME%\lib\common-26.0.0-dev.jar;%APP_HOME%\lib\jopt-simple-4.9.jar;%APP_HOME%\lib\sdklib-26.0.0-dev.jar;%APP_HOME%\lib\apkanalyzer.jar;%APP_HOME%\lib\shared.jar;%APP_HOME%\lib\binary-resources.jar;%APP_HOME%\lib\guava-22.0.jar
    21.  
    22. SET APP_ARGS=%*
    23. ::Collect all arguments for the java command, following the shell quoting and substitution rules
    24. SET APKANALYZER_OPTS=%DEFAULT_JVM_OPTS% -classpath %CLASSPATH% com.android.tools.apk.analyzer.ApkAnalyzerCli %APP_ARGS%
    25.  
    26. ::Determine the Java command to use to start the JVM.
    27. SET JAVACMD="java"
    28. where %JAVACMD% >nul 2>nul
    29. if %errorlevel%==1 (
    30.   echo ERROR: 'java' command could be found in your PATH.
    31.   echo Please set the 'java' variable in your environment to match the
    32.   echo location of your Java installation.
    33.   echo.
    34.   exit /b 0
    35. )
    36.  
    37. :: execute apkanalyzer
    38.  
    39. %JAVACMD% %APKANALYZER_OPTS%

    And it throws this error :


    Code (CSharp):
    1. stderr[
    2. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    3. Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    4.     at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    5.     at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    6.     at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    7.     at com.android.tools.apk.analyzer.ApkAnalyzerCli.getAaptInvokerFromSdk(ApkAnalyzerCli.java:277)
    8.     at com.android.tools.apk.analyzer.ApkAnalyzerCli.main(ApkAnalyzerCli.java:129)
    9. Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    10.     at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    11.     at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    12.     at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    13.     ... 5 more
    14. ]
    15. stdout[
    16.  
    17. ]
    18. exit code: 1
    19.  

    edit 3:
    When the command is ran from unity with my bat it throws the error:

    CommandInvokationFailure:
    F:\Programs\Unity\2019.1.0f2\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin\apkanalyzer.bat manifest version-code "G:/Projects/test/Builds/Android\testapk.armeabi-v7a.apk"


    But if I execute it manually in command prompt it apparently works and returns the apk version 100001.


    edit 4:
    I tested on another project and it doesn't run apkanalyzer, same unity version, what is this? How can we skip this step?
     
    Last edited: Apr 30, 2019
  7. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    The only way I got it to work was to make my own hacked bat file


    Code (CSharp):
    1. @echo off
    2.  
    3. ECHO 100001
    change 100001 to whatever is the version you want to Build and run...
     
  8. Deleted User

    Deleted User

    Guest

    Did you try adding the missing extension?
     
  9. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    That file is a unix shell script. Doesn't work on windows. The bat I posted above should work, it runs nice when I execute with command prompt, but unity fails to make it work and I couldn't figure out why.

    I also can't understand why Unity runs the analyzer in one project and not on the other.
     
  10. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Unfortunately we're reverting back to using AAPT instead of apkanalyzer for now.

    Apkanalyzer from SDK build-tools v29 seems to work; the tools currently in beta, when they get released, we may revert to using apkanalyzer again.
     
  11. AlonsyRC

    AlonsyRC

    Joined:
    Dec 31, 2012
    Posts:
    10
  12. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Thanks. The fix is on its way.
     
    AlonsyRC likes this.
  13. AlonsyRC

    AlonsyRC

    Joined:
    Dec 31, 2012
    Posts:
    10
    Cool, thanks! any ETA?