Can not use class org.json.XML on Android Studio -


i want parse xml string json, search , know can use library java-json this. added dependencies build.gradle

apply plugin: 'com.android.application'  android {     compilesdkversion 23     buildtoolsversion "23.0.1"      defaultconfig {         applicationid "com.hnib.docbaoonline"         minsdkversion 15         targetsdkversion 23         versioncode 1         versionname "1.0"     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     testcompile 'junit:junit:4.12'     compile 'com.android.support:appcompat-v7:23.0.1'     compile 'com.android.support:design:23.0.1' } 

what did :

jsonobject jsonobj = null; try {     jsonobj = xml.tojsonobject(samplexml); } catch (jsonexception e) {     log.e("json exception", e.getmessage());     e.printstacktrace(); }  

android studio notify me can not use xml class , checked , found can not import package org.json.xml

import org.json.jsonexception; import org.json.jsonobject; import org.json.xml;  // error here 

i not know why, try add jar file lib have same result. have same problem , how resolve ?

select the project view in navigation, in app/module's libs folder, have pasted .jar file, right click on .jar file , select add library .

or

in build.gradle, add compile files('libs/json-20150729.jar') in dependencies block.

dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     testcompile 'junit:junit:4.12'     compile 'com.android.support:appcompat-v7:23.0.1'     compile 'com.android.support:design:23.0.1'      //this :      compile files('libs/json-20150729.jar')  } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -