Is it possible to use AndroidAnnotations with the Scala programming language and the Gradle build system? When I try to integrate AndroidAnnotations into my existing Android/Scala/Gradle project, then compilation fails because the generated underscore classes (e.g. MyActivity_) cannot be found.
Here are some useful starting points and references:
http://www.scala-lang.org/node/4773 (2010-01-06)
http://www.scala-lang.org/sid/5 (2010-01-27)
http://code.google.com/p/androidannotations/wiki/Configuring (2011-07-28)
http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/ch08.html#d0e2816 (2010?)
Java 6 annotation processing configuration with Ant (2010-09-05)
http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#processing
http://ant.apache.org/manual/Tasks/apt.html
Generating JPA2 Metamodel from a Gradle build script (2011-06-22)
http://download.oracle.com/javase/1.5.0/docs/guide/apt/GettingStarted.html
During my quest to solve this problem, I added some research links to my original question post. The AndroidAnnotations annotation processor generates source code (Java files). Annotation processors in general seem to operate at the source code level (and not class files). I am expecting AndroidAnnotations to generate Java code from Scala source files. Scala doesn't seem to support the Java annotation processing tool. So my answer to this question would be: it is not possible to use AndroidAnnotations with Scala source code. However, AndroidAnnotations may still be used in the Java source code in a Scala mixed-source project.
Regarding Gradle (without Scala), it seems that someone managed to use it with AndroidAnnotations, here: Adapt AndroidAnnotations Maven settings to Gradle
Related
I have an Android.mk file and I was trying to make a build for Android 8.1 where I was using RxJava but while building it, I was getting the error
Lambda coming from jar file need their interfaces on the classpath to be compiled
so, I searched a lot and found that
"ANDROID_COMPILE_WITH_JACK:=false"
fixes the issue but I want to know how and why it is like that.
I found on https://source.android.com/setup/build/jack that Jack supports Java programming language 1.7 and lambda(in rxJava) is 1.8 feature so is it causing the problem? That is why I need to disable the compilation?
I am wondering if the ButterKnife framework which has Annotation Processors could work with scala sbt?
Scala doesn't seem to support the Java annotation processing tool As shown is this answer
During my quest to solve this problem, I added some research links to my original question post. The AndroidAnnotations annotation processor generates source code (Java files). Annotation processors, in general, seem to operate at the source code level (and not class files). I am expecting AndroidAnnotations to generate Java code from Scala source files. Scala doesn't seem to support the Java annotation processing tool. So my answer to this question would be: it is not possible to use AndroidAnnotations with Scala source code. However, AndroidAnnotations may still be used in the Java source code in a Scala mixed-source project.
this is an old answer but I doubt that any thing has changed then.
but in scala, you can use an even better method to bind your layout using TYPED RESOURCES (TR)
I have two existing native libraries that I would like to integrate into an Android project. One has a working Android.mk file and the other has a working CMakeList.txt file. Is there a clean way to link both to Gradle?
Using CMake's ExternalProject[1] is the only idea I have at the moment.
[1] https://cmake.org/cmake/help/v3.0/module/ExternalProject.html
The solution that I arrived at was to add an additional Gradle module to build the ndk-build project. In Gradle terms the project would become a multi-project/multi-module build and is discussed further here [1]. I was also able to express the dependency in Gradle and the project built without issue.
My initial thought of using CMake's ExternalBuild failed under Gradle, but would build fine when invoking CMake from the command line. This probably had something to do with my lack of knowledge in Gradle and CMake.
[1] https://speakerdeck.com/bmuschko/state-of-the-art-gradle-multi-module-builds
I might have what you need. There is an all c++ sample that involves no JAVA UI which is actually a big thing because now your main (entry point) is in a c++ file - you can do OOP and depend on 3rd party libraries without much hassle.
Check out my repo: https://github.com/skanti/Android-Manual-Build-Command-Line
I'm trying to use spring-context in an Android project and have gotten as far as trying to load a context file. I'm getting this error:
Your JAXP provider ... does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
I've found partial answers from a couple years ago indicating the fix is to include Xerces in my project.
I'm using Android Studio, which forces me to use Gradle. I can't for the life of me figure out what to use as the classpath to include Xerces in Gradle. Does anyone know what it is? Is Xerces even available to Gradle? Is there some newer, easier fix that I've missed?
Was that the only thing you wanted? :)
'xerces:xercesImpl:2.11.0'
Xerces extends the core library javax.*. Extending core libraries is not allowed in Android. However you can use --core-library to suppress these warnings. However, this is not recommended. For more information see this.
You can overcome this problem by repackaging the needed classes with a tool like JarJar. This has been done in the Xerces-for-Android, wherein the package mf is placed above the "normal" Xerces packages.
I am trying to build an Android project with Scala sources in IntelliJ IDEA (Community Edition). I am using Scala sources from Java files: auto-complete works correctly, but build cannot resolve Scala classes in Java: cannot find symbol class MyScalaClass.
(I managed that in Eclipse, but Scala support in Eclipse is poor.)
Any hints or tutorials?
Update: I have added Scala module in addition to Android module. Now, build fails during generating classes.dex with message:
Error: trouble writing output: format == null
I found that it is a limitation of Dalvik: issue 7147.
How can I strip unused methods/classes in IDEA without using Ant script? (I was using ProGuard in Ant script, but I was unable make IDEA to parse Scala error messages from Ant results.)
The scala/java system requires that you:
- Build scala first, giving the compiler both scala and java files.
- Build the java sources with the compiled scala classes in the path for javac.
The second is probably what you lack. Refer to how to add directory to classpath in an application run profile in intellij idea? to add a classpath to Intellij (I suppose you did it for the android runtime, so you probably already know it).
You should use ProGuard to strip down unused classes.
Follow the instructions here (Specifically take a look at the progaurd-project.txt:
https://github.com/yareally/android-scala-intellij-no-sbt-plugin