开发者

Android:Java Unable to find class at runtime from JAR I created

开发者 https://www.devze.com 2023-01-26 03:17 出处:网络
I am working through a facebook-sdk example and trying to utilize the collection of classes as provided as a .JAR.I am relatively new to java and eclipse so I expect I am making some obvious blunder.

I am working through a facebook-sdk example and trying to utilize the collection of classes as provided as a .JAR. I am relatively new to java and eclipse so I expect I am making some obvious blunder.

The issue is that everything seems to compile fine, but when I run the project (using the android emulator) dalvik vm is unable to find the first class I reference from this facebook sdk. ( com/facebook/android/Facebook.class )

As an aside, if I copy the source directly into my project as an additional package everything works fine.

Step 1: I exported the com_facebook_android project as a .JAR file. ( right click project, export, java / jar file ) I choose c:\data\jag\jar as my location to save facebooksdk.jar.

Step 2: I hit properties on the project HelloGoogleMaps, Selected Java Build Path, Libraries, Add External JARS... I the directly selected the c:\data\jag\jar\facebooksdk.jar file.

At this point my project seems to be building just fine ( no errors ).

Android:Java Unable to find class at runtime from JAR I created

Step 3: Debug the project and receive the error:

[2010-11-19 09:05:08 - Example] ActivityManager: Error: Activity class {com.facebook.android/com.facebook.android.Example} does not exist. [2010-11-19 09:05:11 - Example] Starting activity com.facebook.android.Example on device [2010-11-19 09:05:12 - Example] New package not yet registered with the system. Waiting 3 seconds before next attempt.

[2010-11-19 09:05:15 - Ex开发者_如何学Goample] Starting activity com.facebook.android.Example on device

[2010-11-19 09:05:17 - Example] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.facebook.android/.Example }

[2010-11-19 09:05:17 - Example] New package not yet registered with the system. Waiting 3 seconds before next attempt.

[2010-11-19 09:05:20 - Example] Starting activity com.facebook.android.Example on device

[2010-11-19 09:05:21 - Example] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.facebook.android/.Example }

[2010-11-19 09:05:21 - Example] ActivityManager: Error type 3

[2010-11-19 09:05:21 - Example] ActivityManager: Error: Activity class {com.facebook.android/com.facebook.android.Example} does not exist.

SHAWN -- Here are the Android properties for my project.

Android:Java Unable to find class at runtime from JAR I created


When you set the Java Build Path, you only did that: set the build path itself. This caused you to get a successful compile. However, when the .apk file is created, the system does not know that you need external jar files to be bundled along with your source files.

I have not done this before, but it looks like if you right click on your com_facebook_android project and select Properties > Android, you should select the Is Library box. Then go into the Android properties of your main project and click Add... and choose the external library. I believe this will do what you need.

EDIT: This is called a Library Project, and is a fairly new addition to the SDK. You can find more information at http://developer.android.com/guide/developing/eclipse-adt.html#libraryProject


I think you will need to add com.facebook.android as a library into your project...

if i am not wrong this is android facebook sdk.

You can check this link out...

See the instructions over here:

https://github.com/facebook/facebook-android-sdk

Hope it helps you........
Thanksss


ok, really not comfortable about what I did to get me past this.
1) I added the .jar as an external jar.
2) I then also included the .apk file as a .jar (not external jar) I had to select this directly from com_facebook_android/bin/com_facebook_android.apk.

it seems like I am solving this with brute force and something else would be more appropriate.

0

精彩评论

暂无评论...
验证码 换一张
取 消