I'm running my android project using ant in order to continuously run it using Hudson. I have created my build.xml on my mac and instead of importing the generated android build.xml, I copy/pasted it in, since I have to customize some things.
It works fine on my local machine, however, when I run this on hudson, located on a server. I run into an error with the Renderscript attribute.
renderscript doesn't support the "includePath" attribute
So, I decided to take OUT that line in the xml transforming this code:
<renderscript executable="${renderscript}"
includePath="${android.renderscript.include.path}"
genFolder="${gen.absolute.dir}"
resFolder="${out.res.absolute.dir}/raw"
targetApi="${project.minSdkVersion}"
optLevel="${renderscript.opt.level}"
buildType="${build.is.packaging.debug}"
previousBuildType="${build.last.is.packaging.debug}">
<source path="${source.absolute.dir}"/>
</renderscript>
to this:
<renderscript executable="${renderscript}"
genFolder="${gen.absolute.dir}"
resFolder="${out.res.absolute.dir}/raw"
targetApi="${project.minSdkVersion}"
optLevel="${renderscript.opt.level}"
buildType="${build.is.packaging.debug}"
previousBuildType="${build.last.is.packaging.debug}">
<source path="${source.absolute.dir}"/>
</renderscript>
And then comically get this error:
RenderScriptTask's 'includePath' is required.
I'm running the same ant on both machines, downloaded the linux-specific SDK on the server, updated based on tools, platform-tools, and android-7 (the OS I'm supporting). I've run out of ideas of what the problem could be, any help or pointers would be amazing.
Thanks!
This error happened because you updated the android sdk tools to revision to 20.0.1.
renderscript requires the property includePathRefId and it's path was changed. So your code should be:
<renderscript executable="${renderscript}"
includePathRefId="android.renderscript.include.path"
genFolder="${gen.absolute.dir}"
resFolder="${out.res.absolute.dir}/raw"
targetApi="${project.minSdkVersion}"
optLevel="${renderscript.opt.level}"
buildType="${build.is.packaging.debug}"
previousBuildType="${build.last.is.packaging.debug}">
<source path="${source.absolute.dir}"/>
</renderscript>
where the includePathRefId it should be defined like this:
<path id="android.renderscript.include.path">
<pathelement location="${android.platform.tools.dir}/renderscript/include" />
<pathelement location="${android.platform.tools.dir}/renderscript/clang-include" />
</path>
This ended up happening because I had some files to be ignored via the classpath. It was a simple, but overlooked mistake.
Related
I am developing an Android Game and for a week now, I have tried my best to implement AdMob with Mediation. It works fine in the Editor, but when I build, it throws the error mentioned below. I did try to implement multiple other plugins and they built successfully, but crashed on launch (also tried with just their sample app implementations in new projects).
After a lot of digging around, I have a hypothesis that Facebook needs some aars that Admob need, but cannot use the latest version of it (I have tried latest FB SDK versions to no avail as well). Here are some things I noticed:
Notice that CustomTabs is present here. I tried deleting these classes but then build failed with another error
Some conflicting dependencies were found.
The following dependency versions were modified:
com.android.support:appcompat-v7:25.3.1 --> com.android.support:appcompat-v7:27.0.2#aar
com.android.support:cardview-v7:25.3.1 --> com.android.support:cardview-v7:27.0.2#aar
com.android.support:customtabs:25.3.1 --> com.android.support:customtabs:27.0.2#aar
com.android.support:support-v4:25.3.1 --> com.android.support:support-v4:27.0.2#aar
This is the AndroidResolverDependencies.xml file in ProjectSettings Dir.
com.android.support:appcompat-v7:25.3.1
com.android.support:cardview-v7:25.3.1
com.android.support:customtabs:25.3.1
com.android.support:support-v4:25.3.1
com.facebook.android:facebook-core:[5,6)
com.facebook.android:facebook-login:[5,6)
com.facebook.android:facebook-share:[5,6)
com.google.ads.mediation:unity:3.1.0.0
com.google.android.gms:play-services-ads:18.0.0
com.parse.bolts:bolts-android:1.4.0
com.unity3d.ads:unity-ads:3.1.0
Assets/Plugins/Android/android.arch.core.common-1.0.0.jar
Assets/Plugins/Android/android.arch.lifecycle.common-1.0.3.jar
Assets/Plugins/Android/android.arch.lifecycle.runtime-1.0.3.aar
Assets/Plugins/Android/androidx.annotation.annotation-1.0.0.jar
Assets/Plugins/Android/androidx.arch.core.core-common-2.0.0.jar
Assets/Plugins/Android/androidx.arch.core.core-runtime-2.0.0.aar
Assets/Plugins/Android/androidx.asynclayoutinflater.asynclayoutinflater-1.0.0.aar
Assets/Plugins/Android/androidx.browser.browser-1.0.0.aar
Assets/Plugins/Android/androidx.collection.collection-1.0.0.jar
Assets/Plugins/Android/androidx.coordinatorlayout.coordinatorlayout-1.0.0.aar
Assets/Plugins/Android/androidx.core.core-1.0.0.aar
Assets/Plugins/Android/androidx.cursoradapter.cursoradapter-1.0.0.aar
Assets/Plugins/Android/androidx.customview.customview-1.0.0.aar
Assets/Plugins/Android/androidx.documentfile.documentfile-1.0.0.aar
Assets/Plugins/Android/androidx.drawerlayout.drawerlayout-1.0.0.aar
Assets/Plugins/Android/androidx.fragment.fragment-1.0.0.aar
Assets/Plugins/Android/androidx.interpolator.interpolator-1.0.0.aar
Assets/Plugins/Android/androidx.legacy.legacy-support-core-ui-1.0.0.aar
Assets/Plugins/Android/androidx.legacy.legacy-support-core-utils-1.0.0.aar
Assets/Plugins/Android/androidx.lifecycle.lifecycle-common-2.0.0.jar
Assets/Plugins/Android/androidx.lifecycle.lifecycle-livedata-2.0.0.aar
Assets/Plugins/Android/androidx.lifecycle.lifecycle-livedata-core-2.0.0.aar
Assets/Plugins/Android/androidx.lifecycle.lifecycle-runtime-2.0.0.aar
Assets/Plugins/Android/androidx.lifecycle.lifecycle-viewmodel-2.0.0.aar
Assets/Plugins/Android/androidx.loader.loader-1.0.0.aar
Assets/Plugins/Android/androidx.localbroadcastmanager.localbroadcastmanager-1.0.0.aar
Assets/Plugins/Android/androidx.print.print-1.0.0.aar
Assets/Plugins/Android/androidx.slidingpanelayout.slidingpanelayout-1.0.0.aar
Assets/Plugins/Android/androidx.swiperefreshlayout.swiperefreshlayout-1.0.0.aar
Assets/Plugins/Android/androidx.versionedparcelable.versionedparcelable-1.0.0.aar
Assets/Plugins/Android/androidx.viewpager.viewpager-1.0.0.aar
Assets/Plugins/Android/com.android.support.animated-vector-drawable-27.0.2.aar
Assets/Plugins/Android/com.android.support.appcompat-v7-27.0.2.aar
Assets/Plugins/Android/com.android.support.cardview-v7-27.0.2.aar
Assets/Plugins/Android/com.android.support.customtabs-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-annotations-27.0.2.jar
Assets/Plugins/Android/com.android.support.support-compat-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-core-ui-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-core-utils-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-fragment-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-media-compat-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-v4-27.0.2.aar
Assets/Plugins/Android/com.android.support.support-vector-drawable-27.0.2.aar
Assets/Plugins/Android/com.facebook.android.facebook-common-5.1.0.aar
Assets/Plugins/Android/com.facebook.android.facebook-core-5.1.0.aar
Assets/Plugins/Android/com.facebook.android.facebook-login-5.1.0.aar
Assets/Plugins/Android/com.facebook.android.facebook-share-5.1.0.aar
Assets/Plugins/Android/com.google.ads.mediation.unity-3.1.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-ads-18.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-ads-base-18.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-ads-identifier-17.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-ads-lite-18.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-basement-17.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-gass-18.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-measurement-base-17.0.0.aar
Assets/Plugins/Android/com.google.android.gms.play-services-measurement-sdk-api-17.0.0.aar
Assets/Plugins/Android/com.google.zxing.core-3.3.3.jar
Assets/Plugins/Android/com.parse.bolts.bolts-android-1.4.0.jar
Assets/Plugins/Android/com.parse.bolts.bolts-applinks-1.4.0.jar
Assets/Plugins/Android/com.parse.bolts.bolts-tasks-1.4.0.jar
Assets/Plugins/Android/com.unity3d.ads.unity-ads-3.1.0.aar
<settings>
<setting name="androidAbis" value="armeabi-v7a,x86" />
<setting name="bundleId" value="com.pratyaksh.cosmicballs" />
<setting name="explodeAars" value="True" />
<setting name="gradleBuildEnabled" value="True" />
<setting name="gradleTemplateEnabled" value="False" />
<setting name="installAndroidPackages" value="True" />
<setting name="packageDir" value="Assets\Plugins\Android" />
<setting name="patchAndroidManifest" value="True" />
<setting name="patchMainTemplateGradle" value="True" />
<setting name="projectExportEnabled" value="False" />
<setting name="useJetifier" value="False" />
</settings>
</dependencies>
Smaller Portions from error log
CommandInvokationFailure: Gradle build failed.
E:\UnityEditor\2019.1.0f2\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "E:\UnityEditor\2019.1.0f2\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
stderr[
D8: Program type already present: android.support.customtabs.ICustomTabsCallback
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForRelease'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
.
.
//SHORTENED FOR STACKOVERFLOW
.
.
.
:transformClassesWithDexBuilderForRelease
C:\Users\TehBlindNutSack.gradle\caches\transforms-1\files-1.1\facebook-android-wrapper-7.17.0.aar\4bb1132b85935d425bf3b80edd9162a8\jars\classes.jar: D8: Interface com.facebook.applinks.AppLinkData$CompletionHandler not found. It's needed to make sure desugaring of com.facebook.unity.FB$2 is correct. Desugaring will assume that this interface has no default method.
C:\Users\TehBlindNutSack\.gradle\caches\transforms-1\files-1.1\facebook-android-wrapper-7.17.0.aar\4bb1132b85935d425bf3b80edd9162a8\jars\classes.jar: D8: Typecom.facebook.applinks.AppLinkDatawas not found, it is required for default or static interface methods desugaring ofvoid com.facebook.unity.FB.FetchDeferredAppLinkData(java.lang.String)`
:transformDexArchiveWithExternalLibsDexMergerForRelease FAILED
Please, if someone could help me get it right, it would mean a world to me.
Sorry for bad formatting.
Edit: Steps to reproduce:
1. Create a new Unity(2019.1.0f2) Project with android build support
2. Add FB SDK
3. add GoogleMobileAds SDK
4. Build
When you're using GooglePlayResolver you'll be getting new androidx. files. Which could be in conflict with com.android.support. files
Try to do this:
Assets -> GooglePlayResolver -> Android Resolver -> Settings -> Set Jetiffier On
Force Resolve.
Be sure to use the latest:
https://github.com/googlesamples/unity-jar-resolver/releases/tag/v1.2.121
Check this discussion for more info.
https://github.com/googlesamples/unity-jar-resolver/issues/145
I found solutions. there are library files duplicates, see directory and see library files make it as I did. Android and iOS library should be set for each platform.
Download SDK from "https://developers.facebook.com/docs/unity/"
Open SDK directory. there are duplicates. So make a library for each platform.
Set proper platform for iOS and Android.
It works and I tested on Unity 2019.1.0f2. facebookSDK has problem with compile. they made trap.
I have a good news and a bad news.
Bad news First: None of the above solutions worked for me.
Good News: I installed 2019.1.08f and it threw the same error, but with a longer log. I went through the log and found the exact files causing the collision: androidx.browser.browser-1.0.0.aar and androidx.core.core-1.0.0.aar.
I just went into them, opened Classes.jar and deleted Android directory in both the aars' jars.
Build and Run...Voila. (At least for now).
Will update here if another issue arises.
Thank you Brian, for Taking the time to test it and answering the question.
I'm trying to run JAIN-SIP Stack on an Android-Device (4.0.2).
I was able to repackage the jar-files which were needed (jain-sip-api-1.2-src.jar, jain-sip-src-1.2.1111.jar, concurrent.jar, log4j-1.2.8.jar).
This is my build.xml file which I used:
<!-- Converts this project's .class files into .dex files -->
<target name="-jarjar" depends="-compile">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="buildtools/jarjar-1.4.jar"/>
<jarjar jarfile="${out.absolute.dir}/JainSipApi1.2_re.jar">
<zipgroupfileset dir="mylib" includes="jain-sip-api-1.2-src.jar" />
<rule pattern="javax.sip.**" result="sipper.sip.#1"/>
</jarjar>
<jarjar jarfile="${out.absolute.dir}/JainSipRi1.2_re.jar">
<zipgroupfileset dir="mylib" includes="jain-sip-src-1.2.1111.jar" />
<rule pattern="gov.nist.**" result="sipper.nist.#1"/>
</jarjar>
<jarjar jarfile="${out.absolute.dir}/concurrent_re.jar">
<zipgroupfileset dir="mylib" includes="concurrent.jar" />
<rule pattern="EDU.**" result="sipper.EDU.#1"/>
</jarjar>
<jarjar jarfile="${out.absolute.dir}/log4j-1.2.8_re.jar">
<zipgroupfileset dir="mylib" includes="log4j-1.2.8.jar" />
<rule pattern="org.apache.log4j.**" result="sipper.org.apache.log4j.#1"/>
</jarjar>
</target>
And this is a code-sample where I tried to test the repackaged file in a none Android environment:
import sipper.sip.SipFactory;
...
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("sipper.nist");
Properties properties = new Properties();
properties.setProperty("javax.sip.STACK_NAME", "Sipper");
properties.setProperty("javax.sip.IP_ADDRESS", "127.0.0.1");
sipStack = sipFactory.createSipStack(properties);
When I try to run this code I got the following error:
Problem initializing the SIP stack.
sipper.sip.PeerUnavailableException: Missing javax.sip.STACK_NAME property
at sipper.sip.SipFactory.createSipStack(SipFactory.java:144)
at SipLayer.<init>(SipLayer.java:86)
at SipperClient.main(SipperClient.java:51)
As far as I understood, I've just changed the name of the packages, but it seems like that it doesn't work for the "interna" of some packages. That's why I looked into the source and saw there some hard coded strings like:
if (name == null ) throw new PeerUnavailableException("Missing javax.sip.STACK_NAME property");
Now is my question are there any appropriate ways/solutions to make JAIN-SIP under Android working?
Thanks for your help in advance :-)
Daniel
There is now a supported Android port of JAIN SIP by the people who wrote much of the original JAIN SIP stack:
http://www.telestax.com/jain-sip-stack-for-android/
I just saw this post and ran into the same problem.
After a few minutes, I success porting jain sip stack to Nexus 7 Android 4.1.
The main reason of your problem is the "Jar" package name.
Since Android do not support the libraries import from the package name of "javax.*" ,
the first job porting jsip to Android platform is to change the import package name.
And you have changed one of the package name javax.sip into sipper.sip with the following script.
<rule pattern="javax.sip.**" result="sipper.sip.#1"/>
This would make the jsip produce the exception you just mention above.
Please first check the full source code by this link (line 551~552).
You will see the following code.
String name = configurationProperties.getProperty("javax.sip.STACK_NAME");
So the jsip just find the property to get the sip stack name.
And finally , the answer to this question.
Please add those code in your jsip application.
Properties properties = new Properties();
properties.setProperty("sipper.sip.STACK_NAME", "stack");
Hope this could help you and the viewer from the internet!!!
I recently upgraded my app from Phonegap 1.6 to 2.2.
I've refactored everything (ex Plugin --> CordovaPlugin) and I'm also using the new config.xml.
The app compiles and builds, however I constantly am getting an error in logcat and an error dialog box. The dialog says [ERROR] Error initializing Cordova: Class not found.
The logcat error is:
Line 6048 : Error initializing Network Connection: Class not found
What could I be missing?
The issue happens on multiple devices.
Update
I've already changed the config.xml for the network status plugin from Network Status to NetworkStatus. It reads: <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
I had this problem and made it go away by adding the following to the config.xml:
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
And adding this to the Manifest file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I originally took them out because I "knew" that my app wouldn't be using any communications. I had forgotten about the emulator "communicating" with the ADK.
I'll take these 2 lines out when I convert the project over to "production" so that the app is ready for Google Play.
I had this problem using phonegap 3.x and the problem turned out to be that phonegap hadn't properly installed the plugins, or they just messed up along the way. Basically when you install the plugins and build for a platform it takes the javascript files from plugins/org.apache.cordova.core.specific-plugin/www and puts them in platforms/android/assets/www/plugins/org.apache.cordova.core.specific-plugin/www and then it takes the Java files (or objective C for iOS) and puts them in platforms/android/src/org/apache/cordova/specificplugin
And all of this is specified by plugins/org.apache.cordova.core.specific-plugin/plugin.xml. If you look in a plugins.xml you should see something like:
<source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" />
So this tells you that in platforms/android/src/org/apache/cordova/networkinformation, there should be NetworkManager.java. And right that file can be copied from plugins/org.apache.cordova.core.network-information/src/android/NetworkManager.java
Now all of this is supposed to happen automatically without having to touch the platforms folder. But if it messes up you can fix it by copying the correct java files into the correct folders.
The following line in config.xml works for cordova 6.2 with android
<plugin name="cordova-plugin-network-information" value="org.apache.cordova.networkinformation"/>
The name should be the same as in what your plugin contains. You can find it in the your project folder at the following path plugins/name-of-the-plugin/package.json.
The value should be the package name for the plugin which can be found in the native implementation file.
Findbugs is a great software and my team uses it while working on our Android project. In Eclipse everything is nice and shiny, however now we're trying to automate our builds with ant and generate Findbugs results automatically for each build.
It's seems not that difficult. I followed this tutorial:
https://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project#BuildinganAndroidappandtestproject-FindBugs
One minor issue is that I had to change ${android.jar} to ${project.target.android.jar}.
The worse part are The following classes needed for analysis were missing: warnings for classes that come form library projects we use. Some of them are our own and we would like to scan them with Findbugs, too. To make matters more complicated, one of these libs uses another lib (also our own and needs scanning), so it looks like this:
Project A --uses--> Library B --uses--> Library C
Here I thought that since Android SDK can handle all these dependencies (Library C is compiled when I issue ant debug for Project A), I can somehow make use of it, get the list of libs my project depends on and provide it to the findbugs task. Unfortunately I haven't managed to do that.
For now I settled with manually entering all libs, some into class property of findbugs task, some into auxClasspath, which has the upside that I can only analyse some of the libraries the project depends on. Still I hope that what I originally tried to do is possible. Can anybody show me how to extract a path-element
I've finally found that part of SDK build script that puts together a "classpath" of all the jars (classes.jar-s of all the libraries, including Library C from the "diagram" and jars from the libs/ folder of the project and all the libs).
My final custom-rules.xml with findbugs target looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Project_custom" default="findbugs">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
<target name="findbugs">
<gettarget
androidJarFileOut="project.target.android.jar"
androidAidlFileOut="project.target.framework.aidl"
bootClassPathOut="project.target.class.path"
targetApiOut="project.target.apilevel"
minSdkVersionOut="project.minSdkVersion" />
<dependency
libraryFolderPathOut="project.library.folder.path"
libraryPackagesOut="project.library.packages"
libraryManifestFilePathOut="project.library.manifest.file.path"
libraryResFolderPathOut="project.library.res.folder.path"
libraryBinAidlFolderPathOut="project.library.bin.aidl.folder.path"
libraryNativeFolderPathOut="project.library.native.folder.path"
jarLibraryPathOut="project.all.jars.path"
targetApi="${project.target.apilevel}"
verbose="${verbose}" />
<findbugs home="${findbugs.home}" output="xml" outputFile="findbugs-results.xml">
<auxClasspath>
<pathelement location="${project.target.android.jar}" />
<path refid="project.all.jars.path" />
</auxClasspath>
<class location="${out.dir}" />
</findbugs>
</target>
</project>
Edit: I've upgraded the target to run indepent of the build targets, i.e. now you can run just ant findbugs not ant debug findbugs.
I added some extra definition and worked. Thank you
<target name="findbugs">
<mkdir dir="reports" />
<gettarget
androidJarFileOut="project.target.android.jar"
androidAidlFileOut="project.target.framework.aidl"
bootClassPathOut="project.target.class.path"
targetApiOut="project.target.apilevel"
minSdkVersionOut="project.minSdkVersion" />
<dependency
libraryFolderPathOut="project.library.folder.path"
libraryPackagesOut="project.library.packages"
libraryManifestFilePathOut="project.library.manifest.file.path"
libraryResFolderPathOut="project.library.res.folder.path"
libraryBinAidlFolderPathOut="project.library.bin.aidl.folder.path"
libraryNativeFolderPathOut="project.library.native.folder.path"
jarLibraryPathOut="project.all.jars.path"
libraryRFilePathOut="project.library.rfile.path"
buildToolsFolder="${sdk.dir}/build-tools"
renderscriptSupportLibsOut="project.rs.support.libs.path"
renderscriptSupportMode="${renderscript.support.mode}"
targetApi="${project.target.apilevel}"
verbose="${verbose}" />
<findbugs home="${findbugs.home}" output="xml:withMessages" outputFile="reports/findbugs.xml" excludeFilter="findbugs-exclude.xml" maxRank="9">
<!-- auxClasspath path="${project.target.android.jar}" / -->
<auxClasspath>
<pathelement location="${project.target.android.jar}" />
<path refid="project.all.jars.path" />
</auxClasspath>
<sourcePath path="${basedir}/src/" />
<class location="${basedir}/bin/classes/" />
</findbugs>
</target>
I'like to bind the jar-library of ActionBarSherlock in my Mono For Android project. I am reverencing to this documentation: http://docs.xamarin.com/android/tutorials/Binding_a_Java_Library_(.jar)
I have successfully bound android-support-v4.jar which is needed by ActionBarSherlock. But when I try to compile actionbarsherlock.jar, it gives me the following error message:
Target ResolveLibraryProjects:
Skipping target "ResolveLibraryProjects" because it has no inputs.
Target _ResolveMonoAndroidSdks:
MonoAndroid Tools: C:\Program Files (x86)\MSBuild\Novell\
MonoAndroid Framework: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.2\;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\
Android SDK: C:\Program Files (x86)\Android\android-sdk\
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31\
Target ExportJarToXml:
SourceJars:
Jars\actionbarsherlock.jar
ReferenceJars:
Jars\android-support-v4.jar
C:\Program Files (x86)\Java\jdk1.6.0_31\bin\java.exe -jar "C:\Program Files (x86)\MSBuild\Novell\jar2xml.jar" --jar=C:\Users\assrock\Documents\JavaBind\JavaBind\Jars\actionbarsherlock.jar --ref="C:\Program Files (x86)\Android\android-sdk\platforms\android-8\android.jar" --out=C:\Users\assrock\Documents\JavaBind\JavaBind\obj\Release\api.xml --ref=C:\Users\assrock\Documents\JavaBind\JavaBind\Jars\android-support-v4.jar
Couldn't load class com/actionbarsherlock/internal/ActionBarSherlockNative$ActionModeCallbackWrapper
Couldn't load class com/actionbarsherlock/internal/app/ActionBarWrapper$TabWrapper
Couldn't load class com/actionbarsherlock/internal/app/ActionBarWrapper
Couldn't load class com/actionbarsherlock/internal/view/ActionProviderWrapper
Couldn't load class com/actionbarsherlock/internal/view/menu/MenuItemWrapper$1
Exception in thread "main" java.lang.NoClassDefFoundError: com/actionbarsherlock/R
at java.lang.Class.getDeclaringClass(Native Method)
at jar2xml.JavaClass.getConstructorParameterOffset(JavaClass.java:149)
at jar2xml.JavaClass.appendCtor(JavaClass.java:138)
at jar2xml.JavaClass.appendToDocument(JavaClass.java:462)
at jar2xml.JavaPackage.appendToDocument(JavaPackage.java:66)
at jar2xml.Start.main(Start.java:157)
Caused by: java.lang.ClassNotFoundException: com.actionbarsherlock.R
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
C:\Program Files (x86)\MSBuild\Novell\Xamarin.Android.Bindings.targets(170,5): error MSB6006: "java.exe" exited with code 1.
Task "JarToXml" execution -- FAILED
Done building target "ExportJarToXml" in project "C:\Users\assrock\Documents\JavaBind\JavaBind\JavaBind.csproj".-- FAILED
Done building project "C:\Users\assrock\Documents\JavaBind\JavaBind\JavaBind.csproj".-- FAILED
Build FAILED.
Warnings:
C:\Program Files (x86)\MSBuild\Novell\Xamarin.Android.Bindings.targets(40,11): warning MSB4011: There is a circular reference involving the import of file "c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.Targets". This file may have been imported more than once, or you may have attempted to import the main project file. All except the first instance of this file will be ignored.
Errors:
C:\Users\assrock\Documents\JavaBind\JavaBind\JavaBind.csproj (Build) ->
C:\Program Files (x86)\MSBuild\Novell\Xamarin.Android.Bindings.targets (ExportJarToXml target) ->
C:\Program Files (x86)\MSBuild\Novell\Xamarin.Android.Bindings.targets(170,5): error MSB6006: "java.exe" exited with code 1.
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.4730270
--------------------- Fertig ---------------------
Build: 1 Fehler, 0 Warnungen
For the android-support-v4.jar I found these xml-files and put them in the Transforms directory:
EnumFields.xml
<enum-field-mappings>
<mapping jni-class="android/support/v4/app/FragmentActivity$FragmentTag" clr-enum-type="Android.Support.V4.App.FragmentTagType">
<field jni-name="Fragment_id" clr-name="Id" value="1" />
<field jni-name="Fragment_name" clr-name="Name" value="0" />
<field jni-name="Fragment_tag" clr-name="Tag" value="2" />
</mapping>
</enum-field-mappings>
EnumMethods.xml
<enum-method-mappings>
<mapping jni-class="android/support/v4/app/Fragment$SavedState">
<method jni-name="writeToParcel" parameter="p1" clr-enum-type="Android.OS.ParcelableWriteFlags" />
<method jni-name="writeToParcel" parameter="flags" clr-enum-type="Android.OS.ParcelableWriteFlags" />
</mapping>
</enum-method-mappings>
Metadata.xml
<metadata>
<remove-node path="/api/package[#name='android.support.v4.app']/class[#name='BackStackState']" />
<remove-node path="/api/package[#name='android.support.v4.app']/class[#name='FragmentState']" />
<remove-node path="/api/package[#name='android.support.v4.app']/class[#name='FragmentManagerState']" />
<remove-node path="/api/package[#name='android.support.v4.widget']/class[#name='CursorAdapter']/implements[#name='android.support.v4.widget.CursorFilter.CursorFilterClient']" />
<remove-node path="/api/package[#name='android.support.v4.widget']/class[#name='CursorAdapter']/field[#name='mCursorFilter']" />
<remove-node path="/api/package[#name='android.support.v4.content']/class[#name='AsyncTaskLoader.LoadTask']" />
<!-- FIXME:
This method is an override of another method in the base types.
The base method expects JLO, but this method returns Cursor.
So we somehow have to fill the gap between them.
-->
<remove-node path="/api/package[#name='android.support.v4.content']/class[#name='CursorLoader']/method[#name='loadInBackground']" />
<remove-node path="/api/package[#name='android.support.v4.view.accessibility']/class[#name='AccessibilityNodeInfoCompat.AccessibilityNodeInfoIcsImpl']" />
<remove-node path="/api/package[#name='android.support.v4.widget']/class[#name='CursorAdapter.ChangeObserver']" />
<remove-node path="/api/package[#name='android.support.v4.view.accessibility']/class[#name='AccessibilityNodeInfoCompat.AccessibilityNodeInfoIcsImpl']" />
<remove-node path="/api/package[#name='android.support.v4.view.accessibility']/class[#name='AccessibilityNodeInfoCompat.AccessibilityNodeInfoStubImpl']" />
<remove-node path="/api/package[#name='android.support.v4.view']/interface[#name='ViewPager.OnAdapterChangeListener']" />
<attr path="/api/package[#name='android.support.v4.app']/class[#name='LoaderManager']/method[#name='initLoader']/parameter[#name='p2']" name="type">android.support.v4.app.LoaderManager.LoaderCallbacks</attr>
<attr path="/api/package[#name='android.support.v4.app']/class[#name='LoaderManager']/method[#name='initLoader']/parameter[#name='callback']" name="type">android.support.v4.app.LoaderManager.LoaderCallbacks</attr>
<attr path="/api/package[#name='android.support.v4.app']/class[#name='LoaderManager']/method[#name='initLoader']" name="return">android.support.v4.content.Loader</attr>
<attr path="/api/package[#name='android.support.v4.app']/class[#name='LoaderManager']/method[#name='restartLoader']/parameter[#name='p2']" name="type">android.support.v4.app.LoaderManager.LoaderCallbacks</attr>
<attr path="/api/package[#name='android.support.v4.app']/class[#name='LoaderManager']/method[#name='restartLoader']/parameter[#name='callback']" name="type">android.support.v4.app.LoaderManager.LoaderCallbacks</attr>
<attr path="/api/package[#name='android.support.v4.app']/class[#name='LoaderManager']/method[#name='restartLoader']" name="return">android.support.v4.content.Loader</attr>
</metadata>
ActionBarSherlock includes UI elements, styles, and other things that can't be compiled into a JAR file. There is a note about this on the ActionBarSherlock FAQ.
Q: Why is ActionBarSherlock a library project whereas the original compatibility library is only a .jar?
A: The custom action bar implementation within ActionBarSherlock relies on styles, themes, layouts, and drawables in order to display properly. Due to the limitations of Android and .jar files, this currently can not be accomplished any other way.
Edit: There is some additional information about trying to share resources across library projects in Mono for Android at this link: http://mono-for-android.1047100.n5.nabble.com/Resources-from-a-Library-Project-td4657828.html. Short answer is it doesn't look possible at the moment.
I believe I have successfully bound ActionBarSherlock in Mono for Android.
You need to package the java files as a JAR file but without the resources and without the R java class files. Before you package the files make sure that you check the box in Android settings that says "Is Library" so that the resource IDs are not created as constants and inlined in your compiled java classes.
Once you have done this you can use the latest version of Mono for Android to bind the JAR file.
Resources need to be copied separately from the JAR file and placed directly in the main android application project. Unfortunately, at the present time there is no way to isolate the resources in a separate library project when using Mono for Android, but I expect that will change soon.
Finally, you need to edit your C-Sharp project file so that it automatically creates a new version of the com.actionbarsherlock.R java class file each time you rebuild. This is required to keep all your resource IDs in sync.
I may have missed a step or two but those are the most important ones.
Please see my blog post for more information and a download link with source code:
http://www.craigsprogramming.com/2012/07/actionbarsherlock-with-mono-for-android.html
This may seem like a sledgehammer approach, but will likely solve your problem...
I would suggest building using Maven, which handles these dependencies much better. You will be able to reference the ActionBarSherlock project in your POM, and MVN will manage the dependancies for you.
I can confirm the original answer as correct as well - there is a limitation to including JAR files that contain layout resources.
Looks like Xamarin solved ActionBarSherlock bound issue
https://bugzilla.xamarin.com/show_bug.cgi?id=6186
This fix has included in 4.2.5 which is available on alpha channel now.