android 集成 unity 3d 错误 Caused by: android.content.res.Resources$NotFoundException: String resource

android 集成 unity 3d 错误

1.资源找不到

java.lang.RuntimeException: 
Unable to start activity ComponentInfo{com.what.mobile.maintenance/com.unity3d.player.UnityPlayerActivity}: 
android.content.res.Resources$NotFoundException: String resource ID #0x0
 Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0

解决方案
在string.xml中添加

  <string name="game_view_content_description"></string>

2.jar包找不到

在项目配置页面添加

 flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        maven { url = "https://dl.bintray.com/kotlin/kotlin-eap" }
        maven { url "https://jitpack.io" }
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

3.UnityPlayer 找不到
修改unityLibrary中的包引入
修改 implementation 为api

implementation类似于“praivte”
api类似于“public”,

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar'])
    implementation(name: 'unity-ads', ext:'aar')
}

4.unity 退出app也退出
修改unityLibrary的manifest

添加 android:process=":unity"启用独立线程
注销 启动设置

<!--            <intent-filter>-->
<!--                <action android:name="android.intent.action.MAIN" />-->
<!--                <category android:name="android.intent.category.LAUNCHER" />-->
<!--            </intent-filter>-->
        <activity
            android:name="com.unity3d.player.UnityPlayerActivity"
            android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection"
            android:hardwareAccelerated="false"
            android:launchMode="singleTask"
            android:screenOrientation="fullSensor"
            android:process=":unity"
            android:theme="@style/UnityThemeSelector">
<!--            <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>
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

魑魅魍魉9527

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值