Joe Rakhimov
Joe Rakhimov

Reputation: 5083

Unable to execute dex: Multiple dex files define & java.lang.NoClassDefFoundError

I am between 2 errors. I dont know what to do. 1st error:

[2014-07-04 15:07:01 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/gdata/util/common/base/Escaper;

[2014-07-04 15:07:01 - MyGov] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/gdata/util/common/base/Escaper;Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;

As suggested here, unchecked Android Private Libraries

enter image description here

I have added all libraries(from AndroidPrivateLibraries) into libs except support-v4-18.0.4.jar library(which is causing to before stated error).

enter image description here

SplashActivity(this activity opens, when application starts) is working fine. But when I tried to open MainActivity following error came out:

java.lang.NoClassDefFoundError: com.globalsolutions.mygov.ui.MainActivity

According to this solution, Android Private Libraries should be checked.

Conclusion:

error#1 makes me to uncheck Android Private libraries
error#2 makes me to re-check Android Private libraries

How to be in this situation? How to solve this problem? Thank you for your valuable time!

UPDATE:

Notification in console for error 1:

[2014-07-04 15:06:48 - MyGov] Dx trouble writing output: already prepared [2014-07-04 15:07:01 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/gdata/util/common/base/Escaper; [2014-07-04 15:07:01 - MyGov] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/gdata/util/common/base/Escaper;

Logcat for error 2:

07-04 15:15:07.679: E/AndroidRuntime(26204): FATAL EXCEPTION: main 07-04 15:15:07.679: E/AndroidRuntime(26204): java.lang.NoClassDefFoundError: com.globalsolutions.mygov.ui.MainActivity 07-04 15:15:07.679: E/AndroidRuntime(26204): at com.globalsolutions.mygov.ui.SplashActivity.startMainActivity(SplashActivity.java:174) 07-04 15:15:07.679: E/AndroidRuntime(26204): at com.globalsolutions.mygov.ui.SplashActivity$6$3.run(SplashActivity.java:275) 07-04 15:15:07.679: E/AndroidRuntime(26204): at android.os.Handler.handleCallback(Handler.java:587) 07-04 15:15:07.679: E/AndroidRuntime(26204): at android.os.Handler.dispatchMessage(Handler.java:92) 07-04 15:15:07.679: E/AndroidRuntime(26204): at android.os.Looper.loop(Looper.java:130) 07-04 15:15:07.679: E/AndroidRuntime(26204): at android.app.ActivityThread.main(ActivityThread.java:3687) 07-04 15:15:07.679: E/AndroidRuntime(26204): at java.lang.reflect.Method.invokeNative(Native Method) 07-04 15:15:07.679: E/AndroidRuntime(26204): at java.lang.reflect.Method.invoke(Method.java:507) 07-04 15:15:07.679: E/AndroidRuntime(26204): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 07-04 15:15:07.679: E/AndroidRuntime(26204): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 07-04 15:15:07.679: E/AndroidRuntime(26204): at dalvik.system.NativeStart.main(Native Method) 07-04 15:15:07.687: E/liblog(1516): failed to call dumpstate 07-04 15:15:07.687: E/(1516): Dumpstate > /data/log/dumpstate_app_error

Main Acitivity code:

package com.globalsolutions.mygov.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.globalsolutions.mygov.Preferences;
import com.globalsolutions.mygov.R;
import com.globalsolutions.mygov.ui.master.MasterWizardActivity;
import com.google.analytics.tracking.android.EasyTracker;

public class MainActivity extends BaseActivity {
    public static final String TAG = MainActivity.class.getSimpleName();

    private LinearLayout warningContainer;
    private TextView warningLabel;
    private Button history;
    private Button appeal;
    private Button call;
    private Button about;
    private Button settings;

    private Preferences prefs;


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

        prefs = Preferences.getInstance(this);
    }


    @Override
    public void onResume() {
        Preferences.refActivity = this;
        super.onResume();
    }


    /**
     * Поиск и инициализация вьюшек
     */
    private void initViews() {
        warningContainer = (LinearLayout) findViewById(R.id.warning);
        warningLabel = (TextView) findViewById(R.id.warningLabel);
        history = (Button) findViewById(R.id.history);
        appeal = (Button) findViewById(R.id.appeal);
        call = (Button) findViewById(R.id.call);
        about = (Button) findViewById(R.id.about);
        settings = (Button) findViewById(R.id.settings);

        Intent intent = getIntent();
        if (intent != null) {
            String status = intent.getStringExtra("status");
            if (!"success".equals(status)) {
                warningContainer.setVisibility(View.VISIBLE);
                history.setEnabled(false);
                appeal.setEnabled(false);
            }
        }
    }

    /**
     * История обращений
     * @param v
     */
    public void historyClick(View v) {
        EasyTracker.getTracker().sendEvent("Главное меню", "Выбран пункт", "История обращений", (long) 0);  
        Intent i = new Intent(getApplicationContext(), RequestsListActivity.class);
        startActivity(i);       
        overridePendingTransition(0, 0);
    }

    /**
     * Подать обращение
     * @param v
     */
    public void appealClick(View v) {
        EasyTracker.getTracker().sendEvent("Главное меню", "Выбран пункт", "Подать обращение", (long) 0);   
        Intent i = new Intent(getApplicationContext(), MasterWizardActivity.class);
        startActivity(i);       
        overridePendingTransition(0, 0);
    }

    /**
     * Позвонить в Call-центр
     * @param v
     */
    public void callClick(View v) {
        EasyTracker.getTracker().sendEvent("Главное меню", "Выбран пункт", "Позвонить в call-центр", (long) 0); 
        dialPhone();
    }

    /**
     * О приложении
     * @param v
     */
    public void aboutClick(View v) {
        EasyTracker.getTracker().sendEvent("Главное меню", "Выбран пункт", "О приложении", (long) 0);   
        Intent intent = new Intent(this, AboutActivity.class);
        startActivity(intent);
    }

    /**
     * Настройки
     * @param v
     */
    public void settingsClick(View v) {
        EasyTracker.getTracker().sendEvent("Главное меню", "Выбран пункт", "Настройки", (long) 0);  
        Intent intent = new Intent(this, PreferencesActivity.class);
        startActivity(intent);
    }

    @Override
    public void onStart() {
      super.onStart();
      EasyTracker.getInstance().activityStart(this);
    }

    @Override
    public void onStop() {
      super.onStop();
      EasyTracker.getInstance().activityStop(this);
    }           
}

Upvotes: 1

Views: 577

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006539

I am between 2 errors. I dont know what to do. 1st error:

This error is fairly self-explanatory. You are including 2+ JARs (or a JAR plus your own Java classes) that have duplicates as noted.

The solution is to determine where the duplicates are coming from (e.g., examining the JARs) and then figuring out which JAR to change or get rid of.

As suggested here, unchecked Android Private Libraries

I have downvoted that answer, as it is rather wrong.

I have added all libraries(from AndroidPrivateLibraries) into libs except support-v4-18.0.4.jar library(which is causing to before stated error).

I am interpreting that sentence to mean "when I add support-v4-18.0.4.jar, I start getting the build error". In that case, you know one of the two JARs that is the source of your problem. Given the class names in conflict, I would guess that the other one is libGoogleAnalyticsV2.jar. You need to either:

  1. Find versions of these JARs that are designed to work together, or

  2. Get rid of one of these JARs.

Upvotes: 1

Related Questions