java - Failed resolution of: Lcom/abhi/barcode/frag/libv2/R$string -


i'm trying launch activity fragment inside doing qr scan, i'm using library > https://code.google.com/archive/p/barcodefraglibv2/

i instructions when run app throws away exception :

failed resolution of: lcom/abhi/barcode/frag/libv2/r$string 

what doing wrong ?

here mainactivity:

package apps.radwin.zxingprojectfragmentsthree;  import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.view.view; import android.widget.button; import android.widget.toast;  import com.abhi.barcode.frag.libv2.barcodefragment; import com.abhi.barcode.frag.libv2.iscanresulthandler; import com.abhi.barcode.frag.libv2.scanresult; import com.google.zxing.barcodeformat;  import java.util.enumset;  public class mainactivity extends fragmentactivity implements iscanresulthandler {          barcodefragment fragment;         button btn;          @override         protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             setcontentview(r.layout.activity_main);             fragment = (barcodefragment)getsupportfragmentmanager().findfragmentbyid(r.id.sample);             fragment.setscanresulthandler(this);             btn = ((button)findviewbyid(r.id.scan));             btn.setenabled(false);              // support adding decoding type             fragment.setdecodefor(enumset.of(barcodeformat.qr_code));         }          @override         public void scanresult(scanresult result) {             btn.setenabled(true);             toast.maketext(this, result.getrawresult().gettext(), toast.length_long).show();         }          public void scanagain(view v){             fragment.restart();         }     } 

here build.gradle file

apply plugin: 'com.android.application'  android {     compilesdkversion 23     buildtoolsversion "23.0.3"      defaultconfig {         applicationid "apps.radwin.zxingprojectfragmentsthree"         minsdkversion 16         targetsdkversion 23         versioncode 1         versionname "1.0"     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  dependencies {     compile filetree(include: ['*.jar'], dir: 'libs')     testcompile 'junit:junit:4.12'     compile 'com.android.support:appcompat-v7:23.4.0'     compile files('libs/barcodelib.jar')     compile files('libs/core.jar') } 

my activity xml >

 <?xml version="1.0" encoding="utf-8"?>     <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:paddingbottom="@dimen/activity_vertical_margin"         android:paddingleft="@dimen/activity_horizontal_margin"         android:paddingright="@dimen/activity_horizontal_margin"         android:paddingtop="@dimen/activity_vertical_margin"         tools:context=".mainactivity">          <fragment             android:id="@+id/sample"             android:name="com.abhi.barcode.frag.libv2.barcodefragment"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_above="@+id/scan"             android:layout_alignparenttop="true"             android:layout_centerhorizontal="true" />          <button             android:id="@+id/scan"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerhorizontal="true"             android:layout_centervertical="true"             android:onclick="scanagain"             android:text="re-scan" /> </relativelayout> 

my exception is:

fatal exception: main  process: apps.radwin.zxingprojectfragmentsthree, pid: 11692 java.lang.noclassdeffounderror: failed resolution of: lcom/abhi/barcode/frag/libv2/r$string; @ com.abhi.barcode.frag.libv2.barcodefragment.displayframeworkbugmessageandexit(barcodefragment.java:345) @ com.abhi.barcode.frag.libv2.barcodefragment.initcamera(barcodefragment.java:338) @ com.abhi.barcode.frag.libv2.barcodefragment.surfacecreated(barcodefragment.java:212) @ android.view.surfaceview.updatewindow(surfaceview.java:712) @ android.view.surfaceview$3.onpredraw(surfaceview.java:209) @ android.view.viewtreeobserver.dispatchonpredraw(viewtreeobserver.java:1014) @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:2510) @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1437) @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:7397) @ android.view.choreographer$callbackrecord.run(choreographer.java:920) @ android.view.choreographer.docallbacks(choreographer.java:695) @ android.view.choreographer.doframe(choreographer.java:631) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:906) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:158) @ android.app.activitythread.main(activitythread.java:7224) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1230) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1120) caused by: java.lang.classnotfoundexception: didn't find class "com.abhi.barcode.frag.libv2.r$string" on path: dexpathlist[[zip file "/data/app/apps.radwin.zxingprojectfragmentsthree-1/base.apk"],nativelibrarydirectories=[/data/app/apps.radwin.zxingprojectfragmentsthree-1/lib/arm64, /vendor/lib64, /system/lib64]] @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:56) @ java.lang.classloader.loadclass(classloader.java:511) @ java.lang.classloader.loadclass(classloader.java:469) @ com.abhi.barcode.frag.libv2.barcodefragment.displayframeworkbugmessageandexit(barcodefragment.java:345)  @ com.abhi.barcode.frag.libv2.barcodefragment.initcamera(barcodefragment.java:338)  @ com.abhi.barcode.frag.libv2.barcodefragment.surfacecreated(barcodefragment.java:212)  @ android.view.surfaceview.updatewindow(surfaceview.java:712)  @ android.view.surfaceview$3.onpredraw(surfaceview.java:209)  @ android.view.viewtreeobserver.dispatchonpredraw(viewtreeobserver.java:1014)  @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:2510)  @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1437)  @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:7397)  @ android.view.choreographer$callbackrecord.run(choreographer.java:920)  @ android.view.choreographer.docallbacks(choreographer.java:695)  @ android.view.choreographer.doframe(choreographer.java:631)  @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:906)  @ android.os.handler.handlecallback(handler.java:739)  @ android.os.handler.dispatchmessage(handler.java:95)  @ android.os.looper.loop(looper.java:158)  @ android.app.activitythread.main(activitythread.java:7224)  @ java.lang.reflect.method.invoke(native method)  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1230)  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1120)  suppressed: java.lang.classnotfoundexception: com.abhi.barcode.frag.libv2.r$string @ java.lang.class.classforname(native method) @ java.lang.bootclassloader.findclass(classloader.java:781) @ java.lang.bootclassloader.loadclass(classloader.java:841) @ java.lang.classloader.loadclass(classloader.java:504) ... 21 more caused by: java.lang.noclassdeffounderror: class not found using boot class loader; no stack trace available 

in app/libs folder, have 2 files, barcodelib.jar, , code.jar, pressed in android studio on barcodelib.jar file right click, add library, cannot press on core.jar well, doesn't give option.

can me saying doing wrong ?

as of api level 23 , higher camera permission needs requested @ run time

change oncreate code to:

        if (packagemanager.permission_granted == activitycompat.checkselfpermission(mainactivity.this, manifest.permission.camera))         {               // asks primission use devices camera             fragment = (barcodefragment)getsupportfragmentmanager().findfragmentbyid(r.id.sample);             fragment.setscanresulthandler(this);             btn = ((button)findviewbyid(r.id.scan));             btn.setenabled(false);              // support adding decoding type             fragment.setdecodefor(enumset.of(barcodeformat.qr_code));          }          else          {             requestwritepermission(mainactivity.this);         } 

and add function ask permission user:

    private static void requestwritepermission(final context context)      {         if (activitycompat.shouldshowrequestpermissionrationale((activity) context, manifest.permission.camera))          {             new alertdialog.builder(context).setmessage("this app needs permission use phone camera in order activate scanner")                     .setpositivebutton("allow", new dialoginterface.onclicklistener() {                         @override public void onclick(dialoginterface dialog, int which)                          { activitycompat.requestpermissions((activity) context, new string[]{manifest.permission.camera}, 1);}                     }).show();         }          else          {             activitycompat.requestpermissions((activity) context, new string[]{manifest.permission.camera}, 1);         }     } 

better use before going fragment activity add these lines , try again. more input read flowing articale:

https://developer.android.com/training/permissions/requesting.html


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -