I have imported a jar file in "libs" folder of a android project. I added it in my Java Build path. I am trying to call a function of this Jar file from my implemented Android SimpleService Class. My android project compiles correctly but while I launch it on the emulator, I get NOClassDefFoundError (#runtime it is not able to get the class file).
I am adding additional info for your knowledge:
JAVA_HOME = /usr/lib/jvm/java-6-sun-1.6.0.26.
Android Platform = 4.0.3, API level = 15.
Android SDK tools revision = 18.
Android SDK Platform-tools revision = 11.
Jar manifest file (MANIFEST.MF) = Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: kunjan
Build-Jdk: 1.6.0_26
Did you try to check whether that jar file is present in *.apk file or not?
What version of ADT are you using? If you are using 17 or later you can put it in a /libs folder.
I have encountered the same problem, if you are using ADT 17 or later, make sure that use the 'libs folder' as source folder . That is how I solved.
Related
I just create a small Xamarin.Forms sample application. When i build my Android project i get some errors.
I just googled errors and find some solutions. But nothing works fine.
Last day i had reinstalled Visual Studio 2015 and Xamarin Studio.
So probably xamarin will be updated in all.
Here I just list my errors and suggested solutions.
Error 1 :
Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the ...~\Local\Xamarin\Android.Support.v4\21.0.3\content directory.
Suggested solution :
The file is downloaded successfully and replaced as per the error message.
Error 2 :
_Please install package: 'Android Support Library' available in SDK installer. Java library file ...~\Local\Xamarin\Android.Support.v4\21.0.3\embedded\classes.jar doesn't exist.
Please install package: 'Android Support Library' available in SDK installer. Java library file ...~\Local\Xamarin\Android.Support.v4\21.0.3\embedded\libs/internal_impl-21.0.3.jar doesn't exist._
Suggested solution :
Android Support Library is deleted and reinstalled.
Error 3 :
Reason: ...~\Local\Xamarin\zips\1FD832DCC1792D8ACA07FAC3259FC5A9.zip is not a valid zip file.
Suggested solution :
I didn't find any solutions for this error.
These solutions are still useless. and not working in my case.
I'm using :
Xamarin 4.0.0.1689 (f860fe4)
Xamarin.Android 6.0.0.34 (3efa14c)
Xamarin.iOS 9.2.1.51 (3c0ec35)
Here is the detailed report :
=== Xamarin Studio ===
Version 5.10 (build 871)
Installation UUID: c5309e12-1ab1-494c-9296-033a0a5c3f24
Runtime:
Microsoft .NET 4.0.30319.42000
GTK+ 2.24.23 (MS-Windows theme)
GTK# 2.12.30
=== Xamarin.Android ===
Version: 6.0.0
Android SDK: D:\Android\android-sdk
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
4.4.87 (API level 20)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
SDK Tools Version: 24.4
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_55
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)
=== Xamarin Android Player ===
Version: 0.6.5
Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe
=== Build Information ===
Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 07:16:34-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-windows-cycle6
=== Operating System ===
Windows 6.3.9600.0 (64-bit)
Any ideas or suggestions to come out of this errors ?
EDIT: This information is now included in our documentation: https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/
Xamarin.Android Support Library NuGet m2repository fixes
1. Investigation
You may run into issues with downloading the m2repository when referencing a NuGet package of the Android Support Libraries / Google Play Services.
Example error:
Download failed. Please download
https://dl-ssl.google.com/android/repository/android_m2repository_r25.zip
and put it to the
C:\Users\[Username]\AppData\Local\Xamarin\{SUPPORT LIBRARY NAME}\{VERSION NUMBER}
directory."
Mac Directory: /Users/[Username]/.local/share/Xamarin/
Windows Directory: C:\Users\[Username]\AppData\Local\Xamarin\
2. Folder Contents
This example will be using Windows paths. This can be applied to either OS.
Given the following: C:\Users\[Username]\AppData\Local\Xamarin\
A folder for each of the respective Android Support Libraries / Google Play Services will be shown.
Each library should have a collection of versions:
Note: In this example I'm showing all of the versions of Android.Support.v4
We will then investigate the respective version we're interested in. We should see two folders inside, content and embedded:
content - Contains the m2repository
embedded - Contains the respective .aar contents
3. Automatic Fix
Delete the versioned library folder that is giving you errors:
Mac Directory: /Users/[Username]/.local/share/Xamarin/{SUPPORT LIBRARY NAME}/{VERSION NUMBER}
Windows Directory: C:\Users\[Username]\AppData\Local\Xamarin\{SUPPORT LIBRARY NAME}\{VERSION NUMBER}
Rebuild your project (Which will kickoff a Build Task to re-download the library).
4. Manual Fix
There are two steps to manually fixing this error.
Adding the m2repository folder to the /content folder.
Adding the respective Android Support Library / Google Play Services .aar contents to the /embedded folder.
1. Adding the m2repository to the /content folder
Download the respective m2repository from google.
https://dl-ssl.google.com/android/repository/android_m2repository_r25.zip
Note: This version number will vary based on your error message.
Extract that .zip to any directory. There should now be a android_m2repository_r25 folder.
Inside the android_m2repository_r25 folder, we have a m2repository folder.
Place the m2repository into the {VERSION NUMBER}/content folder
2. Adding the .aar contents to the /embedded folder
Inside the m2repository folder, there is an .aar for the support library to be resolved. It can be found in the com\android\support directory:
Example:
m2repository\com\android\support
There should be a support-v4\{VERSION NUMBER} which will contain the .aar file.
Extract the .aar and put the contents into the embedded folder.
Example:
m2repository\com\android\support\support-v4\23.1.1\support-v4-23.1.1 will contain items such as a aapt, aidl, assets, libs, res, AndroidManifest.xml, annotations.zip, and classes.jar.
Place all of the contents into the {VERSION NUMBER}/embedded folder.
5. New Manual Fix
Get the URL of the missing m2repository download
Use a MD5 hash on the download URL
Rename the file to {MD5HASH}.zip (Where MD5HASH is the hashed download URL)
Place the new hashed .zip file in your Xamarin\zips directory
Delete all the zip files. Even if it asks you to download and replace, it will corrupt again. The quicker way is to just delete all the zip files and rebuild, it will automatically download and unzip as required.
The Android m2repository gets corrupted often on my machine.
With Android I also suggest, build against API 23 (6.0) and set you minimum level to 15 (unless you really need API 10). Make sure you don't use the "Latest SDK" selection, that has been known to cause issues in the past as well, select the highest API beneath that.
Delete the zip at \Local\Xamarin\zips\1FD832DCC1792D8ACA07FAC3259FC5A9.zip
Clean and Rebuild your solution.
I get that problem when tried to use xamarin forms 2.0
The problem usually comes when IDE (VS2015 for example) try to decompress that zip... VS hangs and you must force close it ... when you reopen the IDE you cannot compile anything with xamarin that use this version.
First of all you should download r23 no r10. Each one contains assemblies for each version api.
When you have it you should delete library folder on C:\Users\%username%\AppData\Local\Xamarin for example Android.Support.v4
Create a path with the library name C:\Users\%username%\AppData\Local\Xamarin{LibraryName}\23.0.1
Copy and unzip download r23 to C:\Users\%username%\AppData\Local\Xamarin\Android.Support.v4\22.2.10\content
Go to m2repository\com\android\support and under libraryname\version you will get a file with extension ".aar" this is a zip file rename to .rar and unzip it to C:\Users\%username%\AppData\Local\Xamarin{LibraryName}\23.0.1\embedded
By the way a copy of downloaded r23.zip must be leaved on:
C:\Users\%username%\AppData\Local\Xamarin{library name}\23.0.1\
When you have done this you are able to compile again
Spent a whole night struggling to get this working, turned out i had forcefully shut down VS during an initial build thinking it got stuck not knowing it was actually downloading a > 200MB file to my C:\Users[UserName]\AppData\Local\Xamarin\zips folder.
Deleting the corrupt zip file and being patient enough to rerun a rebuild definitely fixed the issue.
In Simple Words
-> After handling and clearing all the Errors in your Xml documents
-> click on the hammer icon to build and make project Or Press Ctrl+F9
When creating a new android application i get the following error messages.
Project 'appcompat_v7' is missing required source folder: 'gen' appcompat_v7 Build path Build Path Problem
The container 'Android Dependencies' references non existing library '/Users/Edvin/Documents/Edvins Workspace/appcompat_v7/bin/appcompat_v7.jar' MyFirstAndroidApp. Build path Build Path Problem
Im using Android 5.1.1 (API 22) and I've also installed other SDK packages that were required. When i create the project I compile and target with API 22 and the rest of the setting i leave as default. I've seen somewhat similar questions regarding this but the solutions have unfortunately not worked out for me.
Any help or thoughts is greatly appreciated!
If you can then install Android Studio which is the officially supported IDE for android sdk.
You won't have to download libraries jar and instead use the repositories in the maven servers.
Alternative :::
In project.properties file remove appcompat_v7 reference line. Then remove all the error lines that you get in some files like manifest.xml, values folder files, and may be in some java files.
Since appcompat_v7 is not there then its all references should be deleted.
In activity files extend it to Activity.
I have the support libraries installed via the SDK manager.
I have copied the C:\Program Files\Android\android-sdk\extras\android\support\v7\appcompat folder to my projects libs folder.
I have added the \tools folder of the sdk to my command line path. I have then run
android update project --path . --library C:\Users\srayner\dev\android\AndroidTest1\libs\appcompat
But now netbeans gives me this error;
Failed to resolve library path: C:\Users\srayner\dev\android\AndroidTest1\libs\appcompat
What is the correct method to setup an android support library with resouses in netbeans?
I have successfully build and added the appcompat project in NetBeans.
Create a new android project in netbeans - I called mine "appcompat".
Build your new project just make sure it can be successfully build.
Delete everything inside the src directory and rebuild. My project just contained the default MainActivity that was created by NetBeans. You don't need it.
Navigate to your android sdk install directory
"androidSdkPath\extras\android\support\v7\appcompat and copy all
the contents within that folder
Paste the copied contents to the android project that you
created in step 1 (again mine was named as appcompat).
Very important - Open project.properties and ensure that the "target" property matches the following: "target=android-21"
Build your project and Voila... you should be all set.
If you are still having issues compiling the project that will be using the appcompat library, change your project library properties target=android-21"
I am coding a Xamarin application and these are the errors that I am getting when building my application:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5206: Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/appcompat doesn't exist. (XA5206) (SimpleOnePageViewPager)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/appcompat/libs/android-support-v7-appcompat.jar doesn't exist. (XA5207) (SimpleOnePageViewPager)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5206: Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter doesn't exist. (XA5206) (SimpleOnePageViewPager)
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2): Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter/libs/android-support-v7-mediarouter.jar doesn't exist. (XA5207) (SimpleOnePageViewPager)
I have added the Android Support Library v4 as a component and in the Android SDK Manager I seem to have everything installed correctly.
Can I please have some help to get my code building successfully?
Thanks in advance
EDIT
I have added the Android Support Library v7 AppCompat as a component and am now getting these two errors:
Error XA5206: Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter doesn't exist. (XA5206) (SimpleOnePageViewPager)
Error XA5207: Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Simon\Documents\Xamarin\SimpleOnePageViewPager\SimpleOnePageViewPager\Components\googleplayservicesgingerbread-16.0.0.1\lib\android\19.1.0\content\support/v7/mediarouter/libs/android-support-v7-mediarouter.jar doesn't exist. (XA5207) (SimpleOnePageViewPager)
in case your "embedded" folder is missing, just downloading and extracting the android_m2repository_r10.zip does not solve the issue.
I deleted the entire C:\Users\\AppData\Local\Xamarin\Android.Support.v4\23.0.1.3 folder and then rebuild as described here:
[Error after updating the Android.Support Library v7 AppCompat to the 21.0.3 version
I solved all of the 'Please install Android Support Library' errors, although I'm not sure which step exactly solved it. However, this is what I did in case someone has the same trouble as I did:
Download "https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip " and paste it in "C:\Users\YourUserName\AppData\Local\Xamarin\Android.Support.v4\21.0.3\". For mac users change the path pre-Xamarin to \Users\YourUserName\ .local\share\Xamarin (Overwrite as needed, but create backup just in case)
Extract the contents of the android_m2repository_r10.zip archive into {...}\Android.Support.v4\21.0.3\content folder (create content folder if it doesn't exist, overwrite as needed and take same precautions as above)
Repeat the steps above but this time for the {...}\Android.Support.v4\22.2.0 folder instead of the 21.0.3
Make sure you have your packages updated to the latest version by right clicking on the Package folder of your solution and clicking Update (At least on Xamarin Studio).
Make sure you also have the latest version of Android Support Library on the Android SDK Manager
In case everything fails, try the AppCompat Android component from Xamarin (your milage may vary with the last one)
I was facing same problem and i followed following link and it is working like a charm.
https://forums.xamarin.com/discussion/56627/xamarin-android-support-v7-cardview-error-depite-being-installed
Just suppress the zip in Xamarin\zips{zip} and rebuild your solution .
In Addition to #sgarcia the answer there are another steps that fixes the problem.
1- Renaming the android_m2repository_rnn.zip file to it's MD5 hash of url.Here is a list of some of them:
android_m2repository_r33.zip --> 5FB756A25962361D17BBE99C3B3FCC44
android_m2repository_r32.zip --> F16A3455987DBAE5783F058F19F7FCDF
android_m2repository_r31.zip --> 99A8907CE2324316E754A95E4C2D786E
android_m2repository_r30.zip --> 05AD180B8BDC7C21D6BCB94DDE7F2C8F
android_m2repository_r29.zip --> 2A3A8A6D6826EF6CC653030E7D695C41
android_m2repository_r28.zip --> 17BE247580748F1EDB72E9F374AA0223
android_m2repository_r27.zip --> C9FD4FCD69D7D12B1D9DF076B7BE4E1C
android_m2repository_r26.zip --> 8157FC1C311BB36420C1D8992AF54A4D
android_m2repository_r25.zip --> 0B3F1796C97C707339FB13AE8507AF50
android_m2repository_r24.zip --> 8E3C9EC713781EDFE1EFBC5974136BEA
android_m2repository_r23.zip --> D5BB66B3640FD9B9C6362C9DB5AB0FE7
android_m2repository_r22.zip --> 96659D653BDE0FAEDB818170891F2BB0
android_m2repository_r21.zip --> CD3223F2EFE068A26682B9E9C4B6FBB5
android_m2repository_r20.zip --> 650E58DF02DB1A832386FA4A2DE46B1A
android_m2repository_r19.zip --> 263B062D6EFAA8AEE39E9460B8A5851A
android_m2repository_r18.zip --> 25947AD38DCB4865ABEB61522FAFDA0E
android_m2repository_r17.zip --> 49054774F44AE5F35A6BA9D3C117EFD8
android_m2repository_r16.zip --> 0595E577D19D31708195A83087881EE6
You can find the list here: https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/#Manually_Downloading_m2repository
If the problem still exists the best way is to follow this link's instructions.
Manually Downloading and Installing m2repository Files
user998066, simonbassey and sgarcia.dev - thanks.
Just to update, you don't have to manually download those zip's and extract them in your appdata folder. Just delete them and rebuild your solution. Visual Studio will download and do the rest. It doesn't show that its downloading/extracting/watever in the output window (one thinks its frozen and will kill the VS instance.. dont do it as this is where your download is interrupted and the zip file is corrupt and keeps giving those errors.) and takes a lot of time. If you go to C:\Users\\AppData\Local\Xamarin\zips you will see the zips getting downloaded while you are building your solution. Its a huge file and your first build will certainly take a lot of time until its downloaded..
Ensure the following:
1- Open Android SDK Manager
2- Under Tools Tab --> Find the folder "Extras"
3- Make sure that "Android Support Repository" is installed
Upgrade Xamarin.Android.Support.v4 to 22 or higher. I went on with 25.4.0.2.
Install Xamarin.Android.Support.v7 and everything just works fine.
You have to add android-support-v7-appcompat as library project. It's it sdk android extras.
If you are still facing this problem , try following these steps to resolve it. it did the magic for me
Goto the Xamarin installation folder path . on windows you can find it here C:\Users\simonbassey\AppData\Local\Xamarin
Next delete the zips folder therein (it may have been corrupt or not an updated version of the support library). Also delete every other Xamarin.Android.Support.* folder there.
Head on to the visual studio solutions folder for the project and delete the bin/ and debug/ folders.
Restart visual studio and rebuild your project.
See this thread for more details
What fixes in my case was:
1- Open Android SDK Manager
2- Find the folder "Extras"
3- Make sure that "Android Support Repository" is installed
Then in VS:
1- clear the obj and bin folder
2- clean and rebuild the solution
Following two links helped me with all jdk and droid project related problems. In case it may help other guys also.
Cleaning particular zips
Setting java version
Platform: MonoDroid v4.2.4
IDE: Visual Studio 2012
Minimum SDK version: API 12
I'm having runtime issues when trying to utilize the LocalBroadcastManager class included in the Android.Support.v4.Content namespace. In my IDE, I've explicitly added the reference and can scope the namespace/class fine, and, after writing some code, compiles as expected. However, upon application deployment and launch, I'm prompted with the error: "NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager"
Here's the code that prompts the runtime error (DSC_Discconected_From_Device is a class that inherits from BroadcastReceiver). It stops execution at the last line.
IntentFilter filter = new IntentFilter(UsbManager.ActionUsbDeviceDetached);
DSC_Disconnected_From_Device Receiver = new DSC_Disconnected_From_Device();
LocalBroadcastManager.GetInstance(this).RegisterReceiver(Receiver, filter);
Under the SDK manager, all the API packages are installed, as well as the "Support Library" package under extras.
Where is it looking for the definition of the class? I've presumably copied the source, LocalBroadcastManager.java, to paths in the android-sdk framework where it "might" be looking. For example: ..\android-sdk\extras\android\support\v4\src\honeycomb\android\support\v4\content\LocalBroadcastManager.java
Ideas?
Edit: Forgot to mention that my project already references the support library, android-support-v4, in the folder "libs", located in the root of my project. I had to create the directory and add it through Visual Studio.
This problem was hounding me for almost six months now and no solution was helping me but today I have managed to find the correct solution on my own.
When you select your project target version to be greater than or equal to Android 4.0, Android SDK includes "android-support-v4.jar" file in your projects "libs" folder. This jar contains all the classes and methods related Android 4.0 or later.
Android is trying to find the class definition which is in "android-support-v4.jar" so that means you have not configured the build path to the "android-support-v4.jar" file. To do this, follow these steps:
Open your project properties
Select "Java Build Path" from left side menu
Select "Libraries" tab
Press "Add External Jar"
(Most important step) Select "android-support-v4" jar file of "libs" folder from your CURRENT PROJECT LOCATION (path should be on your project folder and not the android sdk).
Select "Order and Export" tab and "TICK" the checkbox of "android-support-v4.jar"
That's it, you're done!
I had this error with android facebook integration.The reason was I had android-support-v4.jar library added to my project. Facebook sdk has already support library. So delete support library both from libs and from java build path If you are using a library already has support library in it.
in Android Studio 0.8.2
Press the green "+" in tab Dependencies of Project-Structure, then the keyboard key "1" (for libs) and choose the v4+ lib
If you have proguard enabled, try adding
# Local Broadcast Manager
-keep public class android.support.v4.content.LocalBroadcastManager
This fixed it for me.
You need to add the support library .jar file to the /libs directory in your IDE if it is Eclipse so that when the apk is made the Android packager will include that in your apk.
The problem seems to be related to the "properties" of the android-support-v4.jar library.
By default, the "Build Action" listed in the Advanced Properties in Visual Studio had a value of Content. I switched the value to AndroidJavaLibrary and the runtime error has disappeared.
However, the BroadcastReceiver isn't receiving the USB disconnect intent, hmm... Will update this answer accordingly.
Edit: I could never get a LocalBroadcastReceiver to work, so I had to use a regular one.
Just replace the android-support-v4.jar of your project that is in>libs folder with android-support-v4.jar present in FacebookSDK>libs folder