android - Using Outpan's JAVA API -


i having problems using outpan java api in android project. api mentioned in official outpan website.

my progress till now-:

  • i downloaded outpan java api here, , extracted them.
  • i copied folder io inside src folder (inside downloaded folder) home->androidstudioprojects->(name of project)->app->src->main->java (i using android studio on ubuntu).
  • i copied .jar file inside libs folder (inside downloaded folder) home->androidstudioprojects->(name of project)->app->libs folder.
  • opened android studio project, created earlier (it scans barcodes using zxing library) , added these 2 lines import statements in project-: import io.github.johncipponeri.outpanapi.outpanapi; import io.github.johncipponeri.outpanapi.outpanobject;
  • next, used normal commands given in github repository (that have mentioned earlier) along proper api key (i have registered on outpan).
  • next went to, gradle file (module: app) of project, , added line 'depedencies' section-: compile files('libs/org.json-20131017.jar')

so, when tried debug app on phone, following errors came-:

information:gradle tasks [:app:assembledebug] :app:prebuild up-to-date :app:predebugbuild up-to-date :app:checkdebugmanifest :app:prereleasebuild up-to-date :app:preparecomandroidsupportappcompatv72103library up-to-date :app:preparecomandroidsupportsupportv42103library up-to-date :app:preparecomjourneyappszxingandroidembedded201library up-to-date :app:preparecomjourneyappszxingandroidintegration201library up-to-date :app:preparecomjourneyappszxingandroidlegacy201library up-to-date :app:preparedebugdependencies :app:compiledebugaidl up-to-date :app:compiledebugrenderscript up-to-date :app:generatedebugbuildconfig up-to-date :app:generatedebugassets up-to-date :app:mergedebugassets up-to-date :app:generatedebugresvalues up-to-date :app:generatedebugresources up-to-date :app:mergedebugresources up-to-date :app:processdebugmanifest up-to-date :app:processdebugresources up-to-date :app:generatedebugsources up-to-date :app:processdebugjavares up-to-date :app:compiledebugjava /home/ashutoshsaboo/androidstudioprojects/codescan/app/src/main/java/io/github/johncipponeri/outpanapi/outpanapi.java error:(33, 51) error: cannot find symbol method getencoder() /home/ashutoshsaboo/androidstudioprojects/codescan/app/src/main/java/io/github/johncipponeri/outpanapi/outpanobject.java error:(44, 31) error: cannot find symbol method getnames(jsonobject) error:execution failed task ':app:compiledebugjava'. > compilation failed; see compiler error output details. information:build failed information:total time: 4.348 secs information:3 errors information:0 warnings information:see complete output in console 

it better if downloaded api github, able have @ files individually, because can't paste code of .java files here.

edit:

thanks @johncipponeri help. downloaded new updated version of api, , placed folder in src folder in app->src->main->java folder, , .jar file in libs folder in app->libs folder. also, placed "outpan-api-java-1.1.jar" in app->libs folder, , added following lines in gradle file, under dependencies section-:

compile filetree(dir: 'libs', include: ['*.jar']) compile files('libs/outpan-api-java-1.1.jar') compile 'com.android.support:appcompat-v7:22.2.0' 

but sadly still 2 of previous errors haven't been resolved. so, android package name need of same name "io.github.johncipponeri.outpanapi", because package name different.

my updated message dialog-:

information:gradle tasks [:app:assembledebug] :app:prebuild up-to-date :app:predebugbuild up-to-date :app:checkdebugmanifest :app:prereleasebuild up-to-date :app:preparecomandroidsupportappcompatv72220library up-to-date :app:preparecomandroidsupportsupportv42220library up-to-date :app:preparecomjourneyappszxingandroidembedded201library up-to-date :app:preparecomjourneyappszxingandroidintegration201library up-to-date :app:preparecomjourneyappszxingandroidlegacy201library up-to-date :app:preparedebugdependencies :app:compiledebugaidl up-to-date :app:compiledebugrenderscript up-to-date :app:generatedebugbuildconfig up-to-date :app:generatedebugassets up-to-date :app:mergedebugassets up-to-date :app:generatedebugresvalues up-to-date :app:generatedebugresources up-to-date :app:mergedebugresources up-to-date :app:processdebugmanifest up-to-date :app:processdebugresources up-to-date :app:generatedebugsources up-to-date :app:processdebugjavares up-to-date :app:compiledebugjava /home/ashutoshsaboo/androidstudioprojects/codescan/app/src/main/java/io/github/johncipponeri/outpanapi/outpanapi.java error:(48, 17) error: unreported exception jsonexception; must caught or declared thrown /home/ashutoshsaboo/androidstudioprojects/codescan/app/src/main/java/io/github/johncipponeri/outpanapi/outpanobject.java error:(44, 31) error: cannot find symbol method getnames(jsonobject) note: /home/ashutoshsaboo/androidstudioprojects/codescan/app/src/main/java/com/ashutoshsaboo/codescan/mainactivity.java uses or overrides deprecated api. note: recompile -xlint:deprecation details. error:execution failed task ':app:compiledebugjava'. > compilation failed; see compiler error output details. information:build failed information:total time: 28.092 secs information:3 errors information:0 warnings information:see complete output in console 

error in part of outpanobject.java -:

public outpanobject(jsonobject json) {         this();          this.gtin = json.getstring("gtin");         this.outpan_url = json.getstring("outpan_url");          if (!json.isnull("name"))             this.name = json.getstring("name");          if (!json.isnull("attributes")) {             jsonobject attrobject = json.getjsonobject("attributes");             string[] attrs = jsonobject.getnames(attrobject);              (int = 0; < attrs.length; a++)                 this.attributes.put(attrs[a], attrobject.getstring(attrs[a]));         }          if (!json.isnull("images")) {             jsonarray imgs = json.getjsonarray("images");             (int = 0; < imgs.length(); i++)                 this.images.add(imgs.getstring(i));         }          if (!json.isnull("videos")) {             jsonarray vids = json.getjsonarray("videos");             (int = 0; < vids.length(); i++)                 this.videos.add(vids.getstring(i));         }     } 

another error in part of outpanapi.java-:

while ((numcharsread = isr.read(chararray)) > 0)                 sb.append(chararray, 0, numcharsread);              jsonresult = new jsonobject(sb.tostring());         } catch (malformedurlexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } 

i'm 1 created java wrapper outpan api.

i faced same problem. android supports java 1.7 , version of jar you're using compiled using java 1.8 , 1.8 base64 class.

if download latest version of jar https://github.com/johncipponeri/outpan-api-java/releases/tag/v1.1 problem resolved.

hope helps.

edit:

you can follow following instructions working well. https://github.com/johncipponeri/outpan-api-java/blob/master/readme.md#using-with-android-studio

you don't need include own copy of org.json-20131017.jar packaged wrapper.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -