I'm working on an android app which uses facebook sdk and the android-simple-facebook library (a "wrapper" library).
The android-simple-facebook lib depends on facebook sdk and my app depends on android-simple-facebook.
I created a jar file (via Artificats in IDEA's Module Settings) containing the compile output of both libraries.
I need the facebook sdk compile output too because I have this reference to facebook's LoginActivity in my AndroidManifest.xml:
<activity
android:name="com.facebook.LoginActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
The reason I created this jar file is that i'm not the only developer working on this project, and I don't want anyone who develops this project to reference 2 libraries. I just want them to work with a static jar I create.
So the jar get's created and everything is fine, no compile errors, but when calling the login() function, which starts facebook's LoginActivity I guess, I get the following exception:
Unable to resume activity {com.example.example/com.facebook.LoginActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f02000a
What I suspect is, LoginActivity.onCreate() executes setContentView(R.layout.com_facebook_login_activity_layout) but I don't see any resources (the layout files for example) inside the jar file.
Any help on how to accomplish my goal of having one working jar will be greatly appreciated!
Some additional info about my setup:
My libs folder and jar's contents:
Artificat settings:
What I ended up doing is adding the libraries (repositories) as sub-modules in git and as modules in my project.
So, I don't know if the answer is really "No, it can't be done", but that's how I solved the problem for now.
Hope it helps anyone.
Related
I wanted to test the .java Plugin class which will help in the exposure of the methods that are available in the integrated .aar SDK. I have created the cordova project and integrated the .aar SDK file. I added the plugin class to src directory. I referred to http://moduscreate.com/plugin-authoring-cordova-6-ios-android/ for the changes that has to be done in the .js and .html files. I added the feature in config.xml (app's res directory). But everytime I run the command cordova build android the config.xml file gets reset. But If I run the app using Android studio it works fine. Why is it so?
If you build through Command line, every time it will replace your platform config.xml file with config.xml file(exist in your project folder). If you want to build an app with your custom plugin then you should add a plugin through cli(it wont accept manual installation).
Please follow this link for more details.
Edit
Just saw the other answer and it is not much different from mine. Should have checked before I answered.
Original
The config.xml in platform folders get replaced with the config.xml in the projects root folder everytime you build. Either change this one or add plugins through the command line and Cordova will edit it for you.
I Have a AAR file , in Mobile First Project I have to do a call which should open the activity from AAR file . How to do that? I have a Eclipse with MFP 7.0 .
As suggested by Andrew in the comments, there is nothing specifically in the MobileFirst framework that will help you here. You will need to write native code in order to use whatever is inside the AAR file.
Create a Cordova plug-in as described in the following tutorial in order to access the AAR file and use its provided functionality: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/adding-native-functionality/android-adding-native-functionality-hybrid-application-apache-cordova-plugin/
However I believe this may also require handling it via Gradle: cordova plugin add external .aar file (not .jar)
Another suggestion that comes up is to extract the .jar file that is inside the AAR file and then that's much easier to handle...
I'm attempting to build an android app in Android Studio that integrates the jReddit Java Wrapper. I've cloned the git repository, added a build.gradle file, added the proper dependencies and referenced the jReddit module in my android app's project structure.
I'm able to create any of the objects in the jReddit library, but I cannot use any of the methods for those objects. I get a "Cannot resolve symbol 'xxx'" when I try to use a method. Currently the project structure is set up like below:
Project Title
App
src
libs
jReddit
src
libs
So the app's code is in the src folder and any .jar dependencies are in the libs folder. The jReddit project has in it's build.gradle file "apply plugin: 'java'" and is listed as a dependency in the app's build.gradle file. Finally the libs folder in the jReddit project tree has the jars that IT depends on (which are also referenced in its respective build gradle).
Ultimately, everything compiles nicely, is imported nicely (in the app source code), there are no errors instantiating a new object from the jReddit library, but when I go to do anything with that object, Android Studio cannot find any methods. See the screen shots below to see what I'm talking about:
http://i.imgur.com/Hm09S3W.png
I'm completely dumbfounded with what to do here. I've never encountered anything like this. Does anyone have any suggestions?
So this is a very old post but I never followed up on this. It turns out, I had done everything correctly, but I was attempting to access the objects methods outside the scope of a function (either main or otherwise). Moving the code into the main function fixed the issue.
I have an app project, which uses a library (referencing the library project, not using a jar). Inside that first library, I want to use another library (Estimate Beacons Library), this time using a jar inside the first library libs folder. To properly use this second library, I need to declare in the manifest the following service:
<service android:name="com.estimote.sdk.service.BeaconService"
android:exported="false"/>
I have tried declaring this service in the APP project manifest, but it doesn't get it. The same using the first library project manifest (normal, if I'm not wrong this manifest is ignored by the compiler?).
Any help would be much appreciated. I've been looking for a similar issue but I didn't get lucky.
Edit:
Even with the following configuration it does not work:
First library has Estimote Beacon SDK (second library) added in lib folder. Also, it has bluetooth permissions and service declared in the manifest.
APP project has first library (not using jar but referencing the project) and second library in its lib folder. Bluetooth permissions and service is declared in the manifest.
I also created a test app, declaring the service and bluetooth permissions, and adding the library in the lib folder and it worked great, so it is just getting confused when I use my library.
AndroidManifest.xml it's just Application configuration file, but not build file.
If you are using Gradle build system, than your libraries dependencies should be specified in build.grale and settings.gradle files.
Read this Building Your Android Project with Gradle
Try enabling manifest merging in the project.properties file:
manifestmerger.enabled=true
Also check your generated manifest in the bin directory after you build your project, and make sure the service definition is there.
This is the approach that works for the Android Beacon Library, and I have used it to make other libraries dependent upon it.
Ultimately, though, it is true that Android Studio provides more flexible tools to do this.
I have two projects, the first is a library (Marked as "isLibrary" in the eclipse properties -> android settings) and the second is an android application. The android application uses the library and everything works ok.
I am now trying to include a jar file in the library and access it's functionality in a class (we will call it ClassA) also found again in the library. Now in the android application I create a new instance of the ClassA and tell it to do some stuff that will use functions provided by the jar I added in the library. I end up with this error:
"Android could no find class 'com.blah.blah.blah' etc."
I checked the .classpath in the library and it is exporting the jar properly. What could I be missing?
Thanks in advance.
I think that while you can use any "lib" folder you want in eclipse, and add it to the classpath, I'm pretty sure for Android to package things correctly the jar should be placed in a folder called libs.