【问题标题】:Resource not found when trying to display Unity scene inside side view尝试在侧视图中显示 Unity 场景时找不到资源
【发布时间】:2019-06-03 12:02:52
【问题描述】:

当我尝试在我的 android 应用程序中启动场景时,应用程序崩溃并出现致命异常。

原因:java.lang.RuntimeException:无法启动活动 组件信息{com.nomo3d.seezmy3d/com.unity3d.player.UnityPlayerActivity}: android.content.res.Resources$NotFoundException: 字符串资源 ID #0x0

原因:android.content.res.Resources$NotFoundException:字符串资源 ID #0x0 在 android.content.res.Resources.getText(Resources.java:1184) 在 android.content.res.Resources.getString(Resources.java:1230) 在 com.unity3d.player.UnityPlayer.GetGlViewContentDescription (来源不明) 在 com.unity3d.player.UnityPlayer.(未知来源) 在 com.unity3d.player.UnityPlayerActivity.onCreate (UnityPlayerActivity.java:25) 在 android.app.Activity.performCreate(Activity.java:6977) 在 android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126)

我已经遵循了一些将统一场景导出到 Android 的教程,例如 https://medium.com/@angelhiadefiesta/integrate-a-unity-module-to-a-native-android-app-87644fe899e0

这是导致生成的 UnityPlayerActivity 的活动

class ModelActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activitiy_model)

        val intent = Intent(this, UnityPlayerActivity::class.java)
        startActivity(intent)

        linkMeasurements.setOnClickListener {
            val intent = Intent(this, MeasurementActivity::class.java)
            startActivity(intent)
        }
    }
}

如果我可以让场景显示在我的应用程序中,我可能会解决如何通过拖动等移动 3d 模型来解决问题。

【问题讨论】:

  • 拜托,从错误中非常非常清楚问题是在UnityPlayerActivity 类,而不是ModelActivity
  • 是的,UnityPlayerActivity 是从 Unity 编辑器导出功能自动生成的文件,我应该在这里发布吗?

标签: android unity3d


【解决方案1】:

在我自己的愚蠢中,我认为 Unity 库的包名必须与我的应用程序的包名相同,但将其更改为自己的包名解决了这个问题。我认为错误是应用程序试图解析包名称并且未能这样做,因为它指向自身/对于统一 3d 库为 null。

我将假设这是解决我的特定问题的方法,除非其他人发现我做错了什么,否则库将在没有不同包名称的情况下工作。

【讨论】:

猜你喜欢
  • 2017-10-10
  • 1970-01-01
  • 2023-01-18
  • 2020-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-24
相关资源
最近更新 更多