如何在单个android应用中正确导入多个unity模块,从而避免android studio中不同unity模块之间的名称冲突? [英] How to correctly import multiple unity module in single android app avoiding name conflict between different unity module in android studio?

查看:711
本文介绍了如何在单个android应用中正确导入多个unity模块,从而避免android studio中不同unity模块之间的名称冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经导入了两个unity模块.三角形模块和立方体模块.

I have already imported two unity module . Triangle module and cube module .

 public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, com.labinapp.triangle.UnityPlayerActivity.class);
            startActivity(intent);
        }
    });
    findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, com.labinapp.cube.UnityPlayerActivity.class);
            startActivity(intent);
        }
    });
}}

这是我的成绩文件配置

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.labinapp.demoCode"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true



    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    packagingOptions {
        merge 'lib/armeabi-v7a/libmain.so'
        merge 'lib/x86/libmain.so'
        merge 'lib/armeabi-v7a/libunity.so'
        merge 'lib/x86/libunity.so'
        merge 'lib/armeabi-v7a/libmono.so'
        merge 'lib/x86/libmono.so'
    }


}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:appcompat-v7:25.3.1'

    compile project(':CubeModule')
    compile project(':TriangleModule')
}

我遇到了一些使用合​​并解决的名称冲突

I was facing some name conflicts which i solved by using merge

 packagingOptions {
        merge 'lib/armeabi-v7a/libmain.so'
        merge 'lib/x86/libmain.so'
        merge 'lib/armeabi-v7a/libunity.so'
        merge 'lib/x86/libunity.so'
        merge 'lib/armeabi-v7a/libmono.so'
        merge 'lib/x86/libmono.so'
    }

我的问题是与任何按钮无关,我只单击一个打开的统一项目 这取决于我放置依赖项的顺序

My problem is irrespective of any button i click only one unity project open this depends on order in which i place the dependency

情况1:

   compile project(':CubeModule')
   compile project(':TriangleModule')
   -------------------------------------------------
   Output: CubeModule will be called by default 

情况2:

  compile project(':TriangleModule')
  compile project(':CubeModule')
  ---------------------------------------------------
  Output: TriangleModule will be called by default 

我想合并是否无法正常进行,是否还有其他方法或任何解决方法可以解决此问题,任何建议都会有所帮助.

I guess merge is not working properly is there any other way or any workaround to solve this problem any suggestion will be helpful .

推荐答案

我尝试了多项尝试,但均失败了.似乎不可能.就像试图将两个文件保存在同一文件夹中.但是问题在于两个文件都具有相同的名称.您不能使用两个模块,因为两个模块都带有很少的公共文件,这些文件必须放置在common文件夹中.因此,根据您的依赖关系,android构建系统会选择其中一个并将其打包为apk.

I tried multiple things but failed . It seems impossible . Its like trying to keep two file in the same folder .But the problem is both the file has same name . You cannot use two module as both the modules comes with few common files which has to be placed in common folder .So based on the order of your dependency android build system picks one of them and pack it in apk.

这篇关于如何在单个android应用中正确导入多个unity模块,从而避免android studio中不同unity模块之间的名称冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆