随着依赖关系的增加,Android应用启动时间增加
我的应用启动有问题。它增加了“显示”时间,并添加一些依赖项(仍然没有使用。只是添加)。 问题是,每当我评论这些依赖项时,它都会将时间降低到20毫秒
的时间:1S56ms 没有依赖关系的时间:1S36ms,
即使我没有使用这些依赖关系。这些依赖性对内存剖面的依赖性没有加载。因此,我的问题是,仅添加依赖项,为什么它会散发“显示”时间。
依赖项:
implementation 'com.google.android.libraries.places:places:2.6.0'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.android.gms:play-services-location:19.0.1'
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
启动活动代码:
class MainActivity : AppCompatActivity() {
lateinit var mContext:Context
lateinit var binding:ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mContext = this
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnGo.setOnClickListener {
Intent(mContext,BasicActivity::class.java).also {
startActivity(it)
}
}
}
}
I have an issue with my app startup. It increase the "Displayed" Time with adding some dependencies (still not used. just added).
Problem is that whenever I comment these dependencies it reduces the time up to 20ms
Time with dependencies : 1s56ms
Time without dependencies : 1s36ms
Even though i have not used these dependencies. There are no object loaded of these dependencies on memory profiler. So my question is that by just adding dependencies, why it inccreases the "Displayed" time.
Dependencies:
implementation 'com.google.android.libraries.places:places:2.6.0'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
implementation 'com.google.android.gms:play-services-location:19.0.1'
def retrofit_version = "2.9.0"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
Launching Activity Code:
class MainActivity : AppCompatActivity() {
lateinit var mContext:Context
lateinit var binding:ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mContext = this
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.btnGo.setOnClickListener {
Intent(mContext,BasicActivity::class.java).also {
startActivity(it)
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论