PhoneGap BarcodeScanner - ClassNotFound - android

UPDATE 2
I posted an answer that fixes my original problem. See that for more information.
UPDATE
FYI for anyone wondering, in the end I found this: http://github.com/commonsguy/zxingdemo/tree/master Exactly what I needed to get it rolling was a simple demo that worked! Also, thanks to Sean for pointing me in the right direction for my googling.
I am currently trying to build a simple android app that can scan in a barcode. I have looked through multiple tutorials, tried everything to a T, and re-tried and re-tried. Nothing worked. So now I am going to ask for assistance to see where I went wrong.
To list the tutorials I have followed:
https://github.com/phonegap/phonegap-plugins/tree/master/Android/BarcodeScanner
Tried this one first.
http://www.mobiledevelopersolutions.com/home/start/twominutetutorials/tmt3
http://simonmacdonald.blogspot.com/2011/12/installing-barcode-plugin-for-phonegap.html
Plus a couple others, but more or less hit the point to the same process. Some key points, when I add the LibraryProject to my project as a Library, the app will not compile until I create an AndroidManifest.xml I tried using the one found in the LibraryProject and tried creating a bare mininmal one, both would allow to compile, but the app ForceCloses.
When I load up the App and click "Scan" it ForceCloses and in the debug log of LogCat in Eclipse I get:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.myapp/com.google.zxing.client.android.CaptureActivity}: java.lang.ClassNotFoundException:
com.google.com.zxing.client.android.CaptureActivity in loader dalvik.system.PathClassLoader[/data/app/com.myapp-1.apk]
I have tried googling, found a few issues, but no real clear or solid answers, most just point to the tutorials above. I am not sure if the tutorials are just outdated or I am being stupid and am missing something key. Been working on this for a few days now and am at my wits end.
If you can help I would appreciate it. To avoid answers regarding if I have done X or X, here is what I have done.
When I test the application, I do briefly see it trying to load BarcodeScanner, but right after I see that it ForceCloses. I am not sure what I am missing, but for references I will post the code I currently have setup to test:
AndroidManifest.xml - http://pastebin.com/qq9q0ZU7
Plugins.xml - http://pastebin.com/dZ5eKPSU
index.html - http://pastebin.com/wvht4ken
If I need to post any other items let me know.

On Android, it is much much simpler than all this you're trying to do. Throw this out and restart from http://code.google.com/p/zxing/wiki/ScanningViaIntent

Ok, so for anyone having this problem, you have two choices. You can use the ScanningViaIntent, as Sean pointed out. It works great, if you need an example look at CommonsGuy. As for the tutorials I posted above to get this working with PhoneGap, my whole problem was, after I imported the LibraryProject I did not go back through and add the files. I am not sure if a setting in my Eclipse is bad. But I basically just right clicked on the LibraryProject, went to Import -> File Structure -> Library Project's original project path, and loaded all of it back in there.
There is probably something wrong with my Eclipse setup, but yea. I now have the BarcodeScanner plugin for PhoneGap working!

Related

Unable to serialize DslActivationStatus state...Android Studio

If this is a stupid question because I made some terrible mistake, please let me know. Anyways, I just encountered the error and after searching on internet for quite some time, the only similar error that I could find was here But my situation was different.
1). I tried to create a new project from File menu of a previous project.
2). I clicked on Basic Activity and selected mininimum supported API to be 19.
3). I was following this tutorial by Google Developers.
4). I was previously able to successfully build and run from Empty Templates, but now, even they show this same error.
Here are two screenshots: Error & Window
I have tried to restart computer. I have NOT yet tried to download and re-install Android Studio yet. I do not know of any good troubleshooting besides restarting computer; so, if someone wants to share some tips, please be kind enough to do it.
I have not edited or tried to do anything in the automatically created project. I have not editted any file, until I noticed that even #color/primaryColor could not be resolved. So, I went on to look into the res/values/color file and found out that it had no color values in it, instead there was a single line: androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-au. So, I checked further, and found out that many of the automatically generated files had several errors in them.
I am on a Windows 10 machine. Please help, if this question needs to be edited, please let me know. Thanks a lot in advance.

android and gradle - where is the source to the build tasks?

Im trying to figure out how all of android's gradle build tasks work and Ive found the open source project online but digging through it hasnt really shed much light on how each task for a project works.
https://android.googlesource.com/platform/tools/build/+/6d7fd0d2eff092abf1aaf44d03756b24570b390c/gradle/src/main/groovy/com/android/build/gradle?autodive=0%2F%2F%2F%2F
For example I would love to know the exact script it would take to replicate assemble or package and within those I would like to know exactly how to replicate any their child tasks.
Does documentation like this exist anywhere or are developers expected to bang their heads against the computer screen cursing gradle's creators for hours on end while they figure things out on their own.
And please resist the urge to leave a "read the manual" answer unless you leave a link pointing to what I asked for.
I didnt find any documentation which would outline what I really wanted but over the last few days I put it all together from reading Gradles documentation and doing a lot of debugging. It would be nice if in the future there was clear documentation on all the steps in one place so others dont have to spend days to figure things out.

Build failed with an exception - I have tons of questions

After being kicked off of reddit and told to come here, I have some massive questions.
I just started to code, I am trying to release my first app. However, right as I went to submit it, I messed up and everything is crazy now! So I will start at the beginning:
I am making an app that lets you shuffle between ideas on what to build in minecraft. Each tap brings up a new random idea - that is all. It is super simple, I am keeping it that way since it is my first ever app. Now, I had it working, I have every drawing I need for the app. But as I went to submit the app to actually publish it, my .apk file was invalid. I was using the test version, which wasn't allowed to be used in the submission.
I then followed a guide that instructed me to delete my Gradle and .Gradle folders, and apparently android studio was supposed to regenerate them and fix it. Well, that did not happen. What happened was that my 'Android' folder in Android Studio became empty - there is now an app folder with nothing in it, and a Gradle Scripts section with various files that I had not seen before. The majority of my file names are red or orange.
Now, most of if not all of my code is still here. However, it says that the Gradle project sync failed, and I don't know what that means. I can no longer find out the source of these files, as in, there is no manifests or java folder located within my 'Android' heading. I don't know what to do to get it back. I had almost everything taken care of, and I am certain there is a simple way to get it all back. I did not make a VCS at the time, since nobody ever told me I should. Like I said, I am new at making apps. I still have the folder with what appears to be every single bit of code I have made so far.
If you can help me I will be extremely grateful. I have spent almost three weeks working on this, and it would be horrible to see it all go down the drain over one simple mistake.
What about creating a new project and adding your source files, dependencies and resources to it?

How do I properly implement Google Play Service Achievements?

I've been searching for a couple of days, including on this website. What I have found would be useful, however I find that I'm unable to follow them correctly. The questions here have no answers either.
Firstly, when I attempt to add BasegameUtils to the project and import whats needed, Eclipse cannot find them. I don't understand why, because I have imported it and marked it as a library.
This is not helped by the fact that all of the examples have their mainactivity in the folder where the API is. I have already built a full application, and I do not understand where I'm supposed to put mine.
The whole thing is incredibly confusing, and any help, or examples would be lovely.
https://developers.google.com/games/services/android/init
You need to implement baseGameUtils as a library or module depending on your IDE.
public class Main extends BaseGameActivity
And then you call this to unlock the achievement.
Games.Achievements.unlock(getApiClient(), getString(YOUR_ACHIEVEMENT_CODE));
These code samples really helped me first time round.
https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/libraries/BaseGameUtils
The tricky part isn't the code, it's the configuration of your project, make sure to check on the play developer console that you have set up your testing account properly and your achievement codes are correct etc.
Okay, the solution was not simple. The guides seem to favour Android Studio, which implement a script to create BaseGameUtils. The BaseGameUtild that I was importing with Eclipse was not the correct one. I ended up searching for a valid one, and downloaded it.
The second thing I was doing wrong was not updating the SDK to version 20. Now, with the Play Services Lib in the extras, I could import the updated version.
After that, I discovered that gms.; actually must be written as com.google.android.gms..;. With this in line, I am now able to properly implement everything.
Thank you to those who helped.

Android ActionBarCompat Not working from the start

OK, I have been wanting to try the new ActionBarCompat, however, I am not able to run my programs in the emulator.
I have been trying to implement the following: http://antonioleiva.com/actionbarcompat-how-to-use.
and have been stuck on basically the first part. However, working with the author of that content, I was able to get further as I was not adding the project under sdk\extras\android\support\v7\appcompat folder like stated. However, I still think that might be the reason I cannot do this...
More detail can be found here: http://antonioleiva.com/actionbarcompat-how-to-use/#comment-43
Basically, on my first attempt, I just created an Android project, and changed the source code as indicated. Code would not run on the emulator. So I went back to the original code, and that ran on the emulator.
Checked online, found out I might need to add the \extras\android\support\v7\appcompat folder as a library to the project I am building. So I added that and a new android project was created. There were build errors from the start, but I failed at trying to add it as a library to my project, and deleted it....thinking this was way overboard.
After back and forth chats with author of linked website, I found out I had to do that overboard thing.
So I tried the following link to the T: (I cannot post more than 2 links due to low repuation...I will add this link as a comment below)
However, Eclipse would not allow me to add the appcompat Existing Android Project...but it did allow me to add the appcompat Existing (General) Project. I think this may be some of the problems??
Right now, I cannot run the project at all. Eclipse is showing a red exclamation mark on the project folder, but all the code seems to be fine. So I don't know what to do now...I recreated this project several times over, and this one was the one where I knew what to do...and I am still getting problems
So...
I decided to move to Android Studio...updated the IDE, updated the SDK manager to include the new support library, and other things. Created a new project, added to the build.gradle file as shown in the link provided below in the comment. I ran the ant build, and then built the project...tried to import the right things to allow ActionBarActivity, but I could not get that far.
I can import
"android.support.v7.*"
"android.support.vy.R" // and all folders within
but nothing allows me to add ActionBarActivity, and I don't know why.
FYI, I guess I would prefer a solution to Ecplise, as it seems like I actually got somewhere with it.
The best example to use is from here, and I would follow it closely. I had similiar issues when I first came across this. Problem was I misunderstood what I needed to do
http://developer.android.com/tools/support-library/setup.html#libs-with-res

Categories

Resources