0
일부 장치에서 테스트 할 때 나는 비트 맵에 흐림 효과를 만들기 위해 안드로이드 지원 RenderScript를 사용하려고하지만, 한 (API 22) 내 응용 프로그램 충돌 두 컨텍스트가 없습니다 다른 SDK 버전 "오류가 발생했습니다.RenderScript : "이 문맥과 다른 지원 lib 디렉토리에 SDK 버전
아무도이 전에 물었다 것을 매우 이상했다!
build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-vector-drawable:23.2.1'
compile 'com.android.support:support-annotations:23.2.1'
compile 'com.android.support:support-v13:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:palette-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
MainActivity.java
이 작업을 수행하려고 할 때 충돌public Bitmap blurImage(Bitmap image) {
final float BITMAP_SCALE = 0.4f;
final float BLUR_RADIUS = 7.5f;
int width = Math.round(image.getWidth() * BITMAP_SCALE);
int height = Math.round(image.getHeight() * BITMAP_SCALE);
Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
theIntrinsic.setRadius(BLUR_RADIUS);
theIntrinsic.setInput(tmpIn);
theIntrinsic.forEach(tmpOut);
tmpOut.copyTo(outputBitmap);
return outputBitmap;
}
:
RenderScript rs = RenderScript.create(context);
기능 및 비트 맵은 모두 동일한 활동에 , 내 질문은 : 두 가지 다른 상황을 일으키는 것은 무엇입니까?
예, 당신은 옳았다! 하지만 지원 모드를 비활성화해야했습니다. 또한 minSdk를 17으로 변경했습니다. android.support.v8.renderscript.RenderScript가 앱을 중단시키고 있습니다. –