java.lang.NoSuchFieldError caused by 3rd Party module - java

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.

Related

Is it possible to use links file java class files instead of copying them into project in Android Studio?

I have many java class files written by me for common purposes which I need to use very often in my Android projects. These classes (let's call them 'library') has many static methods in them and I call these methods when I need them in my Android Studio projects without any problem
When I create a new Android Studio project I copy all those library files into the Java folder of my new project. So, I can call them with the syntax like classname.methodname() at any time in my projects (in activities, in other java classes, etc)
The question is that this technic causes many independent library files in each project. This means that, when I have added a new method or changed a method, I need to do the same thing at each library files in each project.
As I am new at Android Studio and I am playing with that at the moment, this might be ok. But in real life, this will be impossible in the near future while I was struggling with many projects.
I am sure that, there should be a way to use file links instead of inserting these library files by copying them into the Android projects. So, making changes in a source library file will affect all projects at once. Something like $I directive in the C type languages...
Is this possible and if yes, how?
Thank you...
One good way would be to create your own library/module in android studio.
Here is a link for that : https://developer.android.com/studio/projects/android-library
And another way would be to create your own JAR file.

Android Studio - Hide aar modules dependencies in another aar module

I'm facing a problem while developing a library with Android Studio.
The concept is to create one aar (MyLib) which is depends on other aar.
At the end, I want to hide everything from the other aar, and only exposed 'MyLib'.
So I found this tool: 'com.kezong.fat-aar' which give me the ability to create one big fat aar from 'multiple aar'.
Then I have created a ProGuard to only include (-keep) some classes of 'MyLib'.
It works but I can still access to classes defined in the 'multiple aar'.
I've made some online research and I can't find any solution.
Now I wonder if it's even possible to achieve what I want because 'MyLib' should access to the 'multiple aar' (dependencies) but I don't want that the user or client can see them.
Sorry for my bad english...
Do you have any clue or information to help me ?
Thanks a lot.

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.

How do I use MUpdf in an existing java project

Mupdf documentation shows me how to use the library as an application and deploy it. However, I want to suck it into an existing java project and build my application on top of it. Can this be done? If so, how do I bring just the pieces needed, into my project?
Take a look at jMuPdf. I never used it, but it seems to be active.
Otherwise you will need to create Java Native Bindings (JNA or JNI).

Android: Adding a new framework

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.

Categories