Android工作室构建和运行应用程序的方法的极限GC尺寸
当我运行我的应用程序时,我在logcat中得到了下面的东西,我坚持这一点,并不能解决这个问题了,我谷歌它但支持超过65k方法使用Android工作室我这样做,但不幸的是,也可以帮助。Android工作室构建和运行应用程序的方法的极限GC尺寸
错误
04-16 18:07:28.442 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3181 (com_facebook_loginview_text_color) in Lcom/facebook/android/R$color; 04-16 18:07:28.442 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x0025
04-16 18:07:28.452 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3265 (com_facebook_login_view) in Lcom/facebook/android/R$styleable;
04-16 18:07:28.452 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x62 at 0x0005
04-16 18:07:28.452 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3248 (com_facebook_loginview_log_out_button) in Lcom/facebook/android/R$string;
04-16 18:07:28.452 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x001a
04-16 18:07:28.452 29389-29389/com.skd.buzzapp W/dalvikvm﹕ VFY: unable to resolve static field 3246 (com_facebook_loginview_log_in_button) in Lcom/facebook/android/R$string;
04-16 18:07:28.452 29389-29389/com.skd.buzzapp D/dalvikvm﹕ VFY: replacing opcode 0x60 at 0x002f
04-16 18:07:28.452 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c76 at 0x32 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.452 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c6c at 0x4a in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c7c at 0x64 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c7e at 0x69 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c71 at 0x72 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c73 at 0x7f in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c75 at 0x89 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c74 at 0x93 in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0c72 at 0x9d in Lcom/facebook/widget/LoginButton;.<init>
04-16 18:07:28.462 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc2 at 0x0b in Lcom/facebook/widget/LoginButton;.parseAttributes
04-16 18:07:28.472 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc3 at 0x13 in Lcom/facebook/widget/LoginButton;.parseAttributes
04-16 18:07:28.472 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc4 at 0x1b in Lcom/facebook/widget/LoginButton;.parseAttributes
04-16 18:07:28.472 29389-29389/com.skd.buzzapp I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0cc5 at 0x23 in Lcom/facebook/widget/LoginButton;.parseAttributes
回答:
要超过65K的方法构建应用程序,您必须添加多DEX支持。 将这些添加到您的应用程序gradle文件。
android { compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14 // Multi Dex not supported below 14
targetSdkVersion 23
multiDexEnabled true // To Enable Multi Dex
}
dexOptions {
preDexLibraries = false /*Include these three statements to build app quickly (at least faster than before :p) */
javaMaxHeapSize "4g" // To avoid GC Limit Exception
jumboMode = true // To avoid GC Limit Exception
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
/* MultiDex - method count exceeds 65k */
compile 'com.android.support:multidex:1.0.1'
}
现在提出申请,辛格尔顿类并覆盖attachBaseContext()
@Override protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
不要忘了声明它在你的清单
<application android:name=".AppController" <!-- Your Application Singleton Class Name -->
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
...
...
</application>
由于在Android Studio中,你可能仍然内存限制得到GC错误。 尝试清理你的项目,然后再次构建它。
你现在全部设置!
以上是 Android工作室构建和运行应用程序的方法的极限GC尺寸 的全部内容, 来源链接: utcz.com/qa/260552.html