I'm running Ubuntu 16.04. And on Android Studio when I try to run my application in the emulator I get the following error:
我正在运行Ubuntu 16.04。在Android Studio上,当我尝试在模拟器中运行我的应用程序时,我收到以下错误:
FATAL EXCEPTION: main Process: project name here, PID: 2528 java.lang.RuntimeException: Canvas: trying to draw too large(216090000bytes) bitmap. at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260) at android.graphics.Canvas.drawBitmap(Canvas.java:1415) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:528) at android.widget.ImageView.onDraw(ImageView.java:1316) at android.view.View.draw(View.java:17185) at android.view.View.updateDisplayListIfDirty(View.java:16167) at android.view.View.draw(View.java:16951) at android.view.ViewGroup.drawChild(ViewGroup.java:3727) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at android.view.View.updateDisplayListIfDirty(View.java:16162) at android.view.View.draw(View.java:16951) at android.view.ViewGroup.drawChild(ViewGroup.java:3727) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at
etc...致命异常:主进程:项目名称,PID:2528 java.lang.RuntimeException:Canvas:尝试绘制太大(216090000bytes)的位图。在Android.graphics.Cravas.drawBitmap(Canvas.java:1415)的android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)在android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:528)。在android.view.View.draw.draw.Go.Arp(View.java:16167)上的android.view.View.draw(View.java:16185)上的widget.ImageView.onDraw(ImageView.java:1316) (View.java:16951)位于android.view.View的调查表中的android.view.ViewGroup.DispatchDraw(ViewGroup.java:3513)的android.view.View.View.David:View.java: 16162)在android.view.View.draw.draw(View.java:16951)的android.view.ViewGroup.drawChild(ViewGroup.java:3727)android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)等处。 ..
I did have to run through some hoops to get my emulator working however, needed to create a sym-link so I can run the emulator on AMD. Not sure if this is part of the problem. And for the life of me I cannot figure why it continues to do this. In my group there are others who emulate the project just fine on the same emulated phone and SDK.
我确实需要通过一些箍来让我的模拟器工作,但是需要创建一个sym-link,这样我才能在AMD上运行模拟器。不确定这是否是问题的一部分。而对于我的生活,我无法理解为什么它继续这样做。在我的小组中,还有其他人在相同的模拟手机和SDK上模拟项目。
SOLUTION
Turns out the problem was the main image that we used on our app at the time. The actual size of the image was too large, so we compressed it. Then it worked like a charm, no loss in quality and the app ran fine on the emulator.
原来问题是我们当时在我们的应用程序上使用的主要图像。图像的实际尺寸太大,因此我们将其压缩。然后它就像一个魅力,没有质量损失,应用程序在模拟器上运行良好。
5 个解决方案
#1
78
Move your image in the (hi-res) drawable to drawable-xxhdpi. But in app development, you do not need to use large image. It will increase your APK file size.
将(hi-res)drawable中的图像移动到drawable-xxhdpi。但在应用开发中,您不需要使用大图像。它会增加你的APK文件大小。
#2
4
I had the same problem. If you try to upload an image that is too large on some low resolution devices, the app will collapse. You can make several images of different sizes (hdpi, xxdpi and more) or simply use an external library to load images that solve the problem quickly and efficiently. I used Glide library (you can use another library like Picasso).
我有同样的问题。如果您尝试在某些低分辨率设备上上传过大的图片,则应用会崩溃。您可以制作多个不同大小的图像(hdpi,xxdpi等),或者只使用外部库来加载快速有效地解决问题的图像。我使用了Glide库(你可以使用像Picasso这样的另一个库)。
panel_IMG_back = (ImageView) findViewById(R.id.panel_IMG_back);
Glide
.with(this)
.load(MyViewUtils.getImage(R.drawable.wallpaper)
.into(panel_IMG_back);
#3
3
Turns out the problem was the main image that we used on our app at the time. The actual size of the image was too large, so we compressed it. Then it worked like a charm, no loss in quality and the app ran fine on the emulator.
原来问题是我们当时在我们的应用程序上使用的主要图像。图像的实际尺寸太大,因此我们将其压缩。然后它就像一个魅力,没有质量损失,应用程序在模拟器上运行良好。
#4
0
In my case I had to remove the android platform and add it again. Something got stuck and copying all my code into another app worked like a charm - hence my idea of cleaning up the build for android by removing the platform.
在我的情况下,我不得不删除Android平台并再次添加它。有些东西卡住了,把我所有的代码复制到另一个应用程序就像一个魅力 - 因此我想通过删除平台来清理android的构建。
cordova platform remove android
cordova platform add android
I guess it's some kind of cleanup that you have to do from time to time :-(
我想这是你不时要做的某种清理:-(
#5
0
For this error was like others said a big image(1800px X 900px) which was in drawable directory, I edited the image and reduced the size proportionally using photoshop and it worked...!!
对于这个错误就像其他人说的一个大图像(1800px X 900px),这是在drawable目录,我编辑图像,并使用photoshop按比例缩小尺寸,它的工作...... !!
#1
78
Move your image in the (hi-res) drawable to drawable-xxhdpi. But in app development, you do not need to use large image. It will increase your APK file size.
将(hi-res)drawable中的图像移动到drawable-xxhdpi。但在应用开发中,您不需要使用大图像。它会增加你的APK文件大小。
#2
4
I had the same problem. If you try to upload an image that is too large on some low resolution devices, the app will collapse. You can make several images of different sizes (hdpi, xxdpi and more) or simply use an external library to load images that solve the problem quickly and efficiently. I used Glide library (you can use another library like Picasso).
我有同样的问题。如果您尝试在某些低分辨率设备上上传过大的图片,则应用会崩溃。您可以制作多个不同大小的图像(hdpi,xxdpi等),或者只使用外部库来加载快速有效地解决问题的图像。我使用了Glide库(你可以使用像Picasso这样的另一个库)。
panel_IMG_back = (ImageView) findViewById(R.id.panel_IMG_back);
Glide
.with(this)
.load(MyViewUtils.getImage(R.drawable.wallpaper)
.into(panel_IMG_back);
#3
3
Turns out the problem was the main image that we used on our app at the time. The actual size of the image was too large, so we compressed it. Then it worked like a charm, no loss in quality and the app ran fine on the emulator.
原来问题是我们当时在我们的应用程序上使用的主要图像。图像的实际尺寸太大,因此我们将其压缩。然后它就像一个魅力,没有质量损失,应用程序在模拟器上运行良好。
#4
0
In my case I had to remove the android platform and add it again. Something got stuck and copying all my code into another app worked like a charm - hence my idea of cleaning up the build for android by removing the platform.
在我的情况下,我不得不删除Android平台并再次添加它。有些东西卡住了,把我所有的代码复制到另一个应用程序就像一个魅力 - 因此我想通过删除平台来清理android的构建。
cordova platform remove android
cordova platform add android
I guess it's some kind of cleanup that you have to do from time to time :-(
我想这是你不时要做的某种清理:-(
#5
0
For this error was like others said a big image(1800px X 900px) which was in drawable directory, I edited the image and reduced the size proportionally using photoshop and it worked...!!
对于这个错误就像其他人说的一个大图像(1800px X 900px),这是在drawable目录,我编辑图像,并使用photoshop按比例缩小尺寸,它的工作...... !!