startPreview failed error

822 views
Skip to first unread message

Thomas

unread,
Dec 6, 2011, 2:28:03 PM12/6/11
to zxing
Hi everyone,

I noticed I get a "startPreview failed" on calling CaptureActivity
from my app every now and then. I don't have any particular pattern to
reproduce it. The crash happens on several models (Thunderbolt 4G,
Samsung Facinate, Galaxy S, DroidX, etc...).


0 java.lang.RuntimeException: Unable to resume activity
{com.mydomain.myapp/com.google.zxing.client.android.CaptureActivity}:
java.lang.RuntimeException: startPreview failed
1 at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:
2485)
2 at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:
2506)
3 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
1064)
4 at android.os.Handler.dispatchMessage(Handler.java:99)
5 at android.os.Looper.loop(Looper.java:150)
6 at android.app.ActivityThread.main(ActivityThread.java:4293)
7 at java.lang.reflect.Method.invokeNative(Native Method)
8 at java.lang.reflect.Method.invoke(Method.java:507)
9 at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
10 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11 at dalvik.system.NativeStart.main(Native Method)
12 Caused by: java.lang.RuntimeException: startPreview failed
13 at android.hardware.Camera.startPreview(Native Method)
14 at
com.google.zxing.client.android.camera.CameraManager.startPreview(CameraManager.java:
192)
15 at
com.google.zxing.client.android.CaptureActivityHandler.<init>(CaptureActivityHandler.java:
66)
16 at
com.google.zxing.client.android.CaptureActivity.initCamera(CaptureActivity.java:
934)
17 at
com.google.zxing.client.android.CaptureActivity.onResume(CaptureActivity.java:
370)
18 at
android.app.Instrumentation.callActivityOnResume(Instrumentation.java:
1242)
19 at android.app.Activity.performResume(Activity.java:4004)
20 at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:
2475)
21 ... 10 more
22 java.lang.RuntimeException: startPreview failed
23 at android.hardware.Camera.startPreview(Native Method)
24 at
com.google.zxing.client.android.camera.CameraManager.startPreview(CameraManager.java:
192)
25 at
com.google.zxing.client.android.CaptureActivityHandler.<init>(CaptureActivityHandler.java:
66)
26 at
com.google.zxing.client.android.CaptureActivity.initCamera(CaptureActivity.java:
934)
27 at
com.google.zxing.client.android.CaptureActivity.onResume(CaptureActivity.java:
370)
28 at
android.app.Instrumentation.callActivityOnResume(Instrumentation.java:
1242)
29 at android.app.Activity.performResume(Activity.java:4004)
30 at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:
2475)
31 at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:
2506)
32 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:
1064)
33 at android.os.Handler.dispatchMessage(Handler.java:99)
34 at android.os.Looper.loop(Looper.java:150)
35 at android.app.ActivityThread.main(ActivityThread.java:4293)
36 at java.lang.reflect.Method.invokeNative(Native Method)
37 at java.lang.reflect.Method.invoke(Method.java:507)
38 at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
39 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
40 at dalvik.system.NativeStart.main(Native Method)

Any idea?

Sean Owen

unread,
Dec 6, 2011, 2:35:04 PM12/6/11
to zx...@googlegroups.com
Is this a stack trace from Barcode Scanner, or your app? 

I see 'com.mydomain.myapp'. So if you are: We absolutely frown on cloning our app like this, so are definitely not going to help you do so.

Thomas

unread,
Dec 6, 2011, 4:00:41 PM12/6/11
to zxing
Hi Sean,

I am actually using the Android part of ZXing as an Android library
project.
Is that something you "frown on"?

DJ

unread,
Dec 6, 2011, 4:17:35 PM12/6/11
to zxing
Hi Sean,

What's the proper way of integrating zxing with another Android app? I
have seen lots of Android apps having a built-in barcode scanner. I
guess quite a few of them use the zxing lib without relying on intents
to launch the barcode scanner as a separate app, thus giving users a
better experience.

On Dec 6, 11:35 am, Sean Owen <sro...@gmail.com> wrote:

Sean Owen

unread,
Dec 6, 2011, 4:22:23 PM12/6/11
to zx...@googlegroups.com
Yes, please do *not* start anything by copying and pasting the app, or using it as a "library". It is not a library. If you start by writing your own app, you're substantially not cloning our work, and are on the right side of things, I think.

DJ

unread,
Dec 6, 2011, 4:53:29 PM12/6/11
to zxing
Thanks, Sean.

But I guess my interpretation, with all due respect, is this is a
personal appeal/preference. With Apache license, to my best
understanding, I don't think I am legally bound to use the project in
a specific way, ie. as library or not.

May I ask why you don't want the project to be used as a library
although this is the best open source and the de facto standard
barcode scanner project out there?

Sean Owen

unread,
Dec 6, 2011, 4:57:53 PM12/6/11
to zx...@googlegroups.com
I can't stop people from doing this, and do not have time to police it -- although I have had two apps taken down from Market under the DMCA, as they appeared to be actual malware, and Google legal went after one particular company for improper use of the code. You can get in trouble if you really try here.

All I can do is speak out on the issue, and all you can do is do the right thing.

Even with the Apache license requirements met, I believe that copying the UI is flirting with violating the project's trademark rights: people think they're using Barcode Scanner when they aren't. There's no reason to get anywhere near that issue.
More to the point, people write in for support thinking it's our app, when it's not. Like right here.

Clueless developers often preserve registered intents from our Manifest in the process of copying, but leave out capability to respond to the intent. Suddenly users are asked to choose if they want to scan / encode using some third party app that will just swallow the API call. Not cool -- that's hurting users.

Open source software is made to be reused, though I think there's a line: would you download Firefox, change the name and release it as "MyBrowser"? Without any meaningful change or improvement, I believe anyone would frown on this. And I think we're close to that situation when you copy and paste the app or treat it as a library.

From a business perspective, are you doing yourself any favors, going this way? if barcode scanning is crucial, you need to "roll your own" in some form to have a differentiated offering. If it's not crucial, Intent integration is much easier and more suitable. Knowledgeable users who recognize the above issue may not approve of your choice. Does it help users? they can't choose a different scanner or receive scanner updates unless you provide them.

The only reason I've heard advanced amounts to, well, it'll improve user experience if scanning is integrated -- which is a fine thought. And I can appreciate that it saves that app developer time and money to copy the app. But that does not answer the points above, so isn't a good reason in itself. So I tend to take a very hard line against anything that seems to have started with "copied android into my project".


I'm aware that some people have thoughtfully integrated the scanner into their app as a secondary feature, gotten the license right, taken care to make their own improvements and customizations. I am not talking about those kinds of people, who have made minimal effort to reuse this in some kind of normal way.

Sean Owen

unread,
Dec 6, 2011, 5:01:00 PM12/6/11
to zx...@googlegroups.com
Yes, the Apache License grants use of all the copyrighted work of the project without limitation, subject to the terms of the license. It does not grant trademark rights, and I think that remains a real issue for cloners.

"What is legal" is the barest minimum standard of behavior in society -- I think it's important to think about higher-level considerations than that!

DJ

unread,
Dec 6, 2011, 5:58:18 PM12/6/11
to zxing
Your points have been well taken. And I agree with you to a very wide
extent. I just did a search using "barcode scanner" and found were
more than 100 apps. I suspect that there is a certain percentage of
those apps being just an "offspring" of zxing with minimal effort to
make any material improvements except for new branding and logo, and
then claiming to make yet anther barcode scanning app. Maybe those are
the people you call "cloner". On this aspect, I agree with you that
they haven't made contribution to the general well-being of Android
ecosystem.

There are another group of developers who do need the barcode scanning
capability as as intrinsic feature in their app. The intention is
never to create another general purpose barcode scanner but use it to
fulfill their business need. To create an optimal user experience,
they have to make the scanning function part of their app with proper
customizations and UI improvements. I think zxing project is a foundry
project enabling people doing that. Also, to my best understanding and
consciousness, in this context, integrating zxing as a library is a
legal, legitimate, ethical, and moral conduct. I hope you wouldn't
find disagreement with me on this belief.

Sean Owen

unread,
Dec 6, 2011, 6:30:02 PM12/6/11
to zx...@googlegroups.com
Coincidentally (?) I just saw this project mentioned on a blog:


This is a pretty good attempt to package up the core scanning from the project in an embeddable way. I support it, myself, as it addresses most of the things that have bothered me about copy-and-paste. This will head off support e-mails, and will prevent unwanted interference with Intents. They're going to change up the UI a little bit too so it's clear it's not quite the stock BS app. It's not a full scanner app, so is not really "cloneable". You can only really use it if you want to add it as a piece to a larger app. That seems like a much more legitimate use case to satisfy. And it's nice that it's also open source, a real intentional value-add repackaging, not just a copy.
Reply all
Reply to author
Forward
0 new messages