当前位置: 首页 > news >正文

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

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

导出AndroidStudio工程后 需要设置

build.gradle文件

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0' //最低这个
}
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

apply plugin: 'com.android.application'


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
}

android {
    compileSdkVersion 34   //必须这个
    buildToolsVersion '30.0.2' //可选这个

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 34 //必须这个
        applicationId 'com.hemiao.mycabin'
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a'
        }
        versionCode 1
        versionName '1.0'
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = ['.unity3d', '.ress', '.resource', '.obb']
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    signingConfigs {
        release {
            storeFile file('D:/svn-MyCabin/接GooglePay/myCabin.keystore')
            storePassword '123456'
            keyAlias 'mycabin'
            keyPassword '123456'
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.release
            jniDebuggable true
        }
        release {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.release
        }
    }

    packagingOptions {
        doNotStrip '*/armeabi-v7a/*.so'
        doNotStrip '*/arm64-v8a/*.so'
    }


    bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
    }
}

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

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hemiao.mycabin" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:theme="@style/UnityThemeSelector" android:icon="@mipmap/app_icon" android:label="@string/app_name">
    <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">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="android.notch_support" android:value="true" />
    </activity>
    <meta-data android:name="unity.build-id" android:value="dbc63be6-bb66-47ab-b2ec-b8c3198b2086" />
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
  </application>
  <uses-feature android:glEsVersion="0x00020000" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>

配上Proejct Setting., 注target Api 要34

相关文章:

  • 探秘Nutch:揭秘开源搜索引擎的工作原理与无限应用可能(三)
  • 【vue在主页中点击主页面如何弹出一个指定某个页面的窗口】
  • SQLiteC/C++接口详细介绍之sqlite3类(十五)
  • C++ 虚函数表
  • python之自动化(django)
  • 数据库 | Mysql - [binlog]
  • 【LeetCode热题100】148. 排序链表(链表)
  • 门牌制作-蓝桥杯?-Lua 中文代码解题第3题
  • 第八阶段:uni-app小程序 --首页开发(2)
  • 【深度学习目标检测】二十三、基于深度学习的行人检测计数系统-含数据集、GUI和源码(python,yolov8)
  • Spring同时集成JPA与Mybatis
  • 【C++】vector的使用及其模拟实现
  • SpringCloud Gateway 新一代网关
  • 引领人工智能时代的应用安全
  • java售后服务管理系统
  • Golang实现Redis分布式锁(Lua脚本+可重入+自动续期)
  • 【leetcode热题】 两数之和 II - 输入有序数组
  • 9.用FFmpeg测试H.264文件的解码时间
  • 路由器端口转发远程桌面控制:一电脑连接不同局域网的另一电脑
  • springcloud五大组件:Eureka:注册中心、Zuul:服务网关、Ribbon:负载均衡、Feign:服务调用、Hystix:熔断器
  • 【社论】进一步拧紧过紧日子的制度螺栓
  • 中国情怀:时代记录与家国镜相|澎湃·镜相第三届非虚构写作大赛暨七猫第六届百万奖金现实题材征文大赛征稿启事
  • 商务部召开全国离境退税工作推进会:提高退税商店覆盖面,扩大入境消费
  • 董军在第六届联合国维和部长级会议上作大会发言
  • 警方通报男子广州南站持刀伤人:造成1人受伤,嫌疑人被控制
  • 商务部:今年前3月自贸试验区进出口总额达2万亿元