首页 文章

Unity项目导出到android项目异常(多个dex文件定义Lcom / qualcomm / QCARUnityPlayer / BuildConfig)

提问于
浏览
1

我将项目从unity 4D导出到Android项目但是当我运行它时我发现了这个错误

无法执行dex:多个dex文件定义Lcom / qualcomm / QCARUnityPlayer / BuildConfig;转换为Dalvik格式失败:无法执行dex:多个dex文件定义Lcom / qualcomm / QCARUnityPlayer / BuildConfig;

我确实更改了项目 - >属性以包含Android 4.2.2和Android依赖项,但我仍然无法运行它

1 回答

  • 1

    原因是导出的项目(来自Unity)与QCARUnityPlayer.jar中定义的包名称“com.qualcomm / QCARUnityPlayer”相同 .

    请按照我成功完成的步骤进行操作 .

    1)创建扩展QCARPlayerNativeActivity的活动

    package com.example.unitytest;
    
        import android.os.Bundle;
        import android.util.Log;
    
        import com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity;
    
        public class MyUnityAR extends QCARPlayerNativeActivity{
    
          @Override
          protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            Log.i("Test", "MyUnityAR is running.");
          }
        }
    

    2)修改AndroidManifest.xml

    <manifest xmlns:android =“http://schemas.android.com/apk/res/android”package =“com.example.unitytest”android:versionName =“1.0”android:versionCode =“1”android:installLocation =“preferExternal”> ... <application android:icon =“@ drawable / app_icon”android:label =“@ string / app_name”android:theme =“@ android:style / Theme.NoTitleBar.Fullscreen”> <activity android :name =“ . MyUnityAR”android:label =“@ string / app_name”android:screenOrientation =“portrait”android:configChanges =“fontScale | keyboard | keyboardHidden | locale | mnc | mcc | navigation | orientation | screenLayout | screenSize | smallestScreenSize | uiMode |触摸屏“>

    3)清洁和建造,然后享受 .

    Referencehttps://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse

相关问题