Exception in Release Mode due to ZipFile - android

I'm using a code snippet to access a Zip File containing APK file . It works fine in Debug Mode, but, throws Exception in Release Mode.
ZipFile zip = new ZipFile(file);
ZipEntry mft = zip.getEntry("AndroidManifest.xml");
is = zip.getInputStream(mft);
It doesn't make any issue if released in Debug Mode. But, in Release Mode, app gets crashed.
W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x418c6c08)
************ 29072016 ************
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vxeed.xnap/com.vxeed.xnap.forms.MainMenu}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.vxeed.xnap.common.ay.a(Unknown Source)
at com.vxeed.xnap.forms.MainMenu.onCreate(Unknown Source)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
If I get rid of this method, it works fine. Do I need to add anything extra in proguard-rules? Please advise. Thanks in advance

Related

Error on phone "unfortunately 'app name' has stopped" (OutOfMemoryError)

My newly made app is giving error on phone:
"unfortunately 'app name' has stopped"
below is my logcat error
07-27 19:35:58.261 7466-7466/com.example.android.happybirthday E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.happybirthday, PID: 7466
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:683)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:513)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:889)
at android.content.res.Resources.loadDrawable(Resources.java:3436)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.<init>(ImageView.java:133)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:57)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:53)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:102)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:972)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1030)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.example.android.happybirthday.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
try to put this into the application tag of your manifest:
android:largeHeap="true"

Default Android app crashes on AVD running anything less than Lollipop

I seem to be having a bit of an issue getting an app to run on an AVD that is running anything less than Lollipop. I set the minimum SDK to Jellybean (4.2) yet whenever I try to run it on an AVD with either Jellybean or Kit Kat, it crashes.
I've seen other people here having this issue and it could be resolved with multidex but I am having this issue even with applications that only consist of the default "Hello world" content when you first create a blank activity.
I created a demo project with a blank activity and changed absolutely nothing to it, yet it still crashes.
This is the error code it gives:
07-20 22:17:44.161 2698-2698/com.demo.demo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.demo.demo, PID: 2698
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.demo.demo/com.demo.demo.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
at android.content.res.Resources.loadDrawable(Resources.java:2101)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
at com.demo.demo.MainActivity.onCreate(MainActivity.java:10)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
at android.content.res.Resources.loadDrawable(Resources.java:2097)
at android.content.res.Resources.getDrawable(Resources.java:700) 
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354) 
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193) 
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181) 
at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689) 
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186) 
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) 
at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83) 
at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146) 
at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28) 
at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41) 
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193) 
at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173) 
at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511) 
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 
at com.demo.demo.MainActivity.onCreate(MainActivity.java:10) 
at android.app.Activity.performCreate(Activity.java:5231) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.access$800(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
Looking at it I thought that it might be an issue with the theme of the app but changing that doesn't change anything. I'm very new to Android so I'm just a bit unsure of what this could be.
Any advice would be greatly appreciated.
Edit: I should probably also add that I'm using Android Studio in case that makes a difference.
Add to you Gradle within the defaultConfig
vectorDrawables.useSupportLibrary = true
Also make sure your Activity extends AppCompatActivity, and not plain Activity.

I can't use sharedpreferences without android app crashing

SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = pref.edit();
float highscore = pref.getFloat("highscore",0.0f);
As soon as I enter the activity that uses this part, the app crashes. According to logcat, that first line in this code block gives a nullpointerException. If it's important, this part comes after OnCreate, and I'm using Android Studio.
Logcat:FATAL EXCEPTION: main
Process: com.nonexistent.rs.guessthenumber, PID: 4388
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nonexistent.rs.guessthenumber/com.nonexistent.rs.guessthenumber.main}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:185)
at com.nonexistent.rs.guessthenumber.main.<init>(main.java:141)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
07-14 10:17:04.616 6030-6030/com.nonexistent.rs.guessthenumber E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nonexistent.rs.guessthenumber, PID: 6030
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nonexistent.rs.guessthenumber/com.nonexistent.rs.guessthenumber.main}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:185)
at android.preference.PreferenceManager.getDefaultSharedPreferences(PreferenceManager.java:369)
at com.nonexistent.rs.guessthenumber.main.<init>(main.java:142)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Reason:
May be you are using this code from a fragment or on other thread. You Need to pass a activity context reference as an argument. The argument this is the problem.
Solution:
You need to pass the activity / context as the argument
SharedPreferences pref =
PreferenceManager.getDefaultSharedPreferences(Your_Activity_Name.this);
I solved this myself a long time ago, but then I realized that this was left unanswered. Apparently, I'm supposed to put all SharedPrefences code in onCreate.

NoClassDefFoundError when Sending email wiith the library: mysql-connector-java-5.0.8-bin

I have an issue in my android application when I try to send an email. If I use the library for send mail(mail.jar, activation.jar, additionnal.jar) and connector for android: mysql-connector-java-5.0.8-bin.jar throws an error:
java.lang.NoClassDefFoundError: com.example.timis.util.sendMails.Sendmail$1
at com.example.timis.util.sendMails.Sendmail.sendMail(Sendmail.java:31)
at com.example.timis.tour.LoginActivity.onCreate(LoginActivity.java:189)
at android.app.Activity.performCreate(Activity.java:5458)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
If I remove mysql-connector-java-5.0.8-bin it works well.

Please help i have get following error,when i try to integrate twitter in my app

java.lang.NoClassDefFoundError: org.brickred.socialauth.SocialAuthManager
at org.brickred.socialauth.android.SocialAuthAdapter.authorize(SocialAuthAdapter.java:544)
at com.example.koolkrew.MainActivity.initSocialAdapter(MainActivity.java:90)
at com.example.koolkrew.MainActivity.bindWidgetEvents(MainActivity.java:55)
at com.example.koolkrew.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Download socialauth-android.jar from following link: http://www.java2s.com/Code/JarDownload/socialauth/socialauth-android.jar.zip
And if still getting the same error then You just need to define a new activity in AndroidManifest.xml file.
Put the below code inside ---- tag of your manifest file.
<uses-library android:name="org.brickred.socialauth.android.SocialAuthAdapter" />

Categories

Resources