Android Cookie

Android 安卓是最开放的手机操作系统,谷歌安卓APP开发和安卓市场的相关话题

Android:巨型模式与Multidex

我不完全确定将dex选项“jumbomode”设置为true与添加multidex支持之间的区别。 将巨型模式设置为true或multidex为true似乎解决了下面的问题 AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"} AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexIndexOverflowException: Cannot merge new index 65772 into a non-jumbo instruction!","position":{},"original":"com.android.dex.DexIndexOverflowException: Cannot merge new index 65772 into a non-jumbo instruction!"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer.jumboCheck(InstructionTransformer.java:109)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer.access$800(InstructionTransformer.java:26)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer$StringVisitor.visit(InstructionTransformer.java:72)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)","position":{},"original":"\tat com.android.dx.io.CodeReader.callVisit(CodeReader.java:114)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)","position":{},"original":"\tat com.android.dx.io.CodeReader.visitAll(CodeReader.java:89)"} AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)","position":{},"original":"\tat com.android.dx.merge.InstructionTransformer.transform(InstructionTransformer.java:49)"} …

使用匕首的Android生命周期库ViewModel 2

我有一个ViewModel类,就像在Architecture指南的Connecting ViewModel和repository部分定义的一样。 当我运行我的应用程序,我得到一个运行时exception。 有谁知道如何解决这个问题? 我不应该注入ViewModel吗? 有没有办法告诉ViewModelProvider使用Dagger来创build模型? public class DispatchActivityModel extends ViewModel { private final API api; @Inject public DispatchActivityModel(API api) { this.api = api; } } 由于java.lang.InstantiationException:java.lang.Class在java.lang.Class.newInstance(Native方法)上没有零参数构造函数在android.arch.lifecycle.ViewModelProvider $ NewInstanceFactory.create(ViewModelProvider.java:143)在android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:138)android.arch.lifecycle.ViewModelProviderrs $ DefaultFactory.create(ViewModelProviders.java:143)at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java:128)at android.arch.lifecycle.ViewModelProvider.get(ViewModelProvider.java :96)at com.example.base.BaseActivity.onCreate(BaseActivity.java:65)at com.example.dispatch.DispatchActivity.onCreate(DispatchActivity.java:53)at android.app.Activity.performCreate(Activity.java: (android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727))上的android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)上的android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) app.ActivityThread.-wrap12(ActivityThread.java)在android.app.ActivityT 在android.app.ActivityThread.main上的android.os.Looper.loop(Looper.java:154)android.os.Handler.dispatchMessage(Handler.java:102)hread $ H.handleMessage(ActivityThread.java:1478) (ActivityThread.java:6121)