Unable to reference a Library project - Android - android

Well, I wanted to create a Library project from my existing sources so that it would help me re-use code for the paid app that I have in mind. When I saw the developer guide on how this was to be done, I thought it was very simple.
Just mark the project as a Library project and it should be converted to one.
But when I tried referencing one of the base classes in an application, the app force closes with the following exceptions
02-04 21:50:06.765: E/AndroidRuntime(699): java.lang.NoClassDefFoundError: in.my.package.name.R$layout
Let me give you some more info. I have referenced the Library project in the application and have also included the manifest entries with fully qualified activity names. I have a BaseActivity which has all the menu and re-usable code bits. The point where the above exception occurs is where I am trying to reference the layout file in this BaseActivity inside the library project.
setContentView(R.layout.apphome);
What is it that I am missing or doing wrongly?
PS: I am just noticing that When I right click on my application and go to the android tab, there is a red cross instead of a green tick in the place where the library project is referenced. But there are no visible errors on the console or in the code of the project.

Seems its a known issue.
Issue link here
Hope Google guys resolve this problem in their next SDK release.
So to be clear, the problem was that my libraries had custom styling capabilities and that was the problem.

Related

Error in MainAcitivity.java file & no style are loading

I am new to android. I am creating an android application, but there are many errors showing in MainActivity.java. Here is a screenshot
Another problem is that no style in showing in activity_main.xml. Here is the screenshot
Although I have added appcompact_v7 jar file like this
But it's not recognizing it in android option of project propertise
I have installed Support library in SDK manager. Please tell me how to solve this problem?
It is really hard to say what is wrong there. here are some things that you should try:
first of all, there are errors in your xml file (activity_xml). Please check if xml is properly formatted and you are using right tags. For debugging purpose, please make your acitivity_xml an empty FrameLayout and see if it works.
Include android 6.0 into your build path. Clean the project and try building again. Make sure your layouts are error free before doing that.
Your eclipse is unable to detect referenced library at given location. Please make sure referenced library is at same place and ERROR-FREE. If library has error, your project won't include it.
Please solve all problems one by one. First make an error free xml, then a Hello world Activity. Run it on device or emulator. Once done, try to solve library and import problem now.
Best Suggestion: Please migrate to Android Studio and gradle for better support and learning.

Need to embed one android project into another android project

I have two android projects with me. I need to add the first project as a library to the other project.
Now, when I am trying to open the activity of library project from the other application on a button click, i am getting Android.content.ActivityNotFoundException at run time.
Can anyone suggest some pointer on this.
you need to check that you added the new activity to the manifest.xml file
if you are Using ADT(Android Developer Tool).
Thanks for the concern. This issue is resolved for me. Sorry for the late reply. I have created the second application as library project, which is included in first android project.
The point, which fixed the issue is: add the contents of the manifest.xml of library project in main project and the reference provided is the full path for the activity(including package name).

Android Studio 0.8.0 with Shinobi Charts

I was trying out the sample code posted for shinobi charts on android studio 0.8.0 from
https://github.com/ShinobiControls/shinobicharts-with-android-studio
I tried to import the shinobicharts jar as an .jar library .
It compiled perfectly , but I kept getting a runtime error and I have no clue what to do.This is the error displayed, the app never opens, just starts out with this crash
java.lang.NoClassDefFoundError: com.shinobicontrols.charts.R$styleable
at com.shinobicontrols.charts.ct.a(SourceFile:850)
It looks like you're running Proguard and it stripped out one or more needed classes.
Try turning off Proguard. If that gets past this problem, then you can turn it back on and fix its configuration file.
To fix it, you'll need to add rules to "keep" classes that it couldn't tell are needed. You can name specific classes or classname patterns. There might be a way to tell it to look at references from the library .jar to classes outside the library.

Adding google maps library to existing project creates confusing error

I am building an Android app that I want to open google maps with the click of a button. I want the app to find the current location of the user and give them directions to a predefined address. I started building the application before I realized there were special steps that you have to take to include this functionality. To add this feature to my project I followed the directions on these two sites:
https://developer.android.com/google/play-services/setup.html
https://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject
The problem is on the second site, when i added the library to my already existing project it caused all of my code that has findViewById(R.id.whatever) or setContentView(R.layout.whatever) to become errors. It is now telling me that i need to import the class R. If I do that it then gives me error messages on the names of all my xml files.
For example in my MainActivity it is telling me that i should change setContentView(R.layout.activity_main) to setContentView(R.layout.activity_list_item) and does this for all references to my xml files for the entire project.
I tried going back and removing the google play services library from the project and starting over but when I removed it the errors still persists. I also tried using the "fix project setup" option in Eclipse but it didn't fix the problem.
I'm wondering if anyone here has experienced this problem before? If so, how can I fix it? The application had no errors before I tried to include the google play services library. I am new to Android development so a lot of the information I have found has been either confusing to understand or doesn't seem to include enough details for me to figure it out. Thanks for your help!
Look at your imports, and check if you are importing the correct R.java from your application package, not from the android package.
Check also if your XMLs don't contain errors, otherwise R.java won't be generated.
In my case android-maps-library had to errors in two files (I have forgotten their names), I edited the two files removing errors my self. And finally I was able to used it quite nice.
i think you have correct yout Project build target, and this how:
right click on your project folder in the package explorer->propreties->Android
then porject build target and choose you Android target (Android x.xx)
but before that you need to remove import android.R;

Crash when trying to call "GooglePlayServicesUtil.isGooglePlayServicesAvailable"

So, I installed everything, linked the project folder and my app crashes when I try to check the services.
Any hoop I forgot to jump on this stupidly over-complicated system just to display a simple map with some markers on my app?
All I get is "07-06 20:01:43.132: E/AndroidRuntime(1348): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil", even if I try to execute it inside a try-catch, it will still crash the app.
I've seen an app crash the same way before, but it only did because the google-play-services folder was added to the project in the Properties - Java Build Path section instead of including it as an android library in Properties - Android section.
Finnaly made this P.O.S work. Instead of doing all dumb crap googles tells you, just add a variable that points to their google-play-services.jar. But I think doing things simple is too mainstream for those hipsters.

Categories

Resources