我想制作一个切换标签
错误:
错误:任务执行失败 ':应用程序:transformClassesWithDexForDebug'。 com.android.build.api.transform.TransformException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException:使用带有参数的主类com.android.dx.command.Main执行java进程时出错{--dex --force-jumbo --num-threads = 4 --multi-dex --output C:\ Users \ ALi \ AndroidStudioProjects \ Bwin \ app \ build \ intermediates \ transforms \ dex \ debug \ folders \ 1000 \ 5 \ slice_1 C:\ Users \ ALi \ AndroidStudioProjects \ Bwin \ app \ build \ intermediates \ transforms \ instantRunSlicer \ debug \ folders \ 1 \ 5 \ slice_1}
我的主要活动:
public class MainActivity extends AppCompatActivity {
ViewPager viewPager;
TabLayout tabLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewPager = (ViewPager) findViewById(R.id.viewpager);
tabLayout = (TabLayout) findViewById(R.id.tablayout);
tabLayout.setupWithViewPager(viewPager);
viewPager.setAdapter(new customadapter(getSupportFragmentManager(),getApplicationContext()));
}
private class customadapter extends FragmentPagerAdapter {
private String item[] = {"page1","page2"};
public customadapter(FragmentManager supportFragmentManager, Context applicationContext) {
super(supportFragmentManager);
}
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
return new fragment1();
case 1:
return new fragment2();
default:return null;
}
}
@Override
public int getCount() {
return item.length;
}
@Override
public CharSequence getPageTitle(int position) {
return item[position];
}
}
}
什么是{--dex --force-jumbo --num-threads = 4 --multi-dex --output! ?????????? /
我的网格是
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
multiDexEnabled true
applicationId "com.s.i.m.freebet.bwin"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
}
答案 0 :(得分:-2)
在build.gradle(模块)文件中尝试此操作
android {
...
defaultConfig {
...
multiDexEnabled true
}
}