Search Unity

Bug Add an old Android SDK

Discussion in 'Android' started by Clashman, May 25, 2021.

  1. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    Hi !

    I use the Unity Editor 2019.4.25f1 with Android SDK 29 API by default. However I need to use the Android SDK 28 API. I downloaded the platform with the SDK Manager but the compiler gives me the error message "Android resource linking failed". What can I do to properly have the SDK ?

    Thanks a lot for your answers !
    Lilian
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    After downloading SDK 28, did you select API 28 in Unity or switched to API 28 in gradle project itself? I think depending on the API Level Unity generates different gradle resource xml files, most likely there's an entry which was for API 29 and it doesn't exist in API 28, that's why you're getting an error, the error shouldn't contain the name of that resource
     
  3. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    I switched to API 28 in Player Settings in Unity. What is the name of the gradle file ? How can I modify gradle file ?
     
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    Since you didn't post the full error, I am not sure which file is this.

    Here's what you could do:
    Choose export project in Unity, open gradle proejct from Android Studio, try to build it, it should point you to the faulty file.
     
  5. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    I put my errors below. I don't understand where the problem come from...

    upload_2021-5-25_12-39-52.png
    upload_2021-5-25_12-37-17.png
     
  6. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    I generated with Player Settings a mainTemplate.gradle file and modified it. But the error is still here.

    The content of my gradle file :

    Code (JavaScript):
    1. // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
    2.  
    3. apply plugin: 'com.android.library'
    4. **APPLY_PLUGINS**
    5.  
    6. dependencies {
    7.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    8. **DEPS**}
    9.  
    10. android {
    11.     compileSdkVersion 28
    12.     buildToolsVersion '28.0.3'
    13.  
    14.     compileOptions {
    15.         sourceCompatibility JavaVersion.VERSION_1_8
    16.         targetCompatibility JavaVersion.VERSION_1_8
    17.     }
    18.  
    19.     defaultConfig {
    20.         minSdkVersion 20
    21.         targetSdkVersion 28
    22.         ndk {
    23.             abiFilters "armeabi-v7a"
    24.         }
    25.         versionCode 30
    26.         versionName "2.92"
    27.         consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    28.     }
    29.  
    30.     lintOptions {
    31.         abortOnError false
    32.     }
    33.  
    34.     aaptOptions {
    35.         ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    36.     }**PACKAGING_OPTIONS**
    37. }**REPOSITORIES****SOURCE_BUILD_SETUP**
    38. **EXTERNAL_SOURCES**
     
  7. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    Click on 'Configure project launcher" it should contain more in the summary
     
  8. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    This is the summary of 'Configure project launcher" :

    Code (CSharp):
    1.  
    2. > Configure project :launcher
    3. NDK is missing a "platforms" directory.
    4. If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\lilia\AppData\Local\Android\sdk\ndk-bundle.
    5. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
    6.  
    7.  
    8. > Configure project :unityLibrary
    9. NDK is missing a "platforms" directory.
    10. If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\lilia\AppData\Local\Android\sdk\ndk-bundle.
    11. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
    12.  
    13.  
    14. > Task :unityLibrary:preBuild UP-TO-DATE
    15. > Task :launcher:preBuild UP-TO-DATE
    16. > Task :unityLibrary:preReleaseBuild UP-TO-DATE
    17. > Task :unityLibrary:checkReleaseManifest UP-TO-DATE
    18. > Task :launcher:prepareLintJar UP-TO-DATE
    19.  
    20. > Task :unityLibrary:processReleaseManifest
    21. C:\Users\lilia\OneDrive\Documents\Projets\Unity\Nouveau dossier\FitImmersion-Unity\Temp\gradleOut\unityLibrary\src\main\AndroidManifest.xml:4:3-19:17 Warning:
    22.     application@android:allowBackup was tagged at AndroidManifest.xml:4 to replace other declarations but no other declaration present
    23.  
    24. > Task :unityLibrary:compileReleaseAidl NO-SOURCE
    25. > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
    26. > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
    27. > Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
    28. > Task :unityLibrary:generateReleaseResValues UP-TO-DATE
    29. > Task :unityLibrary:generateReleaseResources UP-TO-DATE
    30. > Task :unityLibrary:packageReleaseResources UP-TO-DATE
    31. > Task :unityLibrary:generateReleaseRFile UP-TO-DATE
    32. > Task :launcher:preReleaseBuild
    33. > Task :unityLibrary:prepareLintJar UP-TO-DATE
    34. > Task :launcher:compileReleaseAidl NO-SOURCE
    35. > Task :unityLibrary:generateReleaseSources UP-TO-DATE
    36. > Task :launcher:compileReleaseRenderscript NO-SOURCE
    37. > Task :launcher:checkReleaseManifest UP-TO-DATE
    38. > Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
    39. > Task :launcher:generateReleaseBuildConfig UP-TO-DATE
    40. > Task :launcher:generateReleaseSources UP-TO-DATE
    41. > Task :launcher:mainApkListPersistenceRelease UP-TO-DATE
    42. > Task :launcher:generateReleaseResValues UP-TO-DATE
    43. > Task :launcher:generateReleaseResources UP-TO-DATE
    44. > Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
    45. > Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE
    46. > Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
    47. > Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
    48. > Task :unityLibrary:compileReleaseShaders UP-TO-DATE
    49. > Task :unityLibrary:generateReleaseAssets UP-TO-DATE
    50. > Task :launcher:mergeReleaseResources UP-TO-DATE
    51. > Task :launcher:javaPreCompileRelease
    52. > Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
    53.  
    54. > Task :launcher:processReleaseManifest
    55. C:\Users\lilia\OneDrive\Documents\Projets\Unity\Nouveau dossier\FitImmersion-Unity\Temp\gradleOut\launcher\src\main\AndroidManifest.xml:5:3-121 Warning:
    56.     application@android:allowBackup was tagged at AndroidManifest.xml:5 to replace other declarations but no other declaration present
    57.  
    58. > Task :unityLibrary:packageReleaseAssets
    59. > Task :unityLibrary:bundleLibRuntimeRelease
    60. > Task :unityLibrary:processReleaseJavaRes NO-SOURCE
    61. > Task :unityLibrary:bundleLibResRelease
    62. > Task :launcher:processReleaseResources FAILED
    63. > Task :unityLibrary:mergeReleaseJniLibFolders
    64.  
    65. Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
    66. Use '--warning-mode all' to show the individual deprecation warnings.
    67. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
    68. 28 actionable tasks: 9 executed, 19 up-to-date
    69.  
    70. UnityEngine.GUIUtility:ProcessEvent (int,intptr)
     

    Attached Files:

  9. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    There you go, it says:
    Code (CSharp):
    1. NDK is missing a "platforms" directory.
    Your NDK is invalid I assume
     
  10. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    It's strange because I have a NDK and I use it with API 29...
     
  11. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    Hi ! I added a "platforms" folder in my NDK directory. However, the program still doesn't compile and I don't understand why... This is my error message :

    Code (CSharp):
    1. ask :unityLibrary:preBuild UP-TO-DATE
    2. > Task :launcher:preBuild UP-TO-DATE
    3. > Task :unityLibrary:preReleaseBuild UP-TO-DATE
    4. > Task :unityLibrary:checkReleaseManifest UP-TO-DATE
    5. > Task :launcher:prepareLintJar UP-TO-DATE
    6.  
    7. > Task :unityLibrary:processReleaseManifest
    8. C:\Users\lilia\OneDrive\Documents\Projets\Unity\Nouveau dossier\FitImmersion-Unity\Temp\gradleOut\unityLibrary\src\main\AndroidManifest.xml:4:3-19:17 Warning:
    9.     application@android:allowBackup was tagged at AndroidManifest.xml:4 to replace other declarations but no other declaration present
    10.  
    11. > Task :unityLibrary:compileReleaseAidl NO-SOURCE
    12. > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
    13. > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
    14. > Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
    15. > Task :unityLibrary:generateReleaseResValues UP-TO-DATE
    16. > Task :unityLibrary:generateReleaseResources UP-TO-DATE
    17. > Task :unityLibrary:packageReleaseResources UP-TO-DATE
    18. > Task :launcher:preReleaseBuild
    19. > Task :launcher:compileReleaseAidl NO-SOURCE
    20. > Task :unityLibrary:generateReleaseRFile UP-TO-DATE
    21. > Task :launcher:compileReleaseRenderscript NO-SOURCE
    22. > Task :unityLibrary:prepareLintJar UP-TO-DATE
    23. > Task :launcher:checkReleaseManifest UP-TO-DATE
    24. > Task :unityLibrary:generateReleaseSources UP-TO-DATE
    25. > Task :launcher:generateReleaseBuildConfig UP-TO-DATE
    26. > Task :launcher:generateReleaseSources UP-TO-DATE
    27. > Task :launcher:mainApkListPersistenceRelease UP-TO-DATE
    28. > Task :launcher:generateReleaseResValues UP-TO-DATE
    29. > Task :launcher:generateReleaseResources UP-TO-DATE
    30. > Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
    31. > Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
    32. > Task :unityLibrary:bundleLibCompileRelease UP-TO-DATE
    33. > Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
    34. > Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
    35. > Task :unityLibrary:compileReleaseShaders UP-TO-DATE
    36. > Task :unityLibrary:generateReleaseAssets UP-TO-DATE
    37. > Task :launcher:mergeReleaseResources UP-TO-DATE
    38. > Task :launcher:javaPreCompileRelease UP-TO-DATE
    39. > Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
    40.  
    41. > Task :launcher:processReleaseManifest
    42. C:\Users\lilia\OneDrive\Documents\Projets\Unity\Nouveau dossier\FitImmersion-Unity\Temp\gradleOut\launcher\src\main\AndroidManifest.xml:5:3-121 Warning:
    43.     application@android:allowBackup was tagged at AndroidManifest.xml:5 to replace other declarations but no other declaration present
    44.  
    45. > Task :unityLibrary:packageReleaseAssets
    46. > Task :unityLibrary:bundleLibRuntimeRelease
    47. > Task :unityLibrary:processReleaseJavaRes NO-SOURCE
    48. > Task :unityLibrary:bundleLibResRelease
    49. > Task :launcher:processReleaseResources FAILED
    50. > Task :unityLibrary:mergeReleaseJniLibFolders
    51.  
    52. Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
    53. Use '--warning-mode all' to show the individual deprecation warnings.
    54. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
    55. 28 actionable tasks: 8 executed, 20 up-to-date
    56.  
    57. UnityEngine.GUIUtility:ProcessEvent (int,intptr)
     
  12. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    I don't see the error, there is that warning regarding AndroidManifest, but I am not sure if that would cause a failure.

    Try exporting a project, and build from Android Studio
     
  13. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    In Build Settings window, there's Export Project checkbox
     
  14. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    I found it. I built my project on Android Studio and the compiler give me an error in a generated manifest.xml...

    Code (CSharp):
    1. Android resource linking failed
    2. C:\Users\lilia\OneDrive\Documents\Projets\Exported\launcher\build\intermediates\merged_manifests\debug\AndroidManifest.xml:56: error: attribute android:requestLegacyExternalStorage not found.
    3. error: failed processing manifest.
    I found the same error in the console of Unity :

    Code (CSharp):
    1. FAILURE: Build failed with an exception.
    2.  
    3. * What went wrong:
    4. Execution failed for task ':launcher:processReleaseResources'.
    5. > Android resource linking failed
    6.   C:\Users\lilia\OneDrive\Documents\Projets\Unity\Nouveau dossier\FitImmersion-Unity\Temp\gradleOut\launcher\build\intermediates\merged_manifests\release\AndroidManifest.xml:56: AAPT: error: attribute android:requestLegacyExternalStorage not found.
    7.      
    8.   error: failed processing manifest.
    9.  
    10. * Try:
    11. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    12.  
    13. * Get more help at https://help.gradle.org
     

    Attached Files:

  15. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    requestLegacyExternalStorage is only available in API 29, that's why when you choose API 28, it's not found.

    If you can please report a bug report, since I think Unity shouldn't add requestLegacyExternalStorage to manifest if API 28 or lower is chosen.

    You can also workaround this issue locally, by going to AndroidManifest and removing requestLegacyExternalStorage entry, but only if you do Export Project.
     
    jmcgraw961 likes this.
  16. jmcgraw961

    jmcgraw961

    Joined:
    Jun 7, 2021
    Posts:
    11
    After reading this I resolved my issue by upgrading to API 29 in Player > Settings for Android > Other Settings > Android 10.0 (API level 29). When prompted to update the required Android SDK level, I let it update.