Android: Adding a new framework - java

I am trying to add a new framework in Android Source code and call my applications using that framework.
I have included my framework files and called the functions. Makefile for the application includes the new framework. Everything compiles. But when I run my app it force closes. All the Xml layouts and java classes are fine. Manifest file includes
<user-library android:name="frameworkName">
My question is where to have the mapping for this "frameworkName" in android base code so that it is able to figure out the framework folder/path. Which looks like to be the main problem
What are the possible steps to make this work as I am unable to run my application(Force Close).
EDIT: Initially I was getting Runtime Exception:-Class Not Found for framework classes. Moreover that error was coming up when I missed the "user-library" tag. Now after adding the tag, my apk is not getting installed by the package manager as it is not able to figure out the the framework path.
Android Developers says this:- "the PackageManager framework won't let the user install the application unless the library is present on the user's device".
http://developer.android.com/guide/topics/manifest/uses-library-element.html
So which linking am I missing. Any guesses or help would be really helpful for me.
thanks

Instead of "frameworkName", you should put package name of your library (the one defined in the application name of your library).
If your classes (and R) are in com.example.myframework, then that's your library name.

Related

How to download Packages for Android Studio?

I just started Android Development yesterday and just finished with my first Activity. On running it, I'm getting errors like
**Error:(4, 37) error: package android.support.design.widget does not exist**
As I never post without it, I've already done plenty of searching on this. Basically, what I've understood is that it couldn't find that Widget Package on my PC. So, do I have to download it? If yes, then how?
People on internet had similar problem with Packages and almost every post has different answer to this. Some say change your Gradle File others say Update your Studio (have done it).
Any kind of explanation or bit of knowledge with the solution would be highly appreciated. I'm a kind of geek who want to get concepts and basics clear. So, it would be great if you include the reason and technicality behind this too with your answer. Thanks. :)
It's a design library for Android apps development and as #Dominique pointed have a look at that page and copy paste that compile 'com.android.support:design:22.2.0' line in your project gradle file and press the sync button. Your project will sync in a few moments and the design library will be downloaded. Now you can use this library and there won't be any errors.
No, in Java "package" is not a "library" or a "piece of software" (like it is in some other languages). Package is what classes belong to - you might think of packages as directories containing Java files (it is a simplification, but it works). In Java libraries are packaged into (usually) "jars" (those jars usually contain classes divided into packages), so what you need to download is "jar".
So, first thing you need to check is: what library contains the package, and configure your IDE accordingly. The package in question belongs, I think to the so called android support library, which you can install using the SDK tool.

java.lang.NoSuchFieldError caused by 3rd Party module

I've integrated a third party library in my Android project.
The library is provided in form of an .aar file.
Implementation of it, is a simple one-liner that creates a customdialog in my mainactiviy.
But whenever it tries to create the dialog my app will crash with
java.lang.NoSuchFieldError: de.thirdparty.lib.R$id.neverParticipateButton
at de.thirdparty.lib.views.DialogBuilder.buildView(DialogBuilder.java:97)
I have implemented the library in a new empty android project and it worked as planned. So it seems like there's a conflict with my project.
I've read in a different post (Here), that it can be caused when project and library accidentally use the same name for a layout. But when i inspect the library's code in my build folder, I can't find any layouts that use the same names. Also not ids or drawables.
Does somebody have an idea what else can cause this Error, or advice how to debug?
Kind Regards
Christian
Problem was that another 3rd Party library that was already integrated in my app had the same layout name as the new one... Nothing much i could do here but to inform the devs of the libs to use prefixes.

Import Neo4J API in Netbeans

For a project I am building a Java GUI from which queries can be sent to Neo4j, to make it easier to do particular analyses. To get this all working, I have downloaded a .jar folder containing all relevant classes (neo4j-javadocs-2.1.7-javadoc.jar). I have loaded the library through the project->properties->libraries->Add JAR, but I can't seem to import the classes I want to use in my GUI (neither automatically nor manually).
I am dabbling in Java, so it is probably a basic oversight that I am making, but with the help from tutorials online and trying different commands (like entering the path of the .jar file) I can't get it working. One of these tutorials is specific on the Neo4j library, so I am very confused. That tutorial is written for Eclipse, instead of NetBeans which I am working with, but as far as my knowledge goes that shouldn't matter for the commands
I don't have enough reputation to post direct images, but this link contains a screenshot. If more information is required, let me know. http://i.stack.imgur.com/lUytK.png
Additionally, when I normally add a class that is not imported, there is an automatic function to import the class. This option is missing for my specific class, so maybe I added the library in an incorrect way?
http://i.stack.imgur.com/QeDX4.png
Edit: Issue resolved thanks to a colleague that came in. Apparently I loaded the Javadoc where I should have loaded to individual classes from the lib directory.
It really should work.
Try to save all changes. NetBeans reparses the classes when you save them.
Try to build your project manually from command line using Ant build script
Use Maven, Ivy or Gradle for Dependency Management then you can depend on the Neo4j artifacts.
For sending queries to the server you actually don't need Neo4j artifacts.
You can also use the JDBC driver, see http://neo4j.com/developer/java

How can I use Android with Java and a core made with Scala?

I made a small project using Scala (SBT + IntellijIDEA) that provides me a set of classes and other functions that I want to use in Android. I will call this project $core.
So, keeping that in mind I tried to first only use scala. I tried to create an Android Project using android-plugin and I got it.
But what I really want is to use my $core in an Android Project AND expand the $core classes using Java. $core provides an API that I would like more people to use and they probably don't know Scala so Java would be perfect. Besides, I need to go into a safe route with Android. I saw some info that scala takes a lot of time to compile into Android and has some limitations (like with parceblles).
I already tried to use the classes in eclipse with the import class folder option. I even tried to generate a jar so at least I would have a way to run it and no success. Always the NoClassDef error when I try to use one class from the $core. I have tried to import also the scala compiler library, but didn't work out aswell...
Core isn't finished yet and I would like to develop on a single environment that allowed me to debug on the android device. How can I setup all of this?
PS: Changing to eclipse now maybe is better? Never tried android on intellijIDEA and In scala I can't debug over there, at least using ScalaCheck...
Is it possible that you are getting an noclassdeffound error when working with Scala code from java because you didn't add the Scala library to the java project or at least included the party of it that it's used in the Scala code in the jar?
Could you post the rest of the error?
You could package the core to .jar together with Scala library, use Proguard to remove all unused Scala library classes from it, and then use that jar as a regular library.

Android doesn't recognizes Scala activity

I'm trying to play with Scala in Android but the Manifest doesn't recognizes my main/only-so-far activity.
I did the set up according to this blog post: http://novoda.com/2009/10/17/scala-on-android/ and everything works until i try to run my app, moment in which the logcat saids that it just doesn't find my Activity. the thing is all i can found about this problem is this: http://tiliman.wordpress.com/2010/02/10/android-development-with-scala/. According to this post the manifest doesn't recognizes the Activity because it ain't a Java file, so he creates a Java class that extends from Scala, which i don't think is a good solution at all.
What do i have to do to get started? I think i'm not missing anything.
According to previously asked questions, there seems to be no solution, i mean no one provided one. But i can't believe that using something like sbt is the only way to make full and substantial Android apps in Scala. Truly, no solution at all?
UPDATE: As for the answer given, i'll give SBT a try. But i still think that is necessary a more straightforward way to do it. In a Google Dev Fest i attended, Tim Bray practically said that you could jut make Android apps in Scala or in Java, naturally and without problems: i don't see how this fits with Manifest doesn't recognizing a Scala activity.
The page you're looking at is pretty old. I'd recommend using AndroidPlugin, which is built on top of SBT (https://github.com/jberkel/android-plugin). It handles building, testing, deploying to the emulator/device, etc.
I've got this building my android app, and the only java file I have is the autogenerated R.java.
With SBT you can also generate IDEA and Eclipse configurations, so you should be good to go.
The solution posted here uses the AndroidProguardScala plug-in, in which if the name of the scala file matches the name of the main activity, there is not problem to have your main activity written in scala.
https://stackoverflow.com/a/11084146/1287856

Categories