unfortunately, parseStarterProject has stopped work - java

ParseApplication firstly adding keys to ParseApplication.java is good but after sdk test show error in device "unfortunately, parseStarterProject has stopped work"
this is my ParseApplication.java file
package com.parse.starter;
import android.app.Application;
import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseCrashReporting;
import com.parse.ParseObject;
import com.parse.ParseUser;
public class ParseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
// Initialize Crash Reporting.
ParseCrashReporting.enable(this);
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
// Add your initialization code here
//copy and paste frome parse.com
// Parse.initialize(this, YOUR_APPLICATION_ID, YOUR_CLIENT_KEY);
Parse.initialize(this, "oaXYWiKShMVJ0VqZ52zwVnzpNlC3CKEReLV5wANX", "BiHRJalzAGYgFmh250SDxBxxi8DaIdnsnfunBfpC");
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// Optionally enable public read access.
// defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
}
}
Another, ParseStarterProjectActivity.java file is
package com.parse.starter;
import android.app.Activity;
import android.os.Bundle;
import com.parse.ParseAnalytics;
public class ParseStarterProjectActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ParseAnalytics.trackAppOpenedInBackground(getIntent());
}
}
this is doing in android studio and it's a starting project of parse.com "get start project"

if you are using android studio as a working environment....then what you just need is exit the android studio and then again open it and run your project it solve my problem......I think your will also help likewise.

Remove ParseUser.enableAutomaticUser(); from your code then try again?

Related

The monitor of Android Studio do not show Logs

the monitor of Android Studio do not show Logs.
I have the code:
package com.nv.threadpassdata;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import android.content.Context;
import com.google.android.material.snackbar.Snackbar;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "START";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i(TAG, "Start");
}
}
And the monitor shows NOTHING:
In settings the Log ticks are ON.
I do not use emulator. Instead of emulator I connect my Phone (HUAWEI MYA-L41)
What is the problem? Can anybody find?
Thanks,
Nickolas
Try to do on of the following:
File>Invalidate Caches and Restart
Build>Clean Project then Build>Rebuild Project

Why my implementation of the Dropbox API in Android Studio doesn't work?

I have written this code in Android Studio but as soon as I launch the app it crashes.
package PACKAGE_NAME;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.dropbox.core.DbxException;
import com.dropbox.core.DbxRequestConfig;
import com.dropbox.core.v2.DbxClientV2;
public class MainActivity extends AppCompatActivity {
private static final String ACCESS_TOKEN = MY_ACCESS_TOKEN;
DbxRequestConfig config = DbxRequestConfig.newBuilder("db").build();
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
((TextView)findViewById(R.id.textView)).setText(client.users().getCurrentAccount().getName().getDisplayName());
} catch (DbxException e) {
e.printStackTrace();
}
}
}
I would like to connect to my Dropbox account via access token, I did a similar thing in python and it actually worked.
Someone who knows why this happens?

java.lang.ExceptionInIntilizerError in main

My app crashes straight away with an exception
Here is the code of my main activity
package com.example.orientation;
import android.os.Bundle;
import android.app.FragmentManager;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
public class MainActivity extends ActionBarActivity implements myList.Communication {
myList listFragment;
Details detailsFragment;
FragmentManager manager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
manager=getFragmentManager();
listFragment = (myList) manager.findFragmentById(R.id.listFragment);
listFragment.setCommunicator(this);
}
#Override
public void respond(int index) {
detailsFragment = (Details) manager.findFragmentById(R.id.detailFragment);
if (detailsFragment!=null && detailsFragment.isVisible()) {
detailsFragment.changeData(index);
}else{
Intent intent = new Intent(this,DetailActity.class);
intent.putExtra("index",index);
startActivity(intent);
}
}
}
I tried reading documentation but could not get how to solve this. Any help will be appreciated. Thank You.
If you have only added android support jar, you must add the whole Appcompat project to your workspace:
right click -> IMport -> Android -> Project from Existing Source
Then go to SDK Folder where you installed and find extras/android/support/v7/appcompat
and add this whole Library.
It seems like you are missing resources needed for ActionBarActivity

tried exporting my app the process failed and ended up giving me errors in my code

hey i am new to android development. i tried exporting my app the process failed because of some minor errors and then i got errors all over my code. it was working perfectly fine with no errors before attempting to export.
check these two pics of the xml files where the errors popped up
main activity file: http://postimg.org/image/4gwdipnap/
second activity file: http://postimg.org/image/vuy1ryba3/
I didn't have any of these errors before trying to export the project.
heres the code for both of the files
main activity page
package youngadults.camden;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
public class FrontPage extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.front_page);
findViewById(R.id.uyounadults).setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent myIntent = new Intent(FrontPage.this, youngadultsp.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(myIntent);
}
});
}
}
second activity page
package youngadults.camden;
import android.app.Activity;
import android.os.Bundle;
public class youngadultsp extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.youngadultsp_1);
}
}
You need to set Android API level, do you use Android Studio or Eclipse?
For Eclipse edit your Manifest file (19 is example):
<uses-sdk android:minSdkVersion="19" />
For Android Studio
Right click the App directory
Select "Open Module Setting" at the bottom
Under Modules select app
Set 'Compile Sdk version' as you want

My Junit test doesn't run

I'm new to Java, Android and JUnit. I want to learn how to write JUnit tests for an Android application. To that end, I have a very simple Android app (2 activities, 2 buttons, each button goes to the other activity). I want to test the button. This app runs fine on my phone when it's plugged in. I've been looking at the samples provided in the SDK, and I am trying to emulate them.
My problem is that when I right-click on my test project, and choose Run As -> Android JUnit test, nothing happens. I don't know why.
My test code.
package com.example.twoactivities.test;
import android.app.Instrumentation.ActivityMonitor;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;
import android.widget.Button;
import com.example.twoactivities.MainActivity;
import com.example.twoactivities.MainActivity2;
public class ClickButton extends ActivityInstrumentationTestCase2<MainActivity> {
private Button mButton2;
private long TIMEOUT_IN_MS = 100000;
public ClickButton() {
super(MainActivity.class);
}
#Override
protected void setUp() throws Exception {
super.setUp();
final MainActivity a = getActivity();
// ensure a valid handle to the activity has been returned
assertNotNull(a);
}
#SmallTest
public void click(){
// Set up an ActivityMonitor
ActivityMonitor activityMonitor = getInstrumentation().addMonitor(MainActivity2.class.getName(), null, false);
//check if button is enabled
assertTrue("button is enabled", mButton2.isEnabled());
//click button
mButton2.performClick();
MainActivity2 MainActivity2 = (MainActivity2) activityMonitor.waitForActivityWithTimeout(TIMEOUT_IN_MS );
assertNotNull("MainActivity2 is null", MainActivity2);
// assertEquals("Monitor for MainActivity2 has not been called", 1, activityMonitor.getHits());
// assertEquals("Activity is of wrong type", MainActivity2.class, MainActivity2.getClass());
// Remove the ActivityMonitor
getInstrumentation().removeMonitor(activityMonitor);
}
// public void tearDown() {
// }
}
(I know it's really simple, but I'm just trying to get the basics down.)
My application.
package com.example.twoactivities;
import com.example.twoactivities.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void activity2(View view){
Intent intent = new Intent(this,com.example.twoactivities.MainActivity2.class);
startActivity(intent);
}
}
Activity 2 of my application.
package com.example.twoactivities;
import com.example.twoactivities.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
public class MainActivity2 extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}
public void activity1(View view){
Intent intent = new Intent(this,com.example.twoactivities.MainActivity.class);
startActivity(intent);
}
}
Any ideas why my test class doesn't run?
Thanks,
Stephanie
You have to right click on the test itself, not the project.
According to documentation Android testing API supports JUnit 3 code style, but not JUnit 4. Try naming your test method testClick

Categories