I have a Xamarin Forms (1.3-pre1) application, which needs to integrate with Office 365. In my Android project, my build breaks when I reference the NuGet package in subject (https://www.nuget.org/packages/Microsoft.Office365.OAuth.Xamarin/)
After this package is referenced, I get following error at the end of my build:
3> UNEXPECTED TOP-LEVEL EXCEPTION:
3> java.lang.IllegalArgumentException: already added: Landroid/support/v4/util/TimeUtils;
3> at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
3> at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
3> at com.android.dx.command.dexer.Main.processClass(Main.java:732)
3> at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
3> at com.android.dx.command.dexer.Main.access$300(Main.java:82)
3> at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
3> at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
3> at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
3> at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
3> at com.android.dx.command.dexer.Main.processOne(Main.java:632)
3> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
3> at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279)
3> at com.android.dx.command.dexer.Main.run(Main.java:245)
3> at com.android.dx.command.dexer.Main.main(Main.java:214)
3> at com.android.dx.command.Main.main(Main.java:106)
3> 1 error; aborting
3>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1243,3): error MSB6006: "java.exe" exited with code 1.
3>Done executing task "CompileToDalvik" -- FAILED.
3>Done building target "_CompileDex" in project "KwhApp.Forms.Android.csproj" -- FAILED.
3>
3>Build FAILED.
Removing the package reference, I get my build to complete instead.
Anyone having the same issue? Any suggestion?
Ah ok. I checked with the engineering folks, and they're aware of the issue. Details (and a workaround) here: http://chakkaradeep.com/index.php/getting-started-with-office-365-apis-and-xamarin-projects/.
I had that problem after update android packages.
My solution was opening packages.config in Android project and remove android support v4 from xml:
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid70" />
After that, I go to package folder. and add it again from nuget. When I do that, new Android packages was added. And project build and run again.
Hope this help.
Related
I get some very unhelpful errors from Qt creator, which I have just installed using tutorial on Qt website.
-dex:
[dex] input: D:\techsys\build-androidtest-Android_for_armeabi_v7a_GCC_4_9_Qt_5_5_1-Debug\android-build\bin\classes
[dex] input: D:\techsys\build-androidtest-Android_for_armeabi_v7a_GCC_4_9_Qt_5_5_1-Debug\android-build\libs\QtAndroid-bundled.jar
[dex] input: D:\techsys\build-androidtest-Android_for_armeabi_v7a_GCC_4_9_Qt_5_5_1-Debug\android-build\libs\QtAndroidAccessibility-bundled.jar
[dex] Pre-Dexing D:\techsys\build-androidtest-Android_for_armeabi_v7a_GCC_4_9_Qt_5_5_1-Debug\android-build\libs\QtAndroid-bundled.jar -> QtAndroid-bundled-15710ac48ee3b8e0790e2c0724eced85.jar
[dx] Error occurred during initialization of VM
[dx] Could not reserve enough space for object heap
[dx] Error: Could not create the Java Virtual Machine.
[dx] Error: A fatal exception has occurred. Program will exit.
BUILD FAILED
C:\Users\mareda\AppData\Local\Android\android-sdk\tools\ant\build.xml:888: The following error occurred while executing this line:
C:\Users\mareda\AppData\Local\Android\android-sdk\tools\ant\build.xml:890: The following error occurred while executing this line:
C:\Users\mareda\AppData\Local\Android\android-sdk\tools\ant\build.xml:902: The following error occurred while executing this line:
C:\Users\mareda\AppData\Local\Android\android-sdk\tools\ant\build.xml:283: null returned: 1
Total time: 1 second
Building the android package failed!
-- For more information, run this command with --verbose.
11:50:50: The process "C:\Qt\android.5.5.1\5.5\android_armv7\bin\androiddeployqt.exe" exited with code 14.
Error while building/deploying project androidtest (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.5.1))
When executing step "Build Android APK"
11:50:50: Elapsed time: 00:05.
I don't really get what does it mean. This is my configuration:
I also tried selecting Use Gradle instead of Ant. it didn't affect anything. What expecially freaks me out is the awkward error: The following error occurred while executing this line: without mentioning any actual error.
Here is how to fix it:
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System Variables->New:
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
Variable name: Path
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;
Change this to your appropriate path.
The problem related with memory. You must have enough RAM on system. If not then please add large swap. This would allow dx to complete build and not die in middle. I was facing this issue on small VPS node. Now its fixed.
My android project has only aidl file, project structure is like below:
MyProject/
src/
main/
com.my.aidl/
IMyService.aidl
pom.xml
I am building my android project with maven. My pom uses the dexguard-maven-plugin which is an extension of android-maven-plugin.
In plugin configuration, I explicitly specified the directory of source aidl file & the directory of generated java file.
<build>
<plugins>
<plugin>
<groupId>com.saikoa.dexguard.maven</groupId>
<artifactId>dexguard-maven-plugin</artifactId>
<configuration>
<aidlSourceDirectory>
${project.basedir}/src/main/com/my/aidl
</aidlSourceDirectory>
<genDirectoryAidl>
${project.build.directory}/generated-sources/aidl/main/com/my/aidl
</genDirectoryAidl>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
But after I run mvn clean install -e I got the following error trace:
[ERROR] Failed to execute goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources (default-generate-sources) on project MyProject: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources (default-generate-sources) on project MyProject: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:6.1.18:generate-sources failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.NullPointerException
at java.io.File.<init>(File.java:334)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.generateAidlFiles(GenerateSourcesMojo.java:1266)
at com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo.execute(GenerateSourcesMojo.java:343)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
... 20 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
What is wrong?
Had a similar issue few months ago where I was placing my call related aidl files to incorrect location (I migrated form Eclipse ANT to Studio Gradle).The link below helped in my case:how can I add the aidl file to Android studio (from the in-app billing example)And official document related to that:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure
Depend on your log message, there has a nullexception. I guess the directory is not right. Have you try to change the genDirectoryAidl from 'generated-sources/aidl/main/com/my/aidl' to 'generated-sources/aidl/'? Maybe if you make a directory named 'main/com/my/aidl' you will succeed.
Hope this message can help you.
As I can see is a NullPointerException possibly caused by some unresolved dependencies. Here is a link for similar issue.
Also try to re-run maven with -X and show us the debug output.
i have just a blank project with prime31 google play game services plugin in it and im trying to run the demo scene and i keep getting this error, i feel like its something simple like setting environment variables or something, any help is greatly appreciated thank you
Error building Player: CommandInvokationFailure: Unable to convert
classes into dex format. See the Console for details. C:Program Files
(x86)Javajdk1.7.0_51binjava.exe -Xmx1024M
-Dcom.android.sdkmanager.toolsdir="C:/Users/John P. Rowan III/android-sdkstools" -Dfile.encoding=UTF8 -jar "C:/Program Files
(x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayersdktools.jar" -
stderr[
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic
(00051607) or version (0000.0002) at
com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at
com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at
com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at
com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665) at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:634) at
com.android.dx.command.dexer.Main.access$600(Main.java:78) at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572) at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596) at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:498) at
com.android.dx.command.dexer.Main.runMonoDex(Main.java:264) at
com.android.dx.command.dexer.Main.run(Main.java:230) at
com.android.dx.command.dexer.Main.main(Main.java:199) at
com.android.dx.command.Main.main(Main.java:103) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
SDKMain.main(SDKMain.java:129) ...while parsing
__MACOSX/com/google/android/gms/ads/._a.class
1 error; aborting
Interesting as for environment variables, no, that will only help you find files that are missing, in this case we have a parsing error in your plugin.
There are multiple things you can try to resolve it, one weird thing i notice in the log was the path to java: C:Program Files (x86)Javajdk1.7.0_51binjava.exe There are no dashes "\" in the path, might be wrong but that might be neeeded.
Secondly, if you open the project in eclipse and try to compile it from there, if it still gets you error's you might want to contact prime31 for support, since this is a parsing error in the code, which you can see from the log.
"UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.cf.iface.ParseException: bad class file magic " means that there are lines or characters in places that do not belong there.
I just started trying to use Felix with Android. I followed the instruction at Apache Felix homepage (http://felix.apache.org/site/apache-felix-framework-and-google-android.html), but failed at very first steps.
After setting path for Android SDK, I executed this command:
dx --dex --output=classes.dex felix.jar
But the exception came out:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.io.FileNotFoundException: felix.jar (The system cannot find the file specif
ied)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:214)
at java.util.zip.ZipFile.<init>(ZipFile.java:144)
at java.util.zip.ZipFile.<init>(ZipFile.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:206)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
at com.android.dx.command.dexer.Main.processOne(Main.java:422)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
at com.android.dx.command.dexer.Main.run(Main.java:209)
at com.android.dx.command.dexer.Main.main(Main.java:174)
at com.android.dx.command.Main.main(Main.java:91)
1 error; aborting
I am sure that the file felix.jar was there. This is what I got from dir command:
Directory of D:\QuangND\OSGi\felix-framework-4.2.1\bin
08/30/2013 11:11 AM <DIR> .
08/30/2013 11:11 AM <DIR> ..
03/08/2013 10:19 PM 529,233 felix.jar
1 File(s) 529,233 bytes
2 Dir(s) 198,324,461,568 bytes free`
What is problem here? Thank you very much! (Sorry for my bad English :()
OK, I solved this problem. I need to start dx command from where it located (in sdk/platform-tools), not everywhere
I am trying to run Emma on the tests for an Android project that is a combination of Java and C/JNI code. The build and tests work fine, but whenever I add emma, I get a mysterious exception. I'm using the Android SDK v20.1 and NDK r8b.
The project is here, its an Android library project:
https://github.com/guardianproject/IOCipher
and the tests are here:
https://github.com/guardianproject/IOCipherTests
The build.xml file is generated using android update test-project. Running ant clean debug install test works everytime while ant clean emma debug install test triggers the exception:
here's the exception:
-dex:
[dex] Converting compiled files and external libraries into /var/lib/jenkins/workspace/IOCipherTests/IOCipherTests/bin/classes.dex...
[dx]
[dx] EXCEPTION FROM SIMULATION:
[dx] local variable type mismatch: attempt to set or access a value of type int using a local variable of type info.guardianproject.libcore.io.ErrnoException. This is symptomatic of .class transformation tools that ignore local variable information.
[dx]
[dx] ...at bytecode offset 0000002e
[dx] locals[0000]: Linfo/guardianproject/iocipher/File;
[dx] locals[0001]: Linfo/guardianproject/iocipher/FileDescriptor;
[dx] locals[0002]: <invalid>
[dx] locals[0003]: <invalid>
[dx] locals[0004]: <invalid>
[dx] locals[0005]: [Z
[dx] stack[top0]: int{0x00000001 / 1}
[dx] ...while working on block 002c
[dx] ...while working on method createNewFile:()Z
[dx] ...while processing createNewFile ()Z
[dx] ...while processing info/guardianproject/iocipher/File.class
[dx]
[dx] 1 error; aborting
BUILD FAILED
/opt/android-sdk/tools/ant/build.xml:850: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:852: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:864: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:266: null returned: 1
I was getting the same error. In my project we had a unit test app in one project, which wrapped another project containing the unit tests themselves. Both projects held references to my SDK which, as chaitanya suggested, was causing emma to instrument the SDK code twice. By removing the reference to the SDK in the unit test project I was able to resolve the error.
I build the Android APK project from the command line (without ant, but with some help of CMake. I guess this is not important here) and I met the same error, two things helped me:
From here, I got the info that "If you instrument class files that have local variable debug information in them emma does not correctly maintain the local variable table. This will cause an error when you try to convert the class files for Android. The workaround for this to compile the java classes with only line and source debug information, not local information.", so I add a flag to java compiler-g:{lines,source}
I also excluded Emma classes itself from instrumentation. My instrumentation command is java -cp emma/emma_device.jar emma instr -ix -*.test.*,-com.google.android.*,-com.vladium.* -m overwrite -cp ${CMAKE_JAVA_TARGET_OUTPUT_DIR}. Pay attention to -ix -com.vladium.* parameter, this excludes Emma classes