Android: camera2 crash in capture() - android

I recently started to learn how to use Android camera2, but when I want to take a picture it will crash.
I just know where it crashed but I don't know why it . Does anyone help me to find the problem? thanks.
public void takePicture(){
if(cameraDevice == null){
return ;
}
try {
ImageReader imageReader = ImageReader.newInstance(600, 800, ImageFormat.JPEG, 1);
Surface imageReaderSurface = imageReader.getSurface();
imageReader.setOnImageAvailableListener(new OnImageAvailableListener(), null);
picturesRequestBuilder = cameraDevice.createCaptureRequest(cameraDevice.TEMPLATE_STILL_CAPTURE);
// 将imageReader的surface作为CaptureRequest.Builder的目标
picturesRequestBuilder.addTarget(imageReaderSurface);
// 自动对焦
CaptureRequest captureRequest = picturesRequestBuilder.build();
/* ArrayList<CaptureRequest> captureRequests = new ArrayList<>();
for(int i=0;i<10;i++){
captureRequests.add(captureRequest);
}*/
mCameraCaptureSession.capture(captureRequest, new CaptureCallback(),null);
// mCameraCaptureSession.captureBurst(captureRequests, new CaptureCallback(),null);
}
catch (CameraAccessException e) {
e.printStackTrace();
}
}
My ERROR LOG.
2020-07-20 14:50:23.506 21999-21999/com.example.mycamera E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.mycamera, PID: 21999
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:402)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access$3600(View.java:810)
at android.view.View$PerformClick.run(View.java:28296)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397)
at android.view.View.performClick(View.java:7448) 
at android.view.View.performClickInternal(View.java:7425) 
at android.view.View.access$3600(View.java:810) 
at android.view.View$PerformClick.run(View.java:28296) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
Caused by: java.lang.IllegalArgumentException: CaptureRequest contains unconfigured Input/Output Surface!
at android.hardware.camera2.CaptureRequest.convertSurfaceToStreamId(CaptureRequest.java:738)
at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest(CameraDeviceImpl.java:1191)
at android.hardware.camera2.impl.CameraDeviceImpl.capture(CameraDeviceImpl.java:1051)
at android.hardware.camera2.impl.CameraCaptureSessionImpl.capture(CameraCaptureSessionImpl.java:188)
at com.example.mycamera.MainActivity.takePicture(MainActivity.java:267)
at com.example.mycamera.MainActivity.button(MainActivity.java:69)
at java.lang.reflect.Method.invoke(Native Method) 
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397) 
at android.view.View.performClick(View.java:7448) 
at android.view.View.performClickInternal(View.java:7425) 
at android.view.View.access$3600(View.java:810) 
at android.view.View$PerformClick.run(View.java:28296) 
at android.os.Handler.handleCallback(Handler.java:938) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
2020-07-20 14:50:23.693 21999-21999/? I/Process: Sending signal. PID: 21999 SIG: 9

You can't add a Surface in a CaptureRequest that wasn't part of the Surfaces given to createCaptureSession. In your code, you're creating an ImageReader only once you want to take a picture, and the API is telling you that's not valid:
Caused by: java.lang.IllegalArgumentException: CaptureRequest contains unconfigured Input/Output Surface!
So either set up the ImageReader the same time you're setting up your capture session and include its Surface in the output target list, or create a new capture session in takePicture that includes the newly-created ImageReader.
The latter isn't really recommended, because creating a new capture session will pause preview briefly. So create the ImageReader where you're calling CameraDevice.createCaptureSession, and make sure you keep the ImageReader as part of your enclosing class to avoid it getting garbage-collected.

Related

Cannot connect my android studio application with dropbox, but code executes in Eclipse

I am currently having trouble accessing my dropbox account via android studio. I intend to use dropbox to store photos that the user uploads into my application, then store the dropbox filename inside of the database. I have tested this code on Eclipse, and it works like a charm. But I simply cannot get it to work in android studio. I assume I am missing a step somewhere in android studio... but I cannot find what that step may be. I would appreciate any help.
I have added the following to my build.gradle
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.dropbox.core:dropbox-core-sdk:3.1.1'
I have also added this to my android manifest under the package.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Here is the simple code I am attempting to execute. Note that I have my ACCESS_TOKEN stored as a final string, and it does contain the correct access token (as I mentioned previously, I can run this code (and more) perfectly in eclipse).
public void dropbox(){
DbxRequestConfig config = DbxRequestConfig.newBuilder("myapp").build();
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
FullAccount account = null;
try {
account = client.users().getCurrentAccount(); //This is where my error occurs
} catch (DbxException e) {
e.printStackTrace();
}
Log.d("test",account.getName().getDisplayName());
}
Here is the full error message I get.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sigm.fetchyourpet, PID: 8294
java.lang.IllegalStateException: Could not execute method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:402)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397)
at android.view.View.performClick(View.java:6597) 
at android.view.View.performClickInternal(View.java:6574) 
at android.view.View.access$3100(View.java:778) 
at android.view.View$PerformClick.run(View.java:25885) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6669) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1513)
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:117)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:105)
at java.net.InetAddress.getAllByName(InetAddress.java:1154)
at com.android.okhttp.Dns$1.lookup(Dns.java:39)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83)
at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174)
at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)
at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:127)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:258)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:26)
at com.dropbox.core.http.StandardHttpRequestor.getOutputStream(StandardHttpRequestor.java:132)
at com.dropbox.core.http.StandardHttpRequestor.access$000(StandardHttpRequestor.java:29)
at com.dropbox.core.http.StandardHttpRequestor$Uploader.<init>(StandardHttpRequestor.java:141)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:73)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:29)
at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:275)
at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:146)
at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:330)
at com.dropbox.core.v2.DbxRawClientV2.executeRetriableWithRefresh(DbxRawClientV2.java:351)
at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:137)
at com.dropbox.core.v2.users.DbxUserUsersRequests.getCurrentAccount(DbxUserUsersRequests.java:120)
at com.sigm.fetchyourpet.MainActivity.dropbox(MainActivity.java:63)
at com.sigm.fetchyourpet.MainActivity.signUp(MainActivity.java:174)
at java.lang.reflect.Method.invoke(Native Method) 
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:397) 
at android.view.View.performClick(View.java:6597) 
at android.view.View.performClickInternal(View.java:6574) 
at android.view.View.access$3100(View.java:778) 
at android.view.View$PerformClick.run(View.java:25885) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6669) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
This happens because you are running an HTTP request on the main thread, the easy fix:
Thread thread = new Thread() {
#Override
public void run() {
try {
FullAccount account = client.users().getCurrentAccount();
Log.d("test",account.getName().getDisplayName());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
thread.start();

TransactionTooLargeException when try ro pick image from gallery

val intent = Intent(Intent.ACTION_PICK)
intent.type = "image/*"
val mimeTypes = arrayOf("image/jpeg")
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
startActivityForResult(intent, Config.REQUEST_CODE_PICK_IMAGE)
Here is my code to start activity and choose image.. immediately after selecting some app (Gallery, Google Photos) I get an exception
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 2315820 bytes
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:160)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6694)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.os.TransactionTooLargeException: data parcel size 2315820 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:1129)
at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4027)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:144)
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6694) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
2019-10-10 13:51:27.649 20015-20015/am.lsoft.dev.lsmobilebanking.lsoft E/UncaughtException: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 2315820 bytes
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:160)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6694)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.os.TransactionTooLargeException: data parcel size 2315820 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:1129)
at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4027)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:144)
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6694) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
In my device I have ~3000 photos, so I think the problem is in max parcelable size of 1MB
So question, is there any way to handle this issue
I solved this issue by overriding onSaveInstanceState method
#Override
public void onSaveInstanceState(#NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.clear();
}
It is due to a lot of data in our saved instance bundle

Passing object parameter to extended AsyncTask class

GoodDay everybody.
I wrote a class which extends AsyncTask.
public class InitTransaction extends AsyncTask<TransactionParameters, Void, String> {
#Override
protected String doInBackground(TransactionParameters... params) {
// I do some stuff here
return result;
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
// I do some more stuff
}
}
The class is called with:
TransactionParameters transParams = new TransactionParameters(param1, param2);
InitTransaction initTransaction = new InitTransaction();
initTransaction.execute(transParams);
The problem is that i get an error while passing the object to the task:
[![No method?][1]][1]
Anybody knows where the problem may be?
EDIT
Fixed that problem now I have another one.
As soon as I execute initTransaction.execute(transParams); boom!
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.infovision.elcam_02, PID: 17443
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:389)
at android.view.View.performClick(View.java:6600)
at android.view.View.performClickInternal(View.java:6577)
at android.view.View.access$3100(View.java:781)
at android.view.View$PerformClick.run(View.java:25912)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6923)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384)
at android.view.View.performClick(View.java:6600) 
at android.view.View.performClickInternal(View.java:6577) 
at android.view.View.access$3100(View.java:781) 
at android.view.View$PerformClick.run(View.java:25912) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6923) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) 
Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:828)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.Dialog.show(Dialog.java:329)
at com.infovision.elcam_02.MainActivity$InitTransaction.onPreExecute(MainActivity.java:242)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:648)
at android.os.AsyncTask.execute(AsyncTask.java:595)
at com.infovision.elcam_02.MainActivity.scanCode(MainActivity.java:133)
at java.lang.reflect.Method.invoke(Native Method) 
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:384) 
at android.view.View.performClick(View.java:6600) 
at android.view.View.performClickInternal(View.java:6577) 
at android.view.View.access$3100(View.java:781) 
at android.view.View$PerformClick.run(View.java:25912) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6923) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) 

React-Native: AsyncStorage crashes Android app

I'm writing an App for Android and iOS using react-native.
The iOS version works perfectly but the Android version crashes every time it try to calls a AsyncStorage function.
When my App launches, it checks if there are some user-information stored on the device. It uses this function here:
static async getActiveUser() {
return null;
try {
let value = await AsyncStorage.getItem('#UserStore:activeUser');
if (value !== null){
return JSON.parse(value);
} else {
return null;
}
} catch (error) {
console.log(error);
}
}
As I said before, the iOS version runs perfectly. When I run this code on Android, it crashes at this line:
let value = await AsyncStorage.getItem('#UserStore:activeUser');
The function getActiveUser() gets called inside the componentDidMount function.
I'm searching for hours on a solution!! Can someone help? Thanks a lot!
EDIT:
Error-Log:
07-16 13:16:49.082 7154-7205/com.mblum.cvjm E/unknown:ViewManager: Error while updating prop color
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
07-16 13:16:49.085 7154-7205/com.mblum.cvjm E/unknown:ReactNative: Exception in native call
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'color' in shadow node of type: AndroidTextInput
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:113)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154) 
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58) 
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298) 
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289) 
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374) 
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) 
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:789) 
at android.os.Handler.dispatchMessage(Handler.java:98) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
at android.os.Looper.loop(Looper.java:164) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
at java.lang.Thread.run(Thread.java:764) 
07-16 13:16:49.098 7154-7205/com.mblum.cvjm E/unknown:ViewManager: Error while updating prop color
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
07-16 13:16:49.110 7154-7205/com.mblum.cvjm E/unknown:ReactNative: Exception in native call
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'color' in shadow node of type: AndroidTextInput
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:113)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58)
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298)
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289)
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:159)
at com.facebook.react.uimanager.ReactStylesDiffMap.getInt(ReactStylesDiffMap.java:68)
at com.facebook.react.uimanager.ViewManagersPropertyCache$BoxedIntPropSetter.extractProperty(ViewManagersPropertyCache.java:275)
at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:101)
at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:154) 
at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:58) 
at com.facebook.react.uimanager.ReactShadowNodeImpl.updateProperties(ReactShadowNodeImpl.java:298) 
at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:289) 
at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:364) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374) 
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) 
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:789) 
at android.os.Handler.dispatchMessage(Handler.java:98) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
at android.os.Looper.loop(Looper.java:164) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
at java.lang.Thread.run(Thread.java:764) 
07-16 13:16:49.205 7154-7154/com.mblum.cvjm D/ReactNative: CatalystInstanceImpl.destroy() start
CatalystInstanceImpl.destroy() start
07-16 13:16:49.220 7154-7154/com.mblum.cvjm W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextViewManager
07-16 13:16:49.241 7154-7154/com.mblum.cvjm W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.view.ReactViewManager
07-16 13:16:49.262 7154-7184/com.mblum.cvjm W/ContextImpl: Failed to ensure /dev/null/Android/data/com.mblum.cvjm/cache: 400
07-16 13:16:49.276 7154-7154/com.mblum.cvjm D/AndroidRuntime: Shutting down VM
07-16 13:16:49.278 7154-7154/com.mblum.cvjm E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mblum.cvjm, PID: 7154
java.lang.RuntimeException: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 20
detail: View tag:32
children(4): [
10,13,16,18,
],
viewsToAdd(1): [
[4,20],
],
at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:313)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:33)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:909)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:655)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: com.facebook.react.uimanager.IllegalViewOperationException: Trying to add unknown view tag: 20
detail: View tag:32
children(4): [
10,13,16,18,
],
viewsToAdd(1): [
[4,20],
],
at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:394)
at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:180)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:822)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:929)
at com.facebook.react.uimanager.UIViewOperationQueue.access$2100(UIViewOperationQueue.java:47)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:989)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
... 13 more
your log,
07-16 13:16:49.098 7154-7205/com.mblum.cvjm E/unknown:ViewManager: Error while updating prop color
It is not a problem in your AsyncStorage as the log clearly states that.
some tips:
If you ever think AsyncStorage is not responding well, it usually means you have a wrong data type in there. So always try AsyncStorage.setItem(JSON.stringify('token'));
(just for debugging purposes)

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.

Categories

Resources