I am trying to generate QRCode image using QRGen library.
I have imported qrgen-1.0.jar file to my project.
I know this question is duplicate.
I have referred following code by this link
public Bitmap qrBitmapFromString(String qrText){
ByteArrayOutputStream out = QRCode.from(qrText).to(ImageType.PNG).withSize(300, 300).stream();
byte[] data = out.toByteArray();
Bitmap bmp = BitmapFactory.decodeByteArray (data,0,data.length, null);
return bmp;
}
But I am getting the following error.
04-24 11:48:57.138: E/AndroidRuntime(824): FATAL EXCEPTION: main
04-24 11:48:57.138: E/AndroidRuntime(824): java.lang.NoClassDefFoundError: net.glxn.qrgen.QRCode
04-24 11:48:57.138: E/AndroidRuntime(824): at com.example.barcodeexample.QRCodeGeneratorActivity.onCreate(QRCodeGeneratorActivity.java:34)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.Activity.performCreate(Activity.java:5008)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.os.Looper.loop(Looper.java:137)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-24 11:48:57.138: E/AndroidRuntime(824): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 11:48:57.138: E/AndroidRuntime(824): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 11:48:57.138: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-24 11:48:57.138: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-24 11:48:57.138: E/AndroidRuntime(824): at dalvik.system.NativeStart.main(Native Method)
I have imported
import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;
2.0-SNAPSHOT should solve this https://oss.sonatype.org/content/repositories/snapshots/net/glxn/qrgen/android/2.0-SNAPSHOT/
https://github.com/kenglxn/QRGen
Finally I found and following thing working well for me.
Right click on your project
Go into Build Path
Configure Build Path
Go to Order and Export
Check your OnBarcode library
Clean your project
Think this may help some one like me.
Thanks.
Related
I get a project from other developer to fix minor issues in app, when I'm running my app on device I'm getting an error:
15142-15142/com.etripconcept E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.crashlytics.android.answers.Answers
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:224)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:207)
at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:202)
at com.etripconcept.SplashScreenActivity.onCreate(SplashScreenActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5163)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
I'm new in Android development, so it may be stupid question, but Google doesn't say anything about it. I use Android Studio 1.2.2 on Win 8.1
I have this error when using it on pre-lollipop devices
Is there anyway to use android.telephony.SubscriptionManager on pre-lollipop devices?
java.lang.NoClassDefFoundError: android.telephony.SubscriptionManager
at naviramyle.stkplus.utils.SendSMS.init(SendSMS.java:40)
at naviramyle.stkplus.activities.MainActivity.onCreate(MainActivity.java:95)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
There's two android projects I want to merge, one is Main and the other is linked as Library.
But I have some troubles on this line:
Button modificarC;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_menu_calificaciones);
modificarC = (Button) findViewById(R.id.btn_aseso); //HERE
I tried Project Clean... also I have android-support-v4.jar on my dependencies
And this is my trace:
04-24 19:39:52.568: E/AndroidRuntime(9486): FATAL EXCEPTION: main
04-24 19:39:52.568: E/AndroidRuntime(9486): java.lang.NoSuchFieldError: com.utez.sistemas.sam.R$id.btn_aseso
04-24 19:39:52.568: E/AndroidRuntime(9486): at com.utez.sistemas.sam.calificaciones.CalificacionesActivity.onCreate(CalificacionesActivity.java:67)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.Activity.performCreate(Activity.java:4465)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.os.Looper.loop(Looper.java:137)
04-24 19:39:52.568: E/AndroidRuntime(9486): at android.app.ActivityThread.main(ActivityThread.java:4507)
04-24 19:39:52.568: E/AndroidRuntime(9486): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 19:39:52.568: E/AndroidRuntime(9486): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 19:39:52.568: E/AndroidRuntime(9486): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
04-24 19:39:52.568: E/AndroidRuntime(9486): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-24 19:39:52.568: E/AndroidRuntime(9486): at dalvik.system.NativeStart.main(Native Method)
Also here is the layout:
<LinearLayout
style="#style/LoginFormContainer"
android:layout_width="253dp"
android:layout_height="260dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
android:orientation="vertical" >
<Button
android:id="#+id/btn_alta"
android:layout_width="match_parent"
android:layout_height="63dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/btn_altacalif"
android:contentDescription="#string/action_sign_in_register"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:textAlignment="center" />
<Button
android:id="#+id/btn_aseso"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:layout_weight="0.16"
android:background="#drawable/btn_modcalif"
android:contentDescription="#string/action_sign_in_register"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:textAlignment="center" />
</LinearLayout>
I had the same error and it turns out that the resource was overridden.
If you have one project working as a library that declares some id in a given XML file,
then your main project redefines that XML, the original id is gone, but you won't see the error until run time.
In my case, a partner deleted and committed the XML from the project, then added it back in the library project. Subclipse didn't seems to notice that because I was up to date, but the XML was there on the main project.
Well, I am Chinese. My English is not good.
I got the question too.
The solution may be:
The name of xml file is repeated, eg:a.xml is in your library project, at the same time, a.xml is in your main project.
so, please change one of the xml name.
To elaborate on #Moxor's solution, you can either:
Decalare a dummy layout xml, and assign the missing ids to some dummy Views.
Declare the missing ids as resources, the same way you declare a string resource: http://developer.android.com/guide/topics/resources/more-resources.html#Id
Cleaning the project worked for me.
I have an Activity that contains 12 ImageViews. In onCreate method I load 12 photos in these ImageViews using BitmapFactory.decodeStream(...).
When I come to this page and return back for 10 times I get the following Out of Memory Exception.
Why I get this error and how can I release resources to prevent this exception?
Thanks,
04-24 14:41:00.050: D/TextView(7586): Constructor - Got appearance for textColorPrimaryInverse
04-24 14:41:00.050: D/TextView(7586): Constructor -- Got mEditTextBackgroundColor
04-24 14:41:00.130: I/dalvikvm-heap(7586): Clamp target GC heap from 48.878MB to 48.000MB
04-24 14:41:00.130: D/dalvikvm(7586): GC_FOR_ALLOC freed 495K, 2% free 47950K/48775K, paused 44ms
04-24 14:41:00.130: I/dalvikvm-heap(7586): Forcing collection of SoftReferences for 404616-byte allocation
04-24 14:41:00.180: I/dalvikvm-heap(7586): Clamp target GC heap from 48.856MB to 48.000MB
04-24 14:41:00.180: D/dalvikvm(7586): GC_BEFORE_OOM freed 23K, 2% free 47926K/48775K, paused 48ms
04-24 14:41:00.180: E/dalvikvm-heap(7586): Out of memory on a 404616-byte allocation.
04-24 14:41:00.180: I/dalvikvm(7586): "main" prio=5 tid=1 RUNNABLE
04-24 14:41:00.180: I/dalvikvm(7586): | group="main" sCount=0 dsCount=0 obj=0x40a54460 self=0x1ad5828
04-24 14:41:00.180: I/dalvikvm(7586): | sysTid=7586 nice=0 sched=0/0 cgrp=default handle=1074742408
04-24 14:41:00.180: I/dalvikvm(7586): | schedstat=( 14073874000 2242143000 19299 ) utm=1301 stm=106 core=1
04-24 14:41:00.180: I/dalvikvm(7586): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-24 14:41:00.180: I/dalvikvm(7586): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.utils.Utilities.decodeFile(Utilities.java:1220)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.businessLayer.db.BoInvProducts.getProductPhoto(BoInvProducts.java:107)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.ui.ActProductsGallery.loadPageImages(ActProductsGallery.java:729)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.ui.ActProductsGallery.selectItemInGallery(ActProductsGallery.java:611)
04-24 14:41:00.180: I/dalvikvm(7586): at org.mabna.order.ui.ActProductsGallery.onCreate(ActProductsGallery.java:315)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.Activity.performCreate(Activity.java:4465)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-24 14:41:00.180: I/dalvikvm(7586): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 14:41:00.180: I/dalvikvm(7586): at android.os.Looper.loop(Looper.java:137)
04-24 14:41:00.180: I/dalvikvm(7586): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-24 14:41:00.180: I/dalvikvm(7586): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 14:41:00.180: I/dalvikvm(7586): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 14:41:00.180: I/dalvikvm(7586): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-24 14:41:00.180: I/dalvikvm(7586): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-24 14:41:00.180: I/dalvikvm(7586): at dalvik.system.NativeStart.main(Native Method)
04-24 14:41:00.180: D/skia(7586): --- decoder->decode returned false
04-24 14:41:00.180: D/AndroidRuntime(7586): Shutting down VM
04-24 14:41:00.180: W/dalvikvm(7586): threadid=1: thread exiting with uncaught exception (group=0x40a531f8)
04-24 14:41:00.180: E/AndroidRuntime(7586): FATAL EXCEPTION: main
04-24 14:41:00.180: E/AndroidRuntime(7586): java.lang.OutOfMemoryError
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.utils.Utilities.decodeFile(Utilities.java:1220)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.businessLayer.db.BoInvProducts.getProductPhoto(BoInvProducts.java:107)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.ui.ActProductsGallery.loadPageImages(ActProductsGallery.java:729)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.ui.ActProductsGallery.selectItemInGallery(ActProductsGallery.java:611)
04-24 14:41:00.180: E/AndroidRuntime(7586): at org.mabna.order.ui.ActProductsGallery.onCreate(ActProductsGallery.java:315)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.Activity.performCreate(Activity.java:4465)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.os.Looper.loop(Looper.java:137)
04-24 14:41:00.180: E/AndroidRuntime(7586): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-24 14:41:00.180: E/AndroidRuntime(7586): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 14:41:00.180: E/AndroidRuntime(7586): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 14:41:00.180: E/AndroidRuntime(7586): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-24 14:41:00.180: E/AndroidRuntime(7586): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-24 14:41:00.180: E/AndroidRuntime(7586): at dalvik.system.NativeStart.main(Native Method)
04-24 14:41:01.350: I/Process(7586): Sending signal. PID: 7586 SIG: 9
Maybe, decode your images with the nearest size of your ImageViews (see this : Strange out of memory issue while loading an image to a Bitmap object)
Sounds like you are switching activities the wrong way and keeping to many instances in memory. You could try setting FLAG_ACTIVITY_CLEAR_TOP on the intent that opens this activity or take a look at Activity life cycle to figure out where you should load the images.
Have you tried the following?
recycle the bitmaps like this
#Override
public void onDestroy() {
super.onDestroy();
for (int i = 0; i < 5; i++) {
TermElement e = theFiveGaugesInclRPMInPos4[i];
e.background.recycle();
e.background = null;
}
if (DEBUG)
Log.i(this.getClass().getSimpleName(), " <<-"
+ Thread.currentThread().getStackTrace()[2].getMethodName());
}
to reuse the bitmap I define it as static and just init like this:
if (faceTexture == null)
faceTexture = BitmapFactory.decodeResource(getContext()
.getResources(), faceTextureID);
check memory usage with DDMS
Now it doesn't crash anymore.
ps sorry for the formatting - it just doesn't let me format the code correctly anymore - have to reboot? :-(
04-24 13:30:59.312: VERBOSE/RenderScript(6044): RS Thread exited
04-24 13:30:59.320: ERROR/libEGL(6044): call to OpenGL ES API with no current context (logged once per thread)
04-24 13:30:59.335: WARN/WallpaperService(6044): Ignoring updateSurface: destroyed
04-24 13:30:59.335: WARN/WindowManager(108): Window android.view.IWindow$Stub$Proxy#408968d0 is already added
04-24 13:30:59.355: DEBUG/dalvikvm(6083): GC_EXTERNAL_ALLOC freed 23K, 52% free 2598K/5379K, external 1625K/2137K, paused 55ms
04-24 13:30:59.425: DEBUG/GLWallpaperService(6083): onSurfaceDestroyed()
04-24 13:30:59.496: WARN/InputQueue-JNI(6044): Input channel is not initialized.
04-24 13:30:59.515: DEBUG/AndroidRuntime(6044): Shutting down VM
04-24 13:30:59.539: WARN/dalvikvm(6044): threadid=1: thread exiting with uncaught exception (group=0x40015560)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): FATAL EXCEPTION: main
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): java.lang.RuntimeException: Failed to register input channel. Check logs for details.
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.view.InputQueue.nativeRegisterInputChannel(Native Method)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.view.InputQueue.registerInputChannel(InputQueue.java:92)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.service.wallpaper.WallpaperService$Engine.updateSurface(WallpaperService.java:521)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:904)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.os.Looper.loop(Looper.java:123)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at java.lang.reflect.Method.invoke(Method.java:507)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-24 13:30:59.640: ERROR/AndroidRuntime(6044): at dalvik.system.NativeStart.main(Native Method)
I was developing a Livewallpaper which uses a open-source game engine called Andengine(andengine.org), it works fine now except sometimes when user set my Livewallpaper as wall paper, an Exception will be thrown saying "Failed to register input channel. Check logs for details.", but the werid thing is the Livewallpaper still works and did not exit.
Any idea what maybe causing this problem , or how I can fix it?
Sorry, I could only find that the InputQueue "provides a mechanism for an application to receive incoming input events. Currently only usable from native code".
Check the GLSurfaceView class in andengine. That may give you a clue of what is wrong with your wallpaper
You may also want to check why this is happening:
04-24 13:30:59.320: ERROR/libEGL(6044): call to OpenGL ES API with no current context (logged once per thread)