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

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


http://www.kler.cn/a/271430.html

相关文章:

  • HTML DOM 对象
  • 【懒删除堆】力扣2349. 设计数字容器系统
  • GitHub Actions定时任务配置完全指南:从Cron语法到实战示例
  • 【视频+图文详解】HTML基础3-html常用标签
  • 基于Springboot的智能学习平台系统【附源码】
  • Visual Studio Code修改terminal字体
  • Linux信号量(简易版)
  • C#编程语言在软件开发中的深度应用与实践
  • android studio 连接mumu模拟器调试
  • StarRocks 易用性全面提升:数据导入可以如此简单
  • 研究生总结
  • <Linux> 线程的同步与互斥
  • Java8中Stream流API最佳实践Lambda表达式使用示例
  • macOS上基于httpd-dav搭建WebDav服务
  • RabbitMq——direct交换器、fanout交换器、 topic交换器
  • wayland(xdg_wm_base) + egl + opengles 渲染使用纹理贴图的旋转 3D 立方体实例(十三)
  • 【NLP笔记】文本分词、清洗和标准化
  • 【学习学习】学习金字塔
  • 前端小白的学习之路(HTML5 二)
  • Fork - 将 GitHub 的某个特定仓库复制到自己的账户下
  • 【数据可视化】使用Python + Gephi,构建中医方剂关系网络图!
  • Acwing.1343 挤牛奶(区间合并or差分)
  • 爬虫基本原理介绍、实现以及问题解决
  • html编辑器
  • 分布式链路追踪(一)SkyWalking(2)使用
  • 橡胶工厂5G智能制造数字孪生可视化平台,推进橡胶工业数字化转型