-7

I want to make a switch tab

Error:

Error:Execution failed for task ':app: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: Error while executing java process with main class com.android.dx.command.Main with arguments {--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}

my main activity :

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];
    }
}

}

what is {--dex --force-jumbo --num-threads=4 --multi-dex --output ! ??????????/

and my gridal is

 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'
}
  • 2
    Please edit your question and post the entire content of your Gradle Console, not just this error message. The real error message may be higher in the Gradle Console output. – CommonsWare Apr 06 '17 at 11:39
  • Please edit your question and make it more readable: correct errors, and remove useless ! or ? – Paolo Forgia Apr 06 '17 at 11:41
  • 1
    Possible duplicate of [Error:Execution failed for task ':app:transformClassesWithDexForDebug'](http://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug) – Phil3992 Apr 06 '17 at 11:46
  • @Prag's シ great job on editing this question. Even too much maybe – Paolo Forgia Apr 06 '17 at 11:49
  • What about increasing the max heap size, e.g. by adding `org.gradle.jvmargs=-Xmx4608M` to `gradle.properties`? – JonasVautherin Apr 06 '17 at 22:12

1 Answers1

-2

try this on your build.gradle (module) file

android {
...
defaultConfig {
    ...
    multiDexEnabled true
    }
}
whd.nsr
  • 850
  • 5
  • 11