当前位置:   article > 正文

Unity2019.2.x 导出apk 安装到安卓Android12+及以上的系统版本 安装出现-108 安装包似乎无效的解决办法

Unity2019.2.x 导出apk 安装到安卓Android12+及以上的系统版本 安装出现-108 安装包似乎无效的解决办法

Unity2019.2.x 导出apk 安装到安卓Android12+及以上的系统版本 安装出现-108 安装包似乎无效的解决办法

导出AndroidStudio工程后 需要设置

build.gradle文件

  1. // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
  2. buildscript {
  3. repositories {
  4. google()
  5. jcenter()
  6. }
  7. dependencies {
  8. classpath 'com.android.tools.build:gradle:4.1.0' //最低这个
  9. }
  10. }
  11. allprojects {
  12. repositories {
  13. google()
  14. jcenter()
  15. flatDir {
  16. dirs 'libs'
  17. }
  18. }
  19. }
  20. apply plugin: 'com.android.application'
  21. dependencies {
  22. implementation fileTree(dir: 'libs', include: ['*.jar'])
  23. }
  24. android {
  25. compileSdkVersion 34 //必须这个
  26. buildToolsVersion '30.0.2' //可选这个
  27. compileOptions {
  28. sourceCompatibility JavaVersion.VERSION_1_8
  29. targetCompatibility JavaVersion.VERSION_1_8
  30. }
  31. defaultConfig {
  32. minSdkVersion 16
  33. targetSdkVersion 34 //必须这个
  34. applicationId 'com.hemiao.mycabin'
  35. ndk {
  36. abiFilters 'armeabi-v7a', 'arm64-v8a'
  37. }
  38. versionCode 1
  39. versionName '1.0'
  40. }
  41. lintOptions {
  42. abortOnError false
  43. }
  44. aaptOptions {
  45. noCompress = ['.unity3d', '.ress', '.resource', '.obb']
  46. ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
  47. }
  48. signingConfigs {
  49. release {
  50. storeFile file('D:/svn-MyCabin/接GooglePay/myCabin.keystore')
  51. storePassword '123456'
  52. keyAlias 'mycabin'
  53. keyPassword '123456'
  54. }
  55. }
  56. buildTypes {
  57. debug {
  58. minifyEnabled false
  59. useProguard false
  60. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
  61. signingConfig signingConfigs.release
  62. jniDebuggable true
  63. }
  64. release {
  65. minifyEnabled false
  66. useProguard false
  67. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
  68. signingConfig signingConfigs.release
  69. }
  70. }
  71. packagingOptions {
  72. doNotStrip '*/armeabi-v7a/*.so'
  73. doNotStrip '*/arm64-v8a/*.so'
  74. }
  75. bundle {
  76. language {
  77. enableSplit = false
  78. }
  79. density {
  80. enableSplit = false
  81. }
  82. abi {
  83. enableSplit = true
  84. }
  85. }
  86. }

如果要上gp的话 还要 设置AndroidManifest.xml  增加字段android:exported="true"

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hemiao.mycabin" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
  3. <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  4. <application android:theme="@style/UnityThemeSelector" android:icon="@mipmap/app_icon" android:label="@string/app_name">
  5. <activity android:label="@string/app_name" android:exported="true" android:screenOrientation="sensorLandscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false" android:name="com.hemiao.mycabin.UnityPlayerActivity">
  6. <intent-filter>
  7. <action android:name="android.intent.action.MAIN" />
  8. <category android:name="android.intent.category.LAUNCHER" />
  9. </intent-filter>
  10. <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
  11. <meta-data android:name="android.notch_support" android:value="true" />
  12. </activity>
  13. <meta-data android:name="unity.build-id" android:value="dbc63be6-bb66-47ab-b2ec-b8c3198b2086" />
  14. <meta-data android:name="unity.splash-mode" android:value="0" />
  15. <meta-data android:name="unity.splash-enable" android:value="True" />
  16. <meta-data android:name="notch.config" android:value="portrait|landscape" />
  17. </application>
  18. <uses-feature android:glEsVersion="0x00020000" />
  19. <uses-permission android:name="android.permission.INTERNET" />
  20. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  21. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  22. <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false" />
  23. <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  24. <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  25. <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
  26. </manifest>

配上Proejct Setting., 注target Api 要34

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/260870
推荐阅读
  

闽ICP备14008679号