Java Android Paint.exe模式崩溃
我在用画布在一些文本的顶部绘制高亮框。我需要将paint blendmode设置为乘法Java Android Paint.exe模式崩溃,java,android,androidx,Java,Android,Androidx,我在用画布在一些文本的顶部绘制高亮框。我需要将paint blendmode设置为乘法 Paint paint = new Paint(); paint.setColor(Color.YELLOW); paint.setBlendMode(BlendMode.MULTIPLY); 但是,这会导致崩溃: java.lang.NoClassDefFoundError:未能解析:Landroid/graphics/BlendMode 这不会发生在我的Oneplus 6T上,因为它工作得非常好。然而,
Paint paint = new Paint();
paint.setColor(Color.YELLOW);
paint.setBlendMode(BlendMode.MULTIPLY);
但是,这会导致崩溃:
java.lang.NoClassDefFoundError:未能解析:Landroid/graphics/BlendMode强>
这不会发生在我的Oneplus 6T上,因为它工作得非常好。然而,在我的LG V10上,这种崩溃发生了
有没有办法解决这个问题
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 24
targetSdkVersion 29
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha01'
implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
implementation 'com.tom_roush:pdfbox-android:1.8.10.1'
implementation files('libs\\YouTubeAndroidPlayerApi.jar')
}
*已解决 很明显,API级别29中引入了setBlendMode requires,这就是为什么它不能在运行Android 7的V10上运行。我发现的解决方案是简单地使用旧的Paint.setXfermode和PorterDuff乘法模式
Paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
请参阅:尝试重建项目并检查它是否正常工作。请也发布build.gradle文件。不幸的是,重建没有帮助。build.gradle已发布。