I create an android App which works perfectly in Android 2.3+ all devices. But when i tried to run in 2.2 but it crashed and gives error in log as,
08-16 10:22:41.323: E/dalvikvm(442): Could not find class 'android.os.StrictMode$ThreadPolicy$Builder', referenced from method com.uks.android.mssga.activity.LoginActivity.onCreate
08-16 10:22:41.333: W/dalvikvm(442): VFY: unable to resolve new-instance 39 (Landroid/os/StrictMode$ThreadPolicy$Builder;) in Lcom/uks/android/mssga/activity/LoginActivity;
08-16 10:22:41.333: D/dalvikvm(442): VFY: replacing opcode 0x22 at 0x000a
08-16 10:22:41.333: D/dalvikvm(442): VFY: dead code 0x000c-009a in Lcom/uks/android/mssga/activity/LoginActivity;.onCreate (Landroid/os/Bundle;)V
08-16 10:22:41.423: D/dalvikvm(442): GC_EXTERNAL_ALLOC freed 744 objects / 59064 bytes in 68ms
08-16 10:22:41.483: D/AndroidRuntime(442): Shutting down VM
08-16 10:22:41.483: W/dalvikvm(442): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-16 10:22:41.483: E/AndroidRuntime(442): FATAL EXCEPTION: main
08-16 10:22:41.483: E/AndroidRuntime(442): java.lang.NoClassDefFoundError: android.os.StrictMode$ThreadPolicy$Builder
08-16 10:22:41.483: E/AndroidRuntime(442): at com.uks.android.mssga.activity.LoginActivity.onCreate(LoginActivity.java:58)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.os.Looper.loop(Looper.java:123)
08-16 10:22:41.483: E/AndroidRuntime(442): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-16 10:22:41.483: E/AndroidRuntime(442): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 10:22:41.483: E/AndroidRuntime(442): at java.lang.reflect.Method.invoke(Method.java:521)
08-16 10:22:41.483: E/AndroidRuntime(442): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-16 10:22:41.483: E/AndroidRuntime(442): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-16 10:22:41.483: E/AndroidRuntime(442): at dalvik.system.NativeStart.main(Native Method)
08-16 10:22:44.503: I/Process(442): Sending signal. PID: 442 SIG: 9
Code of LoginActivity is,
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
// Other stuff
}
StrictMode.ThreadPolicy.Builder was introduced in Android 2.3 (API level 9), so attempts to call it in versions earlier than that will fail.
To stop it crashing on 2.2 and earlier you can choose to either:
* Remove the ThreadPolicy code (as it is a developer debug tool to provide warnings of bad things you are doing)
or
* Use reflection to determine if the class exists before making use of it
Related
I have used the following code to upload image in a storage container in azure from android. It throws the error on "// Create the blob client" line. some java.lang.verifyError. I have searched to solve this error but i can't find any solution.
String connectionString = "DefaultEndpointsProtocol=https;AccountName=StorageAccountName;AccountKey=StorageAccountKey"
CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);
// Create the blob client
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Get a reference to a container
// The container name must be lower case
CloudBlobContainer container = blobClient.getContainerReference("images");
// Create the container if it does not exist
container.createIfNotExists();
// Create a permissions object
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Include public access in the permissions object
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
// Set the permissions on the container
container.uploadPermissions(containerPermissions);
// Create or overwrite the "myimage.jpg" blob with contents from a local file
CloudBlockBlob blob = container.getBlockBlobReference("myimageYdolo.jpg");
File source = new File(currImageURI.toString());
blob.upload(new FileInputStream(source), source.length());
Here is the error i have got:
08-16 14:48:15.045: W/dalvikvm(5579): VFY: unable to find exception handler at addr 0x2b
08-16 14:48:15.045: W/dalvikvm(5579): VFY: rejected Lcom/microsoft/azure/storage/ServiceClient;.uploadServicePropertiesImpl (Lcom/microsoft/azure/storage/ServiceProperties;Lcom/microsoft/azure/storage/RequestOptions;Lcom/microsoft/azure/storage/OperationContext;Z)Lcom/microsoft/azure/storage/core/StorageRequest;
08-16 14:48:15.045: W/dalvikvm(5579): VFY: rejecting opcode 0x0d at 0x002b
08-16 14:48:15.045: W/dalvikvm(5579): VFY: rejected Lcom/microsoft/azure/storage/ServiceClient;.uploadServicePropertiesImpl (Lcom/microsoft/azure/storage/ServiceProperties;Lcom/microsoft/azure/storage/RequestOptions;Lcom/microsoft/azure/storage/OperationContext;Z)Lcom/microsoft/azure/storage/core/StorageRequest;
08-16 14:48:15.045: W/dalvikvm(5579): Verifier rejected class Lcom/microsoft/azure/storage/ServiceClient;
08-16 14:48:15.045: D/AndroidRuntime(5579): Shutting down VM
08-16 14:48:15.045: W/dalvikvm(5579): threadid=1: thread exiting with uncaught exception (group=0x41dc6ba8)
08-16 14:48:15.045: E/AndroidRuntime(5579): FATAL EXCEPTION: main
08-16 14:48:15.045: E/AndroidRuntime(5579): Process: com.example.azuretry, PID: 5579
08-16 14:48:15.045: E/AndroidRuntime(5579): java.lang.VerifyError: com/microsoft/azure/storage/ServiceClient
08-16 14:48:15.045: E/AndroidRuntime(5579): at com.microsoft.azure.storage.CloudStorageAccount.createCloudBlobClient(CloudStorageAccount.java:715)
08-16 14:48:15.045: E/AndroidRuntime(5579): at com.example.azuretry.FullscreenActivity.onActivityResult(FullscreenActivity.java:144)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.app.Activity.dispatchActivityResult(Activity.java:5423)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.app.ActivityThread.deliverResults(ActivityThread.java:3347)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3394)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.app.ActivityThread.access$1300(ActivityThread.java:135)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.os.Handler.dispatchMessage(Handler.java:102)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.os.Looper.loop(Looper.java:136)
08-16 14:48:15.045: E/AndroidRuntime(5579): at android.app.ActivityThread.main(ActivityThread.java:5001)
08-16 14:48:15.045: E/AndroidRuntime(5579): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 14:48:15.045: E/AndroidRuntime(5579): at java.lang.reflect.Method.invoke(Method.java:515)
08-16 14:48:15.045: E/AndroidRuntime(5579): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-16 14:48:15.045: E/AndroidRuntime(5579): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-16 14:48:15.045: E/AndroidRuntime(5579): at dalvik.system.NativeStart.main(Native Method)
I had an identical issue, it is most likely the dependency that you are using. Utilizing the library below resolves the issue for Android App development.
Once I used this everything worked.
https://github.com/Azure/azure-storage-android
dependencies {
compile 'com.microsoft.azure.android:azure-storage-android:0.3.0#aar'
}
When running my application it is stooped with null pointer exception.
problem occurring in 4th line
1. Bundle arguments;
2.arguments = getArguments();
3.String viewType=arguments.getString("viewType");
4.if(viewType.equals("weekly"))
{
......
}
Is there any solution? please reply.
08-16 11:31:03.146: E/AndroidRuntime(2675): FATAL EXCEPTION: main
08-16 11:31:03.146: E/AndroidRuntime(2675): java.lang.NullPointerException
08-16 11:31:03.146: E/AndroidRuntime(2675): at com.nv.netmdapp1.ScheduleCreateDialog$1.onClick(ScheduleCreateDialog.java:188)
08-16 11:31:03.146: E/AndroidRuntime(2675): at com.nv.netmdapp1.customViews.CustomAlertDialog$Builder$1.onClick(CustomAlertDialog.java:110)
08-16 11:31:03.146: E/AndroidRuntime(2675): at android.view.View.performClick(View.java:3511)
08-16 11:31:03.146: E/AndroidRuntime(2675): at android.view.View$PerformClick.run(View.java:14109)
08-16 11:31:03.146: E/AndroidRuntime(2675): at android.os.Handler.handleCallback(Handler.java:605)
08-16 11:31:03.146: E/AndroidRuntime(2675): at android.os.Handler.dispatchMessage(Handler.java:92)
08-16 11:31:03.146: E/AndroidRuntime(2675): at android.os.Looper.loop(Looper.java:137)
08-16 11:31:03.146: E/AndroidRuntime(2675): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-16 11:31:03.146: E/AndroidRuntime(2675): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 11:31:03.146: E/AndroidRuntime(2675): at java.lang.reflect.Method.invoke(Method.java:511)
08-16 11:31:03.146: E/AndroidRuntime(2675): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-16 11:31:03.146: E/AndroidRuntime(2675): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-16 11:31:03.146: E/AndroidRuntime(2675): at dalvik.system.NativeStart.main(Native Method)
This is the error log.Any Idea?
4.if(viewType.equals("weekly")) ---> 4.if("weekly".equals(viewType))
I think the problem is you are not properly referencing you bundle variable. Please try the below code:
Bundle arguments = this.getIntent().getExtras();
String viewType=arguments.getString("viewType");
And the rest shall remain the same.
I had updated my android sdk to ics(4.1) as i updated all my old projects which were developped in froyo(2.3) giving me error Like
08-16 19:16:32.284: E/AndroidRuntime(593): FATAL EXCEPTION: main
08-16 19:16:32.284: E/AndroidRuntime(593): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.abc.def/com.abc.def.defMain}: java.lang.ClassNotFoundException: com.abc.def.defMain in loader dalvik.system.PathClassLoader[/data/app/com.abc.def-1.apk]
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.os.Looper.loop(Looper.java:123)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-16 19:16:32.284: E/AndroidRuntime(593): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 19:16:32.284: E/AndroidRuntime(593): at java.lang.reflect.Method.invoke(Method.java:521)
08-16 19:16:32.284: E/AndroidRuntime(593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-16 19:16:32.284: E/AndroidRuntime(593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-16 19:16:32.284: E/AndroidRuntime(593): at dalvik.system.NativeStart.main(Native Method)
08-16 19:16:32.284: E/AndroidRuntime(593): Caused by: java.lang.ClassNotFoundException: com.abc.def.defMain in loader dalvik.system.PathClassLoader[/data/app/com.abc.def-1.apk]
08-16 19:16:32.284: E/AndroidRuntime(593): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
08-16 19:16:32.284: E/AndroidRuntime(593): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
08-16 19:16:32.284: E/AndroidRuntime(593): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
08-16 19:16:32.284: E/AndroidRuntime(593): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
08-16 19:16:32.284: E/AndroidRuntime(593): ... 11 more
before updating sdk all of these were running very without any error please help
I got the solution for this Exception this problem was occuring because i was using external libraries in my project and reffering them in build path but in ics the libraries should be contained in libs directory of project so as i copied the libraries in libs problem get solved
I am developing one android application and in that app I am trying to use Gson Library for Json serialization and de-serialization. I downloaded the library from the following link:-
http://code.google.com/p/google-gson/downloads/list
I included the gson-2.2.2.jar in Java Build Path, but the application crashes at run time when constructing Gson object:-
Gson gson = new Gson();
in logcat I get
07-24 14:53:21.648: E/dalvikvm(488): Could not find class 'com.google.gson.Gson', referenced from method com.google.gson.examples.android.GsonProguardExampleActivity.onCreate
07-24 14:53:21.648: W/dalvikvm(488): VFY: unable to resolve new-instance 10 (Lcom/google/gson/Gson;) in Lcom/google/gson/examples/android/GsonProguardExampleActivity;
07-24 14:53:21.668: D/dalvikvm(488): VFY: replacing opcode 0x22 at 0x0010
07-24 14:53:21.668: D/dalvikvm(488): VFY: dead code 0x0012-007a in Lcom/google/gson/examples/android/GsonProguardExampleActivity;.onCreate (Landroid/os/Bundle;)V
07-24 14:53:21.788: D/AndroidRuntime(488): Shutting down VM
07-24 14:53:21.788: W/dalvikvm(488): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-24 14:53:21.814: E/AndroidRuntime(488): FATAL EXCEPTION: main
07-24 14:53:21.814: E/AndroidRuntime(488): java.lang.NoClassDefFoundError: com.google.gson.Gson
07-24 14:53:21.814: E/AndroidRuntime(488): at com.google.gson.examples.android.GsonProguardExampleActivity.onCreate(GsonProguardExampleActivity.java:40)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.os.Handler.dispatchMessage(Handler.java:99)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.os.Looper.loop(Looper.java:123)
07-24 14:53:21.814: E/AndroidRuntime(488): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-24 14:53:21.814: E/AndroidRuntime(488): at java.lang.reflect.Method.invokeNative(Native Method)
07-24 14:53:21.814: E/AndroidRuntime(488): at java.lang.reflect.Method.invoke(Method.java:521)
07-24 14:53:21.814: E/AndroidRuntime(488): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-24 14:53:21.814: E/AndroidRuntime(488): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-24 14:53:21.814: E/AndroidRuntime(488): at dalvik.system.NativeStart.main(Native Method)
Error is:-
07-24 14:53:21.814: E/AndroidRuntime(488): java.lang.NoClassDefFoundError: com.google.gson.Gson
Also, If I include full source of Gson library as another package in my project it all works well.
What am I doing wrong, is this the correct jar??
Seems you have kept the jar file inside lib folder, rather the name should be changed to libs. This was updated newer revisions of ADT (revision 17 onwards).
I am going to consume web service from android according to this link http://jatin4rise.wordpress.com/2010/10/03/webservicecallfromandroid/ but during run time my android application[AndroidFrontend] shown as
Sorry!.
The application AndroidFrontend(process.org.web.android.frontend)has stopped unexpectedly.Please try later.
And the logcat shown as
LOGCAT
05-14 11:13:55.133: E/dalvikvm(208): Could not find class 'org.ksoap2.serialization.SoapObject', referenced from method org.web.android.frontend.AndroidFrontendActivity.onCreate
05-14 11:13:55.133: W/dalvikvm(208): VFY: unable to resolve new-instance 25 (Lorg/ksoap2/serialization/SoapObject;) in Lorg/web/android/frontend/AndroidFrontendActivity;
05-14 11:13:55.133: D/dalvikvm(208): VFY: replacing opcode 0x22 at 0x0010
05-14 11:13:55.163: D/dalvikvm(208): VFY: dead code 0x0012-0081 in Lorg/web/android/frontend/AndroidFrontendActivity;.onCreate (Landroid/os/Bundle;)V
05-14 11:13:55.224: D/AndroidRuntime(208): Shutting down VM
05-14 11:13:55.224: W/dalvikvm(208): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-14 11:13:55.233: E/AndroidRuntime(208): FATAL EXCEPTION: main
05-14 11:13:55.233: E/AndroidRuntime(208): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
05-14 11:13:55.233: E/AndroidRuntime(208): at org.web.android.frontend.AndroidFrontendActivity.onCreate(AndroidFrontendActivity.java:28)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.os.Handler.dispatchMessage(Handler.java:99)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.os.Looper.loop(Looper.java:123)
05-14 11:13:55.233: E/AndroidRuntime(208): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-14 11:13:55.233: E/AndroidRuntime(208): at java.lang.reflect.Method.invokeNative(Native Method)
05-14 11:13:55.233: E/AndroidRuntime(208): at java.lang.reflect.Method.invoke(Method.java:521)
05-14 11:13:55.233: E/AndroidRuntime(208): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-14 11:13:55.233: E/AndroidRuntime(208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-14 11:13:55.233: E/AndroidRuntime(208): at dalvik.system.NativeStart.main(Native Method)
Guys i have googled these issues as per my knowledge but still seeking for solution.Please let me know the solution if you have.
Thanks for your Precious Time!
The VM is unable to locate the class org.ksoap2.serialization.SoapObject.
Make sure you include the required library (the JAR file) when you build your project.