我将一个统一项目导入android studio,因为Android Studio具有该应用程序和菜单,并且应该打开统一游戏。导入unity项目时错误为零,我更新了所有gradle文件和清单。
我正在尝试通过使用按钮的android studio活动打开Unity活动。
错误:
V/FA: onActivityCreated
E/ample.phonedue: Invalid ID 0x00000000.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.phoneduel, PID: 31572
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.phoneduel/com.unity3d.player.UnityPlayerActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:348)
at android.content.res.Resources.getString(Resources.java:441)
at com.unity3d.player.UnityPlayer.GetGlViewContentDescription(Unknown Source:20)
at com.unity3d.player.UnityPlayer.<init>(Unknown Source:214)
at com.unity3d.player.UnityPlayerActivity.onCreate(UnityPlayerActivity.java:41)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process: Sending signal. PID: 31572 SIG: 9
这是调用Unity活动的活动:((不是从Application.Quit()的主要活动原因中进行调用)
package com.example.phoneduel;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import com.unity3d.player.UnityPlayerActivity;
public class middle extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_middle);
Intent intent = new Intent(middle.this, UnityPlayerActivity.class);
startActivity(intent);
}
}
Unity活动是实现到我的项目的AAR文件。
应用程序的build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services' // Google Services plugin
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.phoneduel"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(":unityLibrary-debug")
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.firebase:firebase-core:17.2.3' //Firebase
implementation 'com.google.firebase:firebase-analytics:17.2.3' //Firebase
implementation 'com.google.firebase:firebase-auth:19.3.0' //Firebase
implementation 'com.google.firebase:firebase-database:19.2.1' //Firebase
implementation 'com.google.firebase:firebase-storage:19.1.1' //Firebase
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'org.jetbrains:annotations-java5:15.0'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
}
我找不到修复程序。请帮助我。
阅读了堆栈跟踪信息后,我设法了解到缺少的资源与[]有某种关系
at com.unity3d.player.UnityPlayer.GetGlViewContentDescription(Unknown Source:20)
在google中查找该行后,我只是理解我必须将以下行添加到我的字符串xml值中:]
<string name="game_view_content_description" translatable="false">Game view</string>
Bingo Bongo Bango成功!