Android Visualizer (Audio Effects) runtime exception on Ice Cream Sandwich - android

In the sample AudioFxDemo.java, provided with the SDK, I get a
java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -4
when trying to create the android.media.audiofx.Visualizer
mVisualizer = new Visualizer(mMediaPlayer.getAudioSessionId());
(AudioFxDemo.java:173).
As far as I can see, the error originates in the native code, (lines 266 ff.) An error also happens when trying to create the android.media.audiofx.Equalizer:
mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());
(AudioFxDemo.java:98)
I get a
java.lang.IllegalArgumentException: Effect type: 0bed4300-ddd6-11db-8f34-0002a5d5c51b not supported.
I have declared the following permissions for my project:
<uses-permission android:name="android.permission.RECORD_AUDIO"
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
Any ideas what might be going wrong here?
It seems to be a problem with the API level. I have no problems on Gingerbread (API Level 10). I have only tested on virtual devices.

This seems to be an issue with the Emulator. I have tested on an actual device running Android 4.0.3 and it worked just fine.

it seems issue on some android devices. I got this crash http://pastebin.com/7kqPbxkV on Lenovo a369i SDK version 17. For now only thing i`ve found is to check if equalizer effect is supported on device:
boolean supports_equalizer=false;
AudioEffect.Descriptor [] effects = Equalizer.queryEffects();
for (AudioEffect.Descriptor lDescriptor:effects){
if (Build.VERSION.SDK_INT>=18) { //Equalizer present only starting with API 18. Cam try to hardcode its UUID
if (AudioEffect.EFFECT_TYPE_EQUALIZER.equals(lDescriptor.uuid)){
supports_equalizer=true;
}
}
}

Related

Settings key unreadable on target SDK 32

after migrating the codebase to android 12 target SDK 32, i am trying to get the value of the below settings key
bluetooth_name
but on pixel devices on android 12 i keep getting this crash
Fatal Exception: java.lang.RuntimeException: java.lang.SecurityException: Settings key: <bluetooth_name> is only readable to apps with targetSdkVersion lower than or equal to: 31
from what i've tried so far, there is no extra permission that is needed for this change, also it works completely fine on almost any other device
am i missing something?
There are new restrictions on Android 12, and Bluetooth requires some extra permissions
However, I don't think that it's a permissions issue -- you simply can't access that setting with Android 12 or higher. You'll need to use the BluetoothAdapter class to get the info you need:
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
String name = adapter.getName()

UnsupportedOperationException raised on Android 4.4 when signing/checking signature using SpongyCastle

The following piece of code throws an UnsupportedOperationException when executed on Android 4.4 but it works fine on Android 5 and 6 (tested on device and emulator). The exception is thrown on the setParameter.
Signature signature = Signature.getInstance("SHA256withRSA/PSS", "SC");
PSSParameterSpec spec1 = new PSSParameterSpec("SHA-256", "MGF1", new MGF1ParameterSpec("SHA-256"), 32, 1);
signature.setParameter(spec1);
I am using Spongy Castle to be able to use SHA256withRSA/PSS.
Any idea why?
In the android open source project issue 63139 documents this exact error. This occurs for any android version below 5.0. Specifically, "The implementation of private static SignatureImpl class(line 590) lacks one of the engineSetParameter implementations." Please read the issue report for more information.
https://code.google.com/p/android/issues/detail?id=63139

Looking for a list of methods that cause Android API 23 (Marshmallow) to throw the permission needed SecurityException

Has the Android team posted a list of methods that cause Android API 23 (Marshmallow) to throw a SecurityException when a permission is needed?
Something like:
RECORD_AUDIO throws SecurityException on the following methods:
SpeechRecognizer.startListening
etc.
As of now, we're just wandering around our app trying to best-guess when this will happen. Some devices are throwing this exception when others aren't -- as well as the emulator.
EDIT:
Issue solved. This is a problem with Xamarin Studio as it does not flag function calls that need a permissions check. I recently created a project in Android Studio and it red-underlines function calls that need a permissions check.

Very simple WebView crashes under API 23 Emulator

I have just created an API 23 emulator on my machine:
HAXM: v1.4 with 1GB allocated RAM
AVD Base: Nexus 4
RAM: 768MB, and 896MB in a second try
Heap: 64 MB
GPU acceleration: no
I tried it successfully with a few apps of my own. But each time I try an application that uses a WebView as a UI, the app crashes that way:
The three first line of this logcat are the only pertaining to my app (highlighted in blue). All other lines do not mention my application package's name in the 'Application' column of LogCat, but one does in the middle of the message (circled in blue).
I can load the HTML code into the WebView. The crash occurs at setContentView(theWebView) time:
public class MyActivity extends Activity {
private WebView mWebview = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWebview = new WebView(this);
mWebview.loadDataWithBaseURL("file:///android_asset/", HTML_CODE, "text/html", "UTF-8", null);
setContentView(mWebview); // THIS IS WHERE THE CRASH OCCURS
}
[...]
Using or not using runOnUiThread() to run mWebview.loadDataWithBaseURL() produces exactly the same result, which is expected as onCreate() is actually on the UI thread.
The html code I am using does not change anything. In the case above, the HTML_CODE variable contains this:
<html>
<head></head>
<body>
<h1>Hello</h1>
<p>Hello world!</p>
</body>
</html>
The app runs perfectly, even with a more advanced HTML+CSS+JS+JS<->Java binding code on all the API 17 and 19 devices and emulators I tried. This is where I'm puzzled. I didn't have a chance to try with an actual Android 6.0 (API 23) device though.
EDIT
I have just :
migrated from Eclipse to Android Studio
upgraded HAXM to v1.5
upgraded my SDK Tools (24.4.1) and my platform (23.0.1)
The problem still occurs but the log is different, and a bit clearer. There is a ClassNotFoundException I cannot explain:
10-28 20:26:05.102 2168-2168/com.example.myapp W/System: ClassLoader referenced unknown path: /data/app/com.example.myapp-1/lib/x86
10-28 20:26:08.583 2168-2168/com.example.myapp E/DataReductionProxySettingListener: No DRP key due to exception:java.lang.ClassNotFoundException: com.android.webview.chromium.Drp
10-28 20:26:09.393 2168-2213/com.example.myapp W/chromium: [WARNING:data_reduction_proxy_config.cc(423)] SPDY proxy OFF at startup
10-28 20:26:12.521 2168-2286/com.example.myapp A/chromium: [FATAL:gl_surface_android.cc(58)] Check failed: kGLImplementationNone != GetGLImplementation() (0 vs. 0)
10-28 20:26:12.521 2168-2286/com.example.myapp A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 2286 (GpuThread)
Any idea? (I'm investigating further so I will update this post should I find anything relevant)
This behaviour was not caused by any erroneous setting of the AVD or any missing prerequisite (harware, etc...).
As cryptojuice mentioned in comments this was caused by an OpenGL ES prerequisite issue on emulator side:
#8 ...#chromium.org
Unfortunately OpenGL ES 2.0 support has been mandatory for devices
since at least Android 4.0, so we haven't ever explicitly supported
GLES 1.x at all and it was only working before by accident :/
It seems a bit problematic that the emulator (without host GPU
emulation) doesn't meet the minimum requirements for Android devices.
We might be able to work around this for the emulator at a significant
performance cost; we're talking to the emulator team about what the
best thing to do here is.
Now this is fixed (SDK tools 25.1 RC1 / platform 23 rev 3), even though this doesn't appear on the ticket linked above.

Android Camera NoSuchMethodError on Exposure Lock

I am getting a NoSuchMethodError on Camera.Parameters.isAutoExposureLockSupported()
How can this be avoided?
I am using:
android:minSdkVersion="8"
android:targetSdkVersion="17"
running application on HTC Wildfire S with Android 2.3.5
isAutoExposureLockSupported() was added in API level 14.
You will need minSDKVersion to be 14 if you want to use this. Your HTC Wildfire S with Android 2.3.5 has no idea about this method.
To fix, you can raise the minimum required SDK version in your manifest, or don't use it in lower versions by doing a version check at runtime.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
// call isAutoExposureLockSupported() and do whatever you need
}

Categories

Resources