Android 三星Galaxy系列内存不足
我有一个欢迎版面,这是我启动应用程序时的第一个版面。我可以在其他设备和Android Studio的模拟器中成功运行该项目 但当我尝试在三星Galaxy系列的GenyMoon模拟器上运行时,它显示了错误 致命异常:主进程:com.example.huaweb_system.taiwanuniversityhome,PID:2325 java.lang.OutOfMemoryError:无法分配157286412字节的分配,其中有6136736个可用字节和87MB,直到OOM 并标记此代码Android 三星Galaxy系列内存不足,android,genymotion,samsung-galaxy,Android,Genymotion,Samsung Galaxy,我有一个欢迎版面,这是我启动应用程序时的第一个版面。我可以在其他设备和Android Studio的模拟器中成功运行该项目 但当我尝试在三星Galaxy系列的GenyMoon模拟器上运行时,它显示了错误 致命异常:主进程:com.example.huaweb_system.taiwanuniversityhome,PID:2325 java.lang.OutOfMemoryError:无法分配157286412字节的分配,其中有6136736个可用字节和87MB,直到OOM 并标记此代码 at
at com.example.huaweb_system.taiwanuniversityhome.StartSplash.onCreate(StartSplash.java:49)
这是我的欢迎课:
public class StartSplash extends AppCompatActivity {
private ImageView imageStartSplash;
private static final int GOTO_MAIN_ACTIVITY = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_start_splash);//show error on this line
handler.sendEmptyMessageDelayed(GOTO_MAIN_ACTIVITY, 4000);
//my image is 1280*1920.png
imageStartSplash = (ImageView) findViewById(R.id.imageStartSplash);
//fade out image
AlphaAnimation alpha = new AlphaAnimation(1.0F, 0.0F);
alpha.setDuration(4000);
alpha.setFillAfter(true);
imageStartSplash.setAnimation(alpha);
}
//delay setting
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Intent intent = new Intent(StartSplash.this, MainActivity.class);
startActivity(intent);
finish();
break;
default:
break;
}
}
};
}
我真的不知道为什么?我尝试删除它们,如:
//imageStartSplash = (ImageView) findViewById(R.id.imageStartSplash);
//fade out image
//AlphaAnimation alpha = new AlphaAnimation(1.0F, 0.0F);
//alpha.setDuration(4000);
//alpha.setFillAfter(true);
//imageStartSplash.setAnimation(alpha);
它仍然显示错误。。。为什么会这样
以下是我的布局xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_start_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.taiwandigestionsociety_v11.StartSplash">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
//i find that if i change the image smaller is would be fine.
app:srcCompat="@drawable/splash_screen_portrait_xxxhdpi_1280x1920"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/imageStartSplash" />
</RelativeLayout>
显示您的xml布局。我刚刚发现问题可能在于我的图像字节,现在我的问题是建议如何在Samsumg Galaxy series上设置图像背景?@user2234894,我更新了我的xml布局。尝试只提供一个图像文件并将其放置在“drawable nodpi”中?(记得从drawable hdpi、xhdpi、xxhdpi等中删除图像)嘿,感谢您的回复,有人教我修复低于6136736字节的图像,我现在修复了这个问题,谢谢!显示您的xml布局。我刚刚发现问题可能在于我的图像字节,现在我的问题是建议如何在Samsumg Galaxy series上设置图像背景?@user2234894,我更新了我的xml布局。尝试只提供一个图像文件,并将其仅放在“drawable nodpi”中?(记得从drawable hdpi、xhdpi、xxhdpi等中删除图像)嘿,感谢您的回复,有人教我修复低于6136736字节的图像,我现在修复了这个问题,谢谢!