3

So I imported an existing project to eclipse and I have a lot of trouble making it work. The project came with three other library projects:

  • google_play_services-lib

  • CaptureActivity

  • PortraitQR

As soon as I imported the project, I went under 'Java Build Path' and added paths for needed jars: enter image description here

After I successfully added the needed jars, I went on to the libraries. I imported all three needed libraries (that I was given along with the project) and it all went well: enter image description here

After that I also made sure private libraries are checked under the export tab: enter image description here

After I was done importing the project I tried to run it but it crashed instantly. This is the logcat file:

07-17 17:33:36.543: E/AndroidRuntime(25965): FATAL EXCEPTION: main
07-17 17:33:36.543: E/AndroidRuntime(25965): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{si.dvanadva.evanturist/si.dvanadva.evanturist.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-1.apk
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.os.Looper.loop(Looper.java:137)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.ActivityThread.main(ActivityThread.java:5041)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at java.lang.reflect.Method.invokeNative(Native Method)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at java.lang.reflect.Method.invoke(Method.java:511)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at dalvik.system.NativeStart.main(Native Method)
07-17 17:33:36.543: E/AndroidRuntime(25965): Caused by: java.lang.ClassNotFoundException: Didn't find class "si.dvanadva.evanturist.MainActivity" on path: /data/app/si.dvanadva.evanturist-1.apk
07-17 17:33:36.543: E/AndroidRuntime(25965):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-17 17:33:36.543: E/AndroidRuntime(25965):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
07-17 17:33:36.543: E/AndroidRuntime(25965):    ... 11 more

I can see from the logcat file that the problem is 'finding MainActivity class'

Solutions that I have tried so far:

  • Checked if MainActivity is correctly declared in the AndroidManifest file (it is)

  • Checked private libraries under the export tab

  • Deleted bin folder and cleaned project

  • I also tried declaring activities in the AndroidManifest file by not including the package name, like this: android:name=".activityname"

  • Deleted the previous version of the app from my phone and tried compiling again

  • Checked for si.dvanadva.evanturist-1.apk in workspace project but I can't find it (am I missing it?)

  • Did this to set JAVA_HOME but it doesn't work

  • Started a new android application project and copied files in there

Maybe I also tried something else but I forgot to mention it, I've been working on this for quite a while now and I'm running out of things to try. I'll greatly appreciate any kind of help!

Guy
  • 6,414
  • 19
  • 66
  • 136
  • "/data/app/si.dvanadva.evanturist-1.apk" -- This is the path? – Sajal Dutta Jul 17 '13 at 16:02
  • Path for MainActivity.class is different. It's workspace/Evanturist/bin/classes/si/dvanadva/evanturist, is this causing the problem? – Guy Jul 17 '13 at 16:11
  • Shouldn't the path be a directory? si.dvanadva.evanturist-1.apk? Did you check? – Sajal Dutta Jul 17 '13 at 16:13
  • I checked, I can't find si.dvanadva.evanturist-1.apk anywhere, there's not even data/app directory – Guy Jul 17 '13 at 16:15
  • Try putting your file in the `src` directory in your project folder. – Steve P. Jul 17 '13 at 16:19
  • @SteveP. There is, src/si/dvanadva/evanturist/'java files'. I also took the MainActivity.class that I found in bin folder and added it to src/si/dvanadva/evanturist/ (if that's what you meant) but nothing changes. – Guy Jul 17 '13 at 16:24
  • @Matthew hmm.... no idea, then. – Steve P. Jul 17 '13 at 16:25
  • How about you do a search in project for si.dvanadva.evanturist-1.apk? Seems like something referencing to it. – Sajal Dutta Jul 17 '13 at 16:28
  • @SajalDutta I did, opened project in workspace and searched for the file but it didn't find anything – Guy Jul 17 '13 at 16:31
  • One last thing- 1. Go to Project-->Properties. 2. Select Android from lefthand side panel. 3. Uncheck the "Is Library" checkbox. – Sajal Dutta Jul 17 '13 at 16:32
  • @SajalDutta It was never checked in the first place :/ – Guy Jul 17 '13 at 16:34
  • Man!! I hate it when this thing happens with Android and Eclipse. The first thing I do when something like this happens is - clean and rebuild. close the project within eclipse. then exit eclipse. launch eclipse. reopen the project. Usually these steps fix these issues. I really have no other idea. – Sajal Dutta Jul 17 '13 at 16:36
  • @SajalDutta I know, these things are just too frustrating. I tried everything you just said...multiple times. I stopped counting how many times I re-imported the project, re-cleaned it, deleted bin folder etc. etc. I just don't know what to do anymore. Thanks for your help anyway :) – Guy Jul 17 '13 at 16:37
  • This one has a lot of possible solutions. You might wanna see and check other related Q&A. Sorry buddy, wish I could help. http://stackoverflow.com/questions/4778113/android-eclipse-could-not-find-apk – Sajal Dutta Jul 17 '13 at 16:42

1 Answers1

1

I've fairly certain I've seen things like this happen when I haven't imported the code into Eclipse, but have tried to run the library from its downloaded location e.g. for Google Play Game Services:

Import the TypeANumber and BaseGameUtils code from the Android samples into your workspace. To do this in Eclipse: Click File > Import > Android > Existing Android Code into Workspace. Browse to the directory where you downloaded TypeANumber on your development machine and click OK to import the files. Perform the same steps for BaseGameUtils.

(I got this from https://developers.google.com/games/services/android/quickstart)

Also ,although this is not an exact fit for your problem:

Google Player Game Service Error: Can't build the sample game

Community
  • 1
  • 1
IanB
  • 3,489
  • 1
  • 20
  • 24
  • Yes!!!! I can't believe I didn't try this yet! The problem was that added a library project google play services from some other directory, not from downloaded location. Thank you so much!! You deserve the bounty award without a doubt :) – Guy Jul 21 '13 at 00:57
  • You are welcome. I spent quite a lot of time reading the other contributions and going through my notes before I stumbled on the likely cause. – IanB Jul 21 '13 at 10:32
  • @Matthew I think you should award the bounty if he helped solve it (I'm not sure how the expiration works; the system is complicated IMO). I was about to ask you the project to take a look, but looks like it's already solved :) – ADTC Jul 23 '13 at 03:44
  • 1
    @ADTC yes! thank you for reminding me, I wanted to reward the bounty days ago but it wouldn't let me because I had to wait another 20 hours and then I completely forgot about it, sorry about that :) – Guy Jul 24 '13 at 14:04