java - Roboguice NoClassDefFoundError -
i started using roboguice today, following wiki https://github.com/roboguice/roboguice/wiki/your-first-view-injection, examples working fine when create new app, when trying integrate roboguice on existing app, given noclassdeffounderror @ runtime
this mainactivity below.
import android.app.searchmanager; import android.content.componentname; import android.content.context; import android.content.intent; import android.content.res.configuration; import android.net.uri; import android.os.bundle; import android.support.design.widget.navigationview; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbar; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.widget.toolbar; import android.util.log; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.view.view; import android.widget.imageview; import android.widget.searchview; import android.widget.textview; import com.example.hp.navigationexercise.r; import roboguice.roboguice; import roboguice.activity.roboactionbaractivity; import roboguice.inject.injectview; public class mainactivity extends roboactionbaractivity implements android.view.view.onclicklistener{ //roboguice static { roboguice.setuseannotationdatabases(false); } @injectview(r.id.textme) textview textview; private drawerlayout mdrawer; private toolbar toolbar; private actionbardrawertoggle drawertoggle; public static final string prefs_name = "myprefsfile"; int firstrun = 0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // set toolbar replace actionbar. toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); // find our drawer view mdrawer = (drawerlayout) findviewbyid(r.id.drawer_layout); //setupdrawercontent(mdrawer); drawertoggle = setupdrawertoggle(); // tie drawerlayout events actionbartoggle mdrawer.setdrawerlistener(drawertoggle); // set menu icon instead of launcher icon. final actionbar ab = getsupportactionbar(); ab.sethomeasupindicator(r.drawable.ic_navigation_drawer); ab.setdisplayhomeasupenabled(true); navigationview navigationview = (navigationview) findviewbyid(r.id.nvview); if (navigationview != null) { setupdrawercontent(navigationview); } } private actionbardrawertoggle setupdrawertoggle() { return new actionbardrawertoggle(this, mdrawer, toolbar, r.string.drawer_open, r.string.drawer_close); } private void setupdrawercontent(navigationview navigationview) { navigationview.setnavigationitemselectedlistener( new navigationview.onnavigationitemselectedlistener() { @override public boolean onnavigationitemselected(menuitem menuitem) { selectdraweritem(menuitem); return true; } }); } public void selectdraweritem(menuitem menuitem) { //handles menu drawer items } public void onfragmentinteraction(uri uri){ //you can leave empty } }
this error throws
08-19 14:24:23.514 25562-25562/com.example.hp.navigationexercise e/androidruntime﹕ fatal exception: main process: com.example.hp.navigationexercise, pid: 25562 java.lang.noclassdeffounderror: android.support.v7.appcompat.r$layout @ android.support.v7.app.appcompatdelegateimplv7.ensuresubdecor(appcompatdelegateimplv7.java:324) @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:246) @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106) @ com.example.hp.navigationexercise.activity.mainactivity.oncreate(mainactivity.java:69) @ android.app.activity.performcreate(activity.java:5343) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1090) @ android.app.activitythread.performlaunchactivity(activitythread.java:2331) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2419) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1342) @ android.os.handler.dispatchmessage(handler.java:110) @ android.os.looper.loop(looper.java:193) @ android.app.activitythread.main(activitythread.java:5323) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:824) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:640) @ dalvik.system.nativestart.main(native method)
it throws error pointing setcontentview(r.layout.activity_main);
in line no 69
this build.gradle (app)
apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' android { compilesdkversion 22 buildtoolsversion "22.0.1" packagingoptions { exclude 'meta-inf/dependencies.txt' exclude 'meta-inf/dependencies' exclude 'meta-inf/dependencies.txt' exclude 'meta-inf/license.txt' exclude 'meta-inf/license' exclude 'meta-inf/license.txt' exclude 'meta-inf/lgpl2.1' exclude 'meta-inf/notice.txt' exclude 'meta-inf/notice' exclude 'meta-inf/notice.txt' } repositories { mavencentral() maven { url 'https://maven.fabric.io/public' } } defaultconfig { applicationid "com.example.hp.navigationexercise" minsdkversion 14 targetsdkversion 22 versioncode 1 versionname "1.0" // enabling multidex support. multidexenabled true } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile('com.twitter.sdk.android:twitter:1.3.2@aar') { transitive = true; } compile 'com.android.support:design:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:cardview-v7:22.2.0' compile 'com.android.support:recyclerview-v7:22.2.0' compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:support-annotations:22.2.0' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.android.support:gridlayout-v7:22.2.0' compile 'com.github.bumptech.glide:glide:3.6.0' compile 'de.hdodenhof:circleimageview:1.3.0' compile 'com.google.android.gms:play-services:7.3.0' compile 'com.facebook.android:facebook-android-sdk:4.1.0' compile 'org.roboguice:roboguice:3.0' provided 'org.roboguice:roboblender:3.0' }
build.gradle (project)
// top-level build file can add configuration options common sub-projects/modules. buildscript { repositories { mavencentral() maven { url 'https://maven.fabric.io/public' } jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' // note: not place application dependencies here; belong // in individual module build.gradle files } } allprojects { repositories { jcenter() maven { url 'https://maven.fabric.io/public' } } }
proguard
-dontwarn com.squareup.okhttp.** -dontwarn com.google.appengine.api.urlfetch.** -dontwarn rx.** -dontwarn retrofit.** -keepattributes signature -keepattributes *annotation* -keep class com.squareup.okhttp.** { *; } -keep interface com.squareup.okhttp.** { *; } -keep class retrofit.** { *; } -keepclasseswithmembers class * { @retrofit.http.* <methods>; }
any appreciated.
this dex size problem (normally can't compile , dex of more 65k functions, solvable using enabling multi-dex in gradle script).
try enable multi-dex , see if helps.
here link - http://developer.android.com/tools/building/multidex.html.
good luck.
Comments
Post a Comment