I am trying to extend android.hardware.audio#2.0::IDevicesFactory to add a new Audio HAL.
So I copied whole 2.0 folder into 2.1 folder, and attempted to extend interface. This is my new IDevicesFactory.hal file:
package android.hardware.audio#2.1;
import android.hardware.audio#2.0::types;
import android.hardware.audio#2.0::IDevicesFactory;
import android.hardware.audio.common#2.0;
import IDevice;
interface IDevicesFactory EXTENDS android.hardware.audio#2.0::IDevicesFactory {
typedef android.hardware.audio#2.0::Result Result;
enum Device : int32_t {
PRIMARY,
A2DP,
USB,
R_SUBMIX,
STUB,
MY_HAL
};
};
[Removed code commentary for readability]
I only wish to add MY_HAL into that enum.
I don't know if I need to extend all interfaces, but I will do that. I will also modify all sources in my 2.1 folder to use #2.1 HIDL (namespaces and types etc).
I tried running hardware/interfaces/update-makefiles.sh and it throws following error:
gps#gps-HP-280-G3-MT:~/andsrc/android-8.0.0_r12$ hardware/interfaces/update-makefiles.sh
Updating makefiles for android.hardware in hardware/interfaces.
Updating android.hardware.audio#2.0
Updating android.hardware.audio#2.1
ERROR: syntax error at hardware/interfaces/audio/2.1/IDevicesFactory.hal:8.27-33
ERROR: syntax error at hardware/interfaces/audio/2.1/IDevicesFactory.hal:19.2
ERROR: Could not parse android.hardware.audio#2.1::IDevicesFactory. Aborting.
I do not understand why is there a Syntax error. Can someone guide me what I missed?
I found my issue.
I misinterpreted the grammar for HIDL, and used upper case EXTENDS instead of lower case extends
Related
The app defines constants in a Kotlin singleton object:
#file:JvmName("APIConstants")
package com.myapp.api
object APIConstants {
const val HTTP_RESPONSE_CODE_NOT_AUTHORIZED = 401
etc....
}
They are then used in another class:
import com.myapp.api.APIConstants.HTTP_RESPONSE_CODE_NOT_AUTHORIZED
etc ...
class API {
private fun returnBadResponse(response: Response<*>, callback: ApiAuthListener<*>) {
if (response.code() == HTTP_RESPONSE_CODE_NOT_AUTHORIZED) {
callback.onBadAuthToken()
} else {
callback.onFailure(response.message(), getServerError(response))
}
}
In this class Android Studio (3.0 beta) provided a hint to add the import for the constant, and it does not give any indication of a problem (no red underlines etc, and the constant reference in the method is shown in purple italic text indicating it has been resolved) but when I build the project I get this:
Error: Unresolved reference: HTTP_RESPONSE_CODE_NOT_AUTHORIZED
I've tried clearing the IDE cache and restarting it, and doing a clean build, which make no difference. I've tried removing the #JvmName annotation and even placing the const values in the root of the file with no containing object but neither allows a build.
Why is the class failing to reference the constant, especially when the IDE strongly suggests it can resolve it?
And the solution is.... to make very sure all Kotlin source files have a .kt file extension! In this case the APIConstants file was called "APIConstants" and not "APIConstants.kt" which appears to mean the IDE was able to resolve references based on the content of the file, but the build tools could not. Confusingly Android Studio showed a Kotlin K icon on the filename despite the lack of a .kt extension.
I have such aidl file:
package com.my.service;
import com.my.common.rpc.OnNextListener;
interface IService {
oneway void acceptStateListener(in OnNextListener l);
}
And I got an error in my Android Studio:
AIDLTokenType.IDENTIFIER expected, got 'rpc'
What's wrong here? Where I can find definitive tutorial about AIDL syntax?
It seems issue with the string "rpc" in your package name. Please rename it, it should work fine. I got similar error for the string "in" in my package.
I would like to use the Scala (2.11) reflection package's runtime mirror in a Scala application compiled for android which is being build using Scala on android.
I was able to fiddle with ProGuard options in order to make it include the required Scala classes. However when I try to get a mirror instance:
universe.runtimeMirror(this.getClass.getClassLoader)
(Indeed it fails during the lazy computation of universe)
The application crashes in run time:
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/rmi/Remote;
at scala.reflect.internal.Definitions$DefinitionsClass.RemoteInterfaceClass$lzycompute(Definitions.scala:370)
at scala.reflect.internal.Definitions$DefinitionsClass.RemoteInterfaceClass(D efinitions.scala:370)
at scala.reflect.runtime.JavaUniverseForce$class.force(JavaUniverseForce.scal a:255)
at scala.reflect.runtime.JavaUniverse.force(JavaUniverse.scala:16)
at scala.reflect.runtime.JavaUniverse.init(JavaUniverse.scala:147)
at scala.reflect.runtime.JavaUniverse.<init>(JavaUniverse.scala:78)
at scala.reflect.runtime.package$.universe$lzycompute(package.scala:17)
at scala.reflect.runtime.package$.universe(package.scala:17)
This crash is for me as expected as it isn't:
It is expected as java.rmi is not part of the Android API and I should expect any code trying to load its classes to crash.
It is unexpected as I didn't know that Scala's reflect package used java.rmi
I have traced the code to were rmi is required, that is to JavaUniverse (a trait mixed in JavaUniverse class) force method:
...
definitions.RemoteInterfaceClass
...
Which leads to DefinitionsClass:
lazy val RemoteInterfaceClass = requiredClass[java.rmi.Remote]
Am I wrong to think that this is a no-go for Scala reflection in Android?
If I am, what could be a workaround to this problem?
To summarize your solution and a related solution, it is sufficient to add two files, and modify build.sbt to include:
dexAdditionalParams in Android += "--core-library"
Add java/rmi/Remote.java to your project with the content:
package java.rmi;
public interface Remote {}
Add java/rmi/RemoteException.java to your project with the content:
package java.rmi;
public interface RemoteException {}
i am working on one of C++ Application, where i need to interface with Android Source Code, i got this Source Code from below URL
https://github.com/android
Now When i am Compiling my application which uses Camera module, then it has many dependencies like utils,binder,gui,system. by this way i am including every header files which camera module of Android depends depends on.
but i am stuck with following error:
In file included from jni/headers/camera/ICamera.h:22:0,
from jni/headers/MyCamera.h:4,
from jni/headers/VideoWrapper.h:4,
from jni/src/com_example_jnitest_VideoJava.cpp:2
jni/headers/binder/Parcel.h:31:7: error: template argument
required for 'class Flattenable'
class Flattenable;
^
jni/headers/binder/Parcel.h:105:37: error: invalid use of
template-name 'android::Flattenable' without an argument list
status_t write(const Flattenable& val);
^
jni/headers/binder/Parcel.h:160:30: error: 'Flattenable' is not a type
status_t read(F
my Question is:How to get out of this error??
Whenever Any class Template need to be pre-declaration in another class or Anywhere then we need to give it with template
e.g:
in Parcel.h file of Android source, pre-declaration of class Flattenable is done as below:
class Flattenable;
but actually it should be:
template <typename T> class Flattenable;
because class Flattenable is Template class.
However i Amazed how this things not taken care into Android Source Code..!!
Iam trying to bind a jar(zubhium sdk jar) file to my mono droid project. I have followed their guide on xamarins website and created a new binding project which I reference I my mono droid project.
I am having some issues with package names. I get the following error:
Error 3 package com.zubhium.interfaces does not exist
com.zubhium.interfaces.ZubhiumListener
C:\Users\jbp\Desktop\ny\CmsApp.Droid\obj\Debug\android\src\mono\com\zubhium\interfaces\ZubhiumListenerImplementor.java 8 25 CmsApp.Droid
from the genrated source:
package mono.com.zubhium.interfaces;
public class ZubhiumListenerImplementor
extends java.lang.Object
implements
mono.android.IGCUserPeer,
com.zubhium.interfaces.ZubhiumListener
And that is because when the project is wrapped it automaticly adds mono(.com.zubhium....) to the package name. I cant find how to remove this mono or if i can set a rule to add this part.
I tried to put <attr path="/api/package[#name='com.zubhium.interfaces']" name="managedName">mono.com.zubhium.interfaces</attr>
in the xmldata.xml file but that did not work.
Do you guys have any sugestions?
Regards
package com.zubhium.interfaces does not exist
When you bind a .jar library and reference the binding project from another project, you need to also add the .jar to your Application project and set its Build action to AndroidJavaLibrary.
Failure to do so means that the .jar won't be added to the javac $CLASSPATH, resulting in javac compilation errors when compiling the Android Callable Wrapper (as you saw), and that the .jar won't included into your final .apk. Both of these are Badâ„¢.
And that is because when the project is wrapped it automaticly adds mono(.com.zubhium....) to the package name.
That's for an "Implementor" type; you can ignore it. It's used as part of the implementation of events. If you look at the generated C# code, there should be:
[global::Android.Runtime.Register ("mono/com/zubhium/interfaces/ZubhiumListenerImplementor")]
internal sealed class ZubhiumListenerImplementor : Java.Lang.Object, IZubhiumListener {
// ...
}
The mono.com.zubhium.interfaces.ZubhiumListenerImplementor is the ACW for the internal ZubhiumListenerImplementor type.
You can't rename this type; it's an internal construct that isn't controlled via metadata.