Invalid Parameter in AWS SNS Android App - android

I have integrated AWS SNS API in my Android app. When I open the app on my device, I get this error log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.intap.appme, PID: 20780
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.intap.appme/com.intap.appme.MainActivity}: com.amazonaws.services.sns.model.InvalidParameterException: Invalid parameter: Endpoint (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: e8589d7c-dec8-55e1-807f-cd16c8794be8)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: com.amazonaws.services.sns.model.InvalidParameterException: Invalid parameter: Endpoint (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: e8589d7c-dec8-55e1-807f-cd16c8794be8)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:712)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:388)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
at com.amazonaws.services.sns.AmazonSNSClient.invoke(AmazonSNSClient.java:2262)
at com.amazonaws.services.sns.AmazonSNSClient.subscribe(AmazonSNSClient.java:1256)
at com.amazonaws.mobile.push.PushManager.subscribeToTopic(PushManager.java:251)
at com.intap.appme.MainActivity.onCreate(MainActivity.java:50)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7224) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
The code lines in the log are those lines:
PushManager.java:251 (The whole method)
public void subscribeToTopic(final SnsTopic topic) {
final SubscribeRequest request = new SubscribeRequest();
request.setEndpoint(endpointArn);
request.setTopicArn(topic.getTopicArn());
request.setProtocol(SNS_PROTOCOL_APPLICATION);
/* Line 251 -> */ final SubscribeResult result = sns.subscribe(request);
// update topic and save subscription in shared preferences
final String subscriptionArn = result.getSubscriptionArn();
topic.setSubscriptionArn(subscriptionArn);
sharedPreferences.edit().putString(topic.getTopicArn(), subscriptionArn).apply();
}
MainActivity.java:50
pushManager.subscribeToTopic(pushManager.getDefaultTopic());
I didn't really realized what is the invalid parameter in my app, so you could you please help me?

According to the logs, the invalid parameter is the Endpoint.
To get the endpoint you could do...
final CreatePlatformEndpointRequest request = new CreatePlatformEndpointRequest();
request.setPlatformApplicationArn(platformApplicationArn);
request.setToken(gcmToken);
final CreatePlatformEndpointResult result = snsClient.createPlatformEndpoint(request);
The endpoint can be retrieved by:
result.getEndpointArn();

Related

My app crashes at Startup

I am beginner to android studio. Trying to put some hands on basic API call using Retrofit, for PHP API calls, for login. Sorry please correct me if my way of asking such question might be wrong.
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
prefConfig = new PrefConfig(this);
apiInterface = ApiClient.getApiClient().create(ApiInterface.class); //Here
if (findViewById(R.id.fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
if (prefConfig.readLoginStatus()) {
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new WelcomeFragment()).commit();
} else {
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new LoginFragment()).commit();
}
}
}
Everything goes fine when i comment the line labeled Here.
Error From The Log:
Process: com.example.surya.emorecomender, PID: 9729
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.surya.emorecomender/com.example.surya.emorecomender.MainActivity}: java.lang.IllegalArgumentException: baseUrl must end in /: http://10.0.2.2/database_api
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2984)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: http://10.0.2.2/database_api
at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:513)
at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:456)
at com.example.surya.emorecomender.ApiClient.getApiClient(ApiClient.java:13)
at com.example.surya.emorecomender.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6956)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386) 
This is the most important part:
Process: com.example.surya.emorecomender, PID: 9729
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.surya.emorecomender/com.example.surya.emorecomender.MainActivity}: java.lang.IllegalArgumentException: baseUrl must end in /: http://10.0.2.2/database_api
Copy the java.lang.IllegalArgumentException: baseUrl must end in /: http://10.0.2.2/database_api and google it.

android button causing crash [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 4 years ago.
I am trying to pass login details to another class so that it can be used to login on my MySQL db (using php) but it is crashing giving me the exception: java.lang.IllegalStateException: Could not execute method for android:onClick
stack trace: {StackTraceElement[0]#5692}
658 10752-10752/uk.ac.abertay.contactslist E/AndroidRuntime: FATAL EXCEPTION: main
Process: uk.ac.abertay.contactslist, PID: 10752
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:6294)
at android.view.View$PerformClick.run(View.java:24770)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:6294) 
at android.view.View$PerformClick.run(View.java:24770) 
at android.os.Handler.handleCallback(Handler.java:790) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void uk.ac.abertay.contactslist.Login.Logino(uk.ac.abertay.contactslist.LoginDetails)' on a null object reference
at uk.ac.abertay.contactslist.LoginActivity.Loginbutton(LoginActivity.java:40)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
at android.view.View.performClick(View.java:6294) 
at android.view.View$PerformClick.run(View.java:24770) 
at android.os.Handler.handleCallback(Handler.java:790) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
04-26 15:39:34.761 1384-3633/? I/chatty: uid=1041(audioserver) writer identical 8 lines
this is the code for the button
private Login login;
public void Loginbutton(View v) {
/* Get entered fields data. */
String email = field_email.getText().toString();
String password = field_password.getText().toString();
login.Logino(new LoginDetails(email,password));
}
when debugging it will run this and go back to the button and after that it will give the exception and crash
public class LoginDetails {
public String email = "";
public String password = "";
LoginDetails(String e, String p) {
email = e;
password = p;
}
}
this is the code I'm trying to run with the button above
public void Logino(LoginDetails loginDetails) {
LoginTask task = new LoginTask();
task.execute(loginDetails);
}
From your StackTrace
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void uk.ac.abertay.contactslist.Login.Logino(uk.ac.abertay.contactslist.LoginDetails)
The line login.Logino the object login is null, you have to initialize it.
Obs:Please use Java naming conventions with method names starting with low case char.

Twitter button click crashing app ? Unable to extract the trust manager on okhttp3.internal.Platform$Android

issues is with Twitter button, this is working fine with Android 6 Moto G, while on android 5.0.1 Samsung Note 3 it crashes, on Simulator it works fine too,
However my code for Click is,
TwitterLoginButton twitterLoginButton = (TwitterLoginButton) findViewById(R.id.button_twitter);
twitterLoginButton.setCallback(new Callback<TwitterSession>() {
#Override
public void success(Result<TwitterSession> result) {
Log.d(TAG, "twitterLogin:success" + result);
handleTwitterSession(TwitterAuthProvider.getCredential(
result.data.getAuthToken().token,
result.data.getAuthToken().secret), false);
}
#Override
public void failure(TwitterException exception) {
Log.w(TAG, "twitterLogin:failure", exception);
}
});
twitterLoginButton.setOnClickListener(this);
Issues it is showing is,
java.lang.RuntimeException:Unable to start activity ComponentInfo{com.my.project/com.twitter.sdk.android.core.identity.OAuthActivity}: java.lang.IllegalStateException: Unable to extract the trust manager on okhttp3.internal.Platform$Android#2e0793c7, sslSocketFactory is class crittercism.android.q
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.IllegalStateException: Unable to extract the trust manager on okhttp3.internal.Platform$Android#2e0793c7, sslSocketFactory is class crittercism.android.q
at okhttp3.OkHttpClient.<init>(OkHttpClient.java:187)
at okhttp3.OkHttpClient.<init>(OkHttpClient.java:60)
at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:718)
at com.twitter.sdk.android.core.internal.oauth.OAuthService.<init>(OAuthService.java:56)
at com.twitter.sdk.android.core.internal.oauth.OAuth1aService.<init>(OAuth1aService.java:69)
at com.twitter.sdk.android.core.identity.OAuthActivity.onCreate(OAuthActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) 
at android.app.ActivityThread.access$900(ActivityThread.java:177) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:5942) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
i searched a lot on google but unable to find any helpful, solution.
This is a problem with Crittercism. If updating that doesn't help you'll need to report the bug to them.

Android DynamoDB mapper.save crash

I'm trying to follow the exact DynamoDB example for the Books DB (http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/dynamodb_om.html), but my apps crashes at the
mapper.save(book)
step (it works if I comment out this line).
Please review below and help me figure out what is the problem. Thank you !
Here is the error message:
07-09 20:00:03.652 2458-2458/com.aegisofsoteria.aegisofsoteria D/CognitoCachingCredentialsProvider: Loading credentials from SharedPreferences
07-09 20:00:03.652 2458-2458/com.aegisofsoteria.aegisofsoteria D/CognitoCachingCredentialsProvider: No valid credentials found in SharedPreferences
07-09 20:00:03.673 2458-2458/com.aegisofsoteria.aegisofsoteria D/AndroidRuntime: Shutting down VM
07-09 20:00:03.674 2458-2458/com.aegisofsoteria.aegisofsoteria E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.aegisofsoteria.aegisofsoteria, PID: 2458
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aegisofsoteria.aegisofsoteria/com.aegisofsoteria.aegisofsoteria.SignInActivity}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:245)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
at com.amazonaws.http.UrlHttpClient.writeContentToConnection(UrlHttpClient.java:128)
at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:65)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:356)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:558)
at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getId(AmazonCognitoIdentityClient.java:444)
at com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.getIdentityId(AWSAbstractCognitoIdentityProvider.java:172)
at com.amazonaws.auth.CognitoCredentialsProvider.getIdentityId(CognitoCredentialsProvider.java:340)
at com.amazonaws.auth.CognitoCachingCredentialsProvider.getIdentityId(CognitoCachingCredentialsProvider.java:422)
at com.aegisofsoteria.aegisofsoteria.SignInActivity.BookDBExample(SignInActivity.java:203)
at com.aegisofsoteria.aegisofsoteria.SignInActivity.onStart(SignInActivity.java:124)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6253)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Here is my code:
it is inside
public class SignInActivity extends AppCompatActivity implements
GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {
and the code is as following :
private void BookDBExample(){
// Initialize the Amazon Cognito credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
my_PollID_here, // Identity Pool ID
Regions.US_EAST_1 // Region
);
Toast.makeText(getApplicationContext(), "my ID" + credentialsProvider.getIdentityId(), Toast.LENGTH_SHORT).show();
AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);
DynamoDBMapper mapper = new DynamoDBMapper(ddbClient);
Book book = new Book();
book.setTitle("Great Expectations");
book.setAuthor("Charles Dickens");
book.setPrice(1299);
book.setIsbn("1234567890");
book.setHardCover(false);
try {
mapper.save(book);
} catch (AmazonServiceException ase) {
// The conditional check failed.
Toast.makeText(getApplicationContext(), "ASE:" + ase.getMessage(), Toast.LENGTH_LONG).show();
} catch (AmazonClientException ace){
Toast.makeText(getApplicationContext(), "ACE:" + ace.getMessage(), Toast.LENGTH_LONG).show();
}
}
Two things that may act as hint:
even the error catch can not stop it from crash. Why ?
what's the meaning of "No valid credentials found in SharedPreferences" ? I set up the Cognito, IAM, DB exactly as the AWS example, and the only difference is that I can not find "Attach Role Policy" on IAM. The options are "Attach Policy" or "Create Role Policy". So, I have to use "Create Role Policy" to complete that specific step.
Thanks.
The root cause is NetworkOnMainThreadException. In short, you need to invoke mapper.save() from a background thread, say wrapping it in an AsyncTask.
The exception that is thrown when an application attempts to perform a
networking operation on its main thread.
This is only thrown for applications targeting the Honeycomb SDK or
higher. Applications targeting earlier SDK versions are allowed to do
networking on their main event loop threads, but it's heavily
discouraged. See the document Designing for Responsiveness.

Firebase Android Trying to push child, and then a child below that

Confusing title, I know, but not quite shure how to explain.
Will do my best here.
What I am trying to accomplish is that when user clicks a button, the text from one field is pushed to firebase, then the text from the next field is pushed below that.
Something like this:
-"UID"--"Scripttitle"--"ScriptURL"
Here is the code that I am trying to do this with:
final EditText title = (EditText) rlLayout.findViewById(R.id.inputScriptTitle);
final EditText scripturl = (EditText) rlLayout.findViewById(R.id.inputScriptURL);
final Button button = (Button) rlLayout.findViewById(R.id.submitScriptButton);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
new Firebase("https://theatre-assistant.firebaseio.com/scripts")
.push()
.child("scripttitle")
.setValue(title.getText().toString());
new Firebase("https://theatre-assistant.firebaseio.com/scripts")
.push()
.child(title.getText().toString())
.setValue(scripturl);
I am shure I am just doing some really basic error, but as I am new to programming, I cant really see what that might be.
The error from logcat is:
--------- beginning of crash
04-28 12:26:15.860 4979-4979/com.langaard.theatreassistant E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.langaard.theatreassistant, PID: 4979
Theme: themes:{default=overlay:system, iconPack:system, fontPkg:system, com.android.systemui=overlay:system, com.android.systemui.navbar=overlay:system}
com.firebase.client.FirebaseException: Failed to parse to snapshot
at com.firebase.client.Firebase.setValueInternal(Firebase.java:357)
at com.firebase.client.Firebase.setValue(Firebase.java:248)
at com.langaard.theatreassistant.ManageScriptsFragment$1.onClick(ManageScriptsFragment.java:57)
at android.view.View.performClick(View.java:5204)
at android.view.View$PerformClick.run(View.java:21158)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Conflicting getter definitions for property "importantForAccessibility": android.view.View#isImportantForAccessibility(0 params) vs android.view.View#getImportantForAccessibility(0 params)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2615)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542)
at com.firebase.client.Firebase.setValueInternal(Firebase.java:346)
at com.firebase.client.Firebase.setValue(Firebase.java:248) 
at com.langaard.theatreassistant.ManageScriptsFragment$1.onClick(ManageScriptsFragment.java:57) 
at android.view.View.performClick(View.java:5204) 
at android.view.View$PerformClick.run(View.java:21158) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5461) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Conflicting getter definitions for property "importantForAccessibility": android.view.View#isImportantForAccessibility(0 params) vs android.view.View#getImportantForAccessibility(0 params)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:838)
at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:387)
at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:478)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:97)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542) 
at com.firebase.client.Firebase.setValueInternal(Firebase.java:346) 
at com.firebase.client.Firebase.setValue(Firebase.java:248) 
at com.langaard.theatreassistant.ManageScriptsFragment$1.onClick(ManageScriptsFragment.java:57) 
at android.view.View.performClick(View.java:5204) 
at android.view.View$PerformClick.run(View.java:21158) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5461) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.IllegalArgumentException: Conflicting getter definitions for property "importantForAccessibility": android.view.View#isImportantForAccessibility(0 params) vs android.view.View#getImportantForAccessibility(0 params)
at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getGetter(POJOPropertyBuilder.java:190)
at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getAccessor(POJOPropertyBuilder.java:283)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.removeIgnorableTypes(BeanSerializerFactory.java:678)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanProperties(BeanSerializerFactory.java:557)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanSerializer(BeanSerializerFactory.java:373)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanSerializer(BeanSerializerFactory.java:268)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:213)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:152)
at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:873)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:833)
at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:387) 
at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:478) 
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:97) 
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2593) 
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2542) 
at com.firebase.client.Firebase.setValueInternal(Firebase.java:346) 
at com.firebase.client.Firebase.setValue(Firebase.java:248) 
at com.langaard.theatreassistant.ManageScriptsFragment$1.onClick(ManageScriptsFragment.java:57) 
at android.view.View.performClick(View.java:5204) 
at android.view.View$PerformClick.run(View.java:21158) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5461) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
You can't set view to setValue. scripturl is a EditText.
new Firebase("https://theatre-assistant.firebaseio.com/scripts")
.push()
.child(title.getText().toString())
.setValue(scripturl);
if you use like that you don't see any error.
new Firebase("https://theatre-assistant.firebaseio.com/scripts")
.child(title.getText().toString())
.push()
.setValue(scripturl.getText().toString);
Replace your following code
new Firebase("https://theatre-assistant.firebaseio.com/scripts")
.push()
.child(title.getText().toString())
.setValue(scripturl);
with
new Firebase("https://theatre-assistant.firebaseio.com/scripts")
.push()
.child(title.getText().toString())
.setValue(scripturl.getText().toString());
//because you pass directly object in value method replace and pass data from edit text not object

Categories

Resources