gpt4 book ai didi

安卓工作室 : App works on API 29 but crash on API 26

转载 作者:行者123 更新时间:2023-12-02 06:59:49 24 4
gpt4 key购买 nike

该应用程序在 API 29 模拟器和 API 24 手机上运行良好,没有任何意外行为,但在 API 26 中崩溃。应用程序在启动时崩溃。在闪屏之后。 我对android还很陌生,我不明白为什么会这样。

我的日志:

    --------- beginning of crash
2020-03-21 03:22:09.496 21362-21362/com.codebees.scaner E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.codebees.scaner, PID: 21362
java.lang.RuntimeException: Canvas: trying to draw too large(113550336bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)
at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:97)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:529)
at android.widget.ImageView.onDraw(ImageView.java:1367)
at android.view.View.draw(View.java:20373)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
at android.view.View.draw(View.java:20376)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20376)
at com.android.internal.policy.DecorView.draw(DecorView.java:980)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:800)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3496)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3283)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2818)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7827)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

它说“试图绘制太大(113550336bytes)的位图。”但我不知道是哪一个,因为我只有 xml drawable 和 2 png

我的 Gradle :
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"

defaultConfig {
applicationId "com.codebees.scaner"
minSdkVersion 19
targetSdkVersion 29
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'
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.zxing:core:3.2.1'
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'

}

任何帮助都感激不尽。谢谢 !

编辑:我发现哪个 png 导致了问题,但我不知道如何解决它,我评论 ImageView 进行测试,它不再崩溃。
这是原因中的 ImageView:
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/cross"
tools:ignore="ContentDescription" />

可绘制的十字架是 1776x1776 alpha png,但它有发光效果
我虽然我必须矢量化它,但我会失去我的发光效果

最佳答案

我通过将我的 png 减小到 1024x1024 和 70kb 大小来解决这个问题

似乎现在可以工作

关于安卓工作室 : App works on API 29 but crash on API 26,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60789362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com