0
我已经导入了两个统一模块。三角模块和立方体模块。如何在单个android应用程序中正确导入多个统一模块,避免android studio中不同统一模块之间的名称冲突?
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')
}
我面临一些名称冲突,我通过解决合并
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'
}
我的问题是,不论任何按钮,我点击只有一个统一项目开放 这取决于我所处的依赖关系的顺序
的情况下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
我猜合并工作不正常是有任何其他方式或任何解决方法来解决这个问题的任何建议将会有所帮助。
你有没有找到解决方案?请分享.. – Pranav