[英]Android: Application is running slow after it's been migrated from old adt-bundle to latest android studio
Its been a year I was inactive with android development. 这是我对Android开发不感兴趣的一年。 Earlier I used to develop apps using adt-bundle eclipse.
之前,我曾经使用adt-bundle eclipse开发应用程序。 Recently I started working with Android studio.
最近,我开始使用Android Studio。 I have migrated my application code by creating new files in android studio project and copied code, also made some changes in manifest and newly introduced build.gradle files.
我已经通过在android studio项目中创建新文件并复制代码来迁移了我的应用程序代码,还对清单文件和新引入的build.gradle文件进行了一些更改。
First I got error, java.lang.OutOfMemoryError 首先我得到了错误java.lang.OutOfMemoryError
So I've added following in manifest file, android:largeHeap="true" 所以我在清单文件android:largeHeap =“ true”中添加了以下内容
This problem is resolved then. 然后解决此问题。
Later I removed inherited class ActionBarActivity from activity classes, and inherited AppCompatActivity . 后来,我从活动类中删除了继承的类ActionBarActivity ,并继承了AppCompatActivity 。
Also added following in bundle.gradle 还在bundle.gradle中添加了以下内容
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.3.0'
}
now I'm getting following errors, 现在我遇到以下错误,
I/Choreographer: Skipped 158 frames! The application may be doing too much work on its main thread.
E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
Is the problem arising due to following use of findViewByID 是由于以下使用findViewByID引起的问题吗
(EditText) findViewById(R.id.editText1);
(EditText) findViewById(R.id.editText2);
(EditText) findViewById(R.id.editText3);
(Spinner) findViewById(R.id.spinner1);
(EditText) findViewById(R.id.editText4);
The main problem is, app is running very slow!!! 主要问题是,应用程序运行速度非常慢!!!
Not sure if you are having the same issue as mine. 不知道您是否遇到与我相同的问题。 Mine was because my app has a configuration in AndroidManifest that says android:hardwareAccelerated="false"
我的原因是我的应用程序在AndroidManifest中有一个配置,内容为android:hardwareAccelerated =“ false”
This doesn't cause any lag issue in the old UI, but I am thinking that maybe with the new material design UI effects it introduces some lag unless we use hardware acceleration. 这不会在旧版UI中引起任何滞后问题,但我认为,除非使用硬件加速,否则新的材料设计UI效果可能会引入一些滞后。
Try removing android:hardwareAccelerated="false" or set it to true to see if it still lags when responding to your touches. 尝试删除android:hardwareAccelerated =“ false”或将其设置为true,以查看响应您的触摸时是否仍然滞后。 It solves mine.
它解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.