How to load native library to android library project - android

First, my project structure is like this:
Android project A --> Android Library project B(contains some native so library) --> Java library C.
how the project A reference the android library project B:
The native library in the android library project B.
how the Android Library project B is library:
The load library code (in the android library project B) :
System.loadLibrary("G72x");
System.loadLibrary("H264Android");
The crash log :
12-27 20:32:51.698: E/AndroidRuntime(11589): FATAL EXCEPTION: Thread-1694
12-27 20:32:51.698: E/AndroidRuntime(11589): java.lang.UnsatisfiedLinkError: InitDecoder
12-27 20:32:51.698: E/AndroidRuntime(11589): at com.xx.xxx.media.H264Decoder.InitDecoder(Native Method)
12-27 20:32:51.698: E/AndroidRuntime(11589): at com.xx.xxx.media.VideoParseThread.getH264(VideoParseThread.java:131)
12-27 20:32:51.698: E/AndroidRuntime(11589): at com.xxx.xxx.media.VideoParseThread.run(VideoParseThread.java:46)
Now when the application run the code that need the so library, it crashed. I have read some answers, but it's still not resolved.
If the all the library b project is in the project A, it worked well.
Any help will be appreciated, this problem drives me crazy, i know it should have one solution, but i don't know how.

First:
Horrible explaination of your project and description of your project structure.
Second:
Make sure it is exported in your build settings.
If you explain more precise, how your structure is, maybe with Screenshots, then I can narrow down my explanation of your mistake
Edit:
Under your "project properties" go into "java build path" and then "order and export".
In here your project needs to be present and marked.

Related

import lib google.android.gms "Could not find class" after updating sdk and google-api

I use google-play-services_lib for one project but after upgrading the google api and sdk,
I get these errors :
05-21 01:57:55.813: E/dalvikvm(22721): Could not find class 'com.google.android.gms.maps.model.LatLng', referenced from method com.eloges.services.GeoLocService$2.onLocationChanged
or this :
05-21 01:57:55.823: E/AndroidRuntime(22721): FATAL EXCEPTION: main
05-21 01:57:55.823: E/AndroidRuntime(22721): java.lang.NoClassDefFoundError: com.google.android.gms.maps.model.CircleOptionsCreator
I read this questions : Issue with Google Maps Android Api v2
but, I tested "google-play-services_lib" on another project and I don't have these errors...
So I concluded that, my error come from my project.
I copied and imported again my project, with right click(Properties>Library >Add etc....) like on another project where it works... but I still have these errors where it can come from?
to "solve" my problem, I created a new project and I copied my java files and xml files.
If someone already had this problem without creating a new project like me..., I'm interested in the solution.
Right-click on the project, under Build Path, select Configure Build Path, select the Order and Export tab and check the relevant lib. Had the same issue with the support library today.

Google Play, Drive API sample code in IntelliJ

I'm following the Google Drive Quickstart on Android instructions and have it working in Eclipse/Kepler. (Juno is just plain dodgy.) However, I'm much more familiar with IntelliJ, so I'm trying to figure out how to install these APIs there in a corresponding manner.
I think I'm getting tripped up on the Drive API part. The Eclipse plugin installs Drive in some special way or place. I added Google-api-services-drive-v2-rev63-1.14.1-beta.jar as a library, same as the others (Google-play-services and the api_java_client). But when I run the application it comes back with
java.lang.NoClassDefFoundError: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential
And I've also gotten a NoClassDefFoundError having to do with Drive$Builder.
In IntelliJ the .jar scopes are set to "Compile" except for the api_java_client libraries which are set to "Provided." None of them have "Export" checked.
Edit: added the module & dependency. I now have a different error:
04-07 00:39:59.766: ERROR/AndroidRuntime(10697): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError:
com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential
at com.fallinghawks.weight4.App.onCreate(App.java:15)
App.java:15 is
credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
I can find the class it's asking for....
Edit 2, after adding libraries per CrazyCoder's instructions:
It compiles, it runs, but I get the following error. I am sure I missed doing something exactly right, I'll try it again in a minute but in the meantime the error is:
04-10 18:02:35.120: ERROR/AndroidRuntime(740): FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.google.api.services.drive.Drive$Builder.build(Drive.java:7301)
at com.example.DriveQuickstart.MyActivity.getDriveService(MyActivity.java:110)
at com.example.DriveQuickstart.MyActivity.onActivityResult(MyActivity.java:49)
at android.app.Activity.dispatchActivityResult(Activity.java:5293)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.google.common.base.Preconditions
at com.google.api.services.drive.Drive.<clinit>(Drive.java:63)
(Hopefully final edit): Yes, I missed something and the beast is working! Thank you so much!!
Now I can use IntelliJ again to work on my "real" project... sooooo much better :)
I went ahead and created IntelliJ IDEA project from scratch, spent about 15 minutes, works just fine.
Download Drive API v2 library and dependencies.
Unpack it somewhere, open readme.html, spend a couple of minutes reading it to understand what jars are needed.
Create a new Android application project in IDEA using a wizard with com.example.drivequickstart package and MainActivity. Use Android 4.2.2 Google APIs as the Platform.
Copy the following jars from the downloaded Drive API library into the project libs folder (you should have learned which jars to use from the step 2):
google-api-client-1.14.1-beta.jar
google-api-client-android-1.14.1-beta.jar
google-http-client-1.14.1-beta.jar
google-http-client-android-1.14.1-beta.jar
google-http-client-gson-1.14.1-beta.jar
google-oauth-client-1.14.1-beta.jar
gson-2.1.jar
jsr305-1.3.9.jar
google-api-services-drive-v2-rev65-1.14.1-beta.jar
Configure a project library from these jars. It can be done by selecting the jars in the Project View, right click, Add as Library..., add this library to the dependencies of your main module.
File | Import Module, browse to ANDROID_SDK\extras\google\google_play_services\libproject\google-play-services_‌​lib, from the existing sources.
Add google-play-services.jar to the dependencies of the imported module, enable the Export checkbox, it should look like this.
Add the module created in step 6 to the dependencies of your main application module.
Copy MainActivity sample code from the Quick Start, step 4 into the MainActivity.java file replacing the old code, edit AndroidManifest.xml as well per the guide.
Build, run in the emulator or on the device to test (don't forget steps 1-2 from the Quick Start).
Or you can just download and use the completely isolated sample that I've created following the above steps (module from the step 6 is included in the project).
It failed for me in the emulator because of some Camera app error (the sample uses Camera and my emulator didn't have it configured), but worked on the Galaxy Nexus device. The sample takes a picture using the device camera and uploads it to your Google Drive.

Can not include source library in project in Intellij IDEA

I've created library project in IDEA with common helpers, which I use in my android applications.
Then I've created android application and included in it my library project like this tutorial said.
Everything seemed okay, code autocomplete worked fine, IDEA recognize that library and all classes and methods in it.
But then I compiled application and saw error "'org.my.helperlibrary' does not exist". However as I said IDEA acts like everything okay before making/launching project.
Here is similar question, but answer is trivial, of course my library has checked "Is Library Project" option but I still can not launch my application which use my library.
Updated:
I've just saw an error: "UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/my/helperlibrary/Helper;" when I removed all usages of library in my android application. So it's just included in my app and not used.
It turned out that I should not add dependency manually in that window
I rather should add new module in my Project window at the left
Then I should choose iml file in the root folder of android library project I want to use
Then I pressed finish and from that point I had two modules in my project
After that when using classes I can press Alt+Enter on any class from SampleLibrary and tell IDEA to add module dependency
Then I could see that IDEA made all I need without me. I can now use SampleLibrary from SampleApplication!
Try to select library project, then click Build -> Compile <your library project name>.
Then back to you project which use this library and click Build -> Rebuild Project.
After that try to run project again.
Hope it helps.

mapviewballoons error

I have recently stumbled into this really neat api for showing callOutbubbles in android MapView. I just have a problem with this api, when i am trying to implement the api following the examples i get this error:
05-02 14:13:19.847: E/AndroidRuntime(11857): java.lang.NoClassDefFoundError: com.readystatesoftware.mapviewballoons.R$layout
And i am getting this warning right before the error:
05-02 14:13:19.838: W/dalvikvm(11857): VFY: unable to resolve static field 590 (balloon_overlay) in Lcom/readystatesoftware/mapviewballoons/R$layout;
Any of you got the same problem ?
thanks
I'm assuming that you have included MapViewBallon project as library (if not then post the details, and also the link of project which you are referring to).
Do following steps:
Clear all your references project library (from ProjectProperties > Android > Library).
Clean your project using Project>Clean.
Add the library projects again.
build and install.

NoClassDefFoundError When Debug Android Engine Connected Android Project

I’m struggling on a problem on my new Android C2DM test project:
Android Engine Connected Android Project.
The problem is:
At LogCat:
04-04 19:35:09.414: E/AndroidRuntime(320): java.lang.NoClassDefFoundError:
com.google.android.c2dm.C2DMessaging
Location at debug window: InvocationTargetException.class
InvocationTargetException.(Thrownable) Line 50
Exception: NoClassDefFoundError
Does any one have any idea what file (and where) I’m missing and how to fix?
Know where/how to get Google API source for debugging?
Really appreciate your inputs.
The problem is that the latest ADT doesn't allow libraries (.jar) in any other folder except "libs" so please rename the folder from "lib" to "libs" and then add the existing three libraries (.jar) again.

Categories

Resources