83908

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 gradel 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.

Answer1:

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 }

Answer2:

<strong>Remove the below line from your gradle file</strong>

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.+'

<strong>These lines as to be in a class extending Application</strong>

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

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

<strong>For example here:</strong>

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:

<strong>here</strong>:

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

Answer3:

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.

Recommend

  • Parse push notification in iphone
  • Need to loop through an NSMutableArray that is stored inside an array in Parse.com database
  • Add new row in Parse class using Android
  • How to use Parse IOS SDK with REST Push Notifications from Rails Back-end
  • How to set HtmlEditorExtender's content server-side
  • New line in page for no reason
  • MATLAB uitable row generation from user input
  • JSeperator in JToolBar moves the components to right end
  • CKEditor separate the toolbar from the editor
  • Open (overflow) menu programmatically
  • Bokeh custom ToolTips {safe} tag displays nothing
  • Why does CollectionViewSource.GetDefaultView(…) return the wrong CurrentItem from inside a Task thre
  • Change the width of the JQM panels
  • Listview - list item selection and initial setting (custom made items)
  • why fullscreen functionality is not working in chrome?
  • How to Handle Click on Imageview in Custom Listview with image and Textview?
  • Android: How do you create an EditText field in java class
  • I have two activity.I want to Send the data from second activity to previous activity.First activity
  • CloseOptionsMenu doesn't work?
  • Opening two instances of InAppBrowser (_system and _blank) prevents events from triggering
  • Unable to resolve Static method?
  • Replace Fragment with another on back button
  • How to get listview position?
  • How to retrieve information from antrun back to maven?
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • how to avoid repetitive constructor in children
  • Meteor helpers not available in Angular template
  • Java: can you cast Class into a specific interface?
  • Deleting and Updating values from a cusrsor adapter
  • Align navbar back button on right side
  • AES padding and writing the ciphertext to a disk file
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Window Size for Mac application
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Build own AppleScript numerical error handling
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • How to stop GridView from loading again when I press back button?
  • java string with new operator and a literal
  • How to push additional view controllers onto NavigationController but keep the TabBar?