Tanveer Ahmad
Tanveer Ahmad

Reputation: 51

Error:Execution failed for task ':app:dexDebug'. Parse.com

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2

My project is not connecting with parse and i have followed all the steps given at parse.com docs. I have tried both new project and existing project to connect it with parse but it is not connecting.

Gradle build finished with 1 error(s) in 4s 824ms.

folloing is my existing project mainActivity.java onCreate code:

@Override
protected void onCreate(Bundle savedInstanceState) {

    Parse.enableLocalDatastore(this);

    Parse.initialize(this, "8R4nAHgdPDJ422tuZyHNE2Hjp3F50y4pSlO9sA1b", "qJomEl0uICAsg7uwiDvxEtWlTWovb3S01N8a3XNr");


    ParseObject testObject = new ParseObject("TestObject");
    testObject.put("foo", "bar");
    testObject.saveInBackground();


    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}

Following is the gradle code for dependencies:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}

Following is the AndroidManifest.xml code for asking/checking about internet connection:

I have also included Parse-1.11.0.jar in my libs.

Upvotes: 2

Views: 157

Answers (3)

Rajesh
Rajesh

Reputation: 2618

Just add this

android {...
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
..}

and add multiDexEnabled true in defaultConfig tag

This is my Application Class public class Example extends MultiDexApplication {

in manifest add like this <application android:name=".Example"

and this is my gradle file

defaultConfig {
    applicationId "com.example"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true // add this
}

Upvotes: 0

johnrao07
johnrao07

Reputation: 6938

Remove the below line from your gradle file

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

because you already have it here

compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'

These lines as to be in a class extending Application

Parse.enableLocalDatastore(this);

Parse.initialize(this, "8R4nAHgdPDJ*****E2Hj0y4pSlO9sA1b", "qJomEl0uICAsg7uwiDvxEtW****3S01N8a3XNr");

And you shouldn't post these code, it's meant to be kept secret.

For example here:

package <your.package.name>;

import android.app.Application;

import com.parse.Parse;
import com.parse.ParseInstallation;

public class ClassNameApplication extends Application {

@Override
public void onCreate() {
    super.onCreate();

    Parse.initialize(this, "2zMz0hbE****r4sMwZJrYtX", "YdK7lFBh5MI6gca*****WPXmKb");
    ParseInstallation.getCurrentInstallation().saveInBackground();
}

}

And add this class name in your manifest file:

here:

<application
    android:name=".ClassNameApplication "
    android:allowBackup="true"
    ......

Upvotes: 2

Emre Akt&#252;rk
Emre Akt&#252;rk

Reputation: 3346

You need to implement Multidex

Also you have some structure problems. The following lines should be called only once. So you need to create a class application and register it in manifest then call your lines onCreate in that application class.. Here is the example..

Parse.enableLocalDatastore(this);

Parse.initialize(this, "YOUR_KEY");

Good luck there.

Upvotes: 0

Related Questions