When I decode and encode using JSONIC on Android app, I get an Exception error.

Asked 2 years ago, Updated 2 years ago, 76 views

I produce Android apps on Android Studio.
When you use JSONIC to do the following, JSON.encode(hm); displays an Exception error and a message indicating that printStackTrace cannot find the library of jsonic.

If there are no Exception errors and you know how to encode and decode using JSONIC, could you please let me know?

try{
    HashMap<String,Object>hm=new HashMap<>();

    hm.put("001", "Strawberry");
    hm.put("002", "Nikan");
    hm.put("003", "Tangerine");

    String json = JSON.encode(hm);
}catch(Exceptione){
    e.printStackTrace();
    return;
}

e.printStackTrace(); Output on the

W/dalvikvm:Exception Ljava/lang/NoClassDefFoundError;thrown while
initializing Lnet/arnx/jsonic/OptionalConverter; W/System.err:
java.util.MissingResourceException:Can't find resource for bundle
'net.arnx.jsonic.Messages_ja_JP', key' 'W/System.err:at
java.util.ResourceBundle.missingResourceException (ResourceBundle.java:238)

Library File Placement

app\src
app\libs
app\libs\jsonic-1.3.10-sources.jar
app\libs\jsonic-1.3.10.jar

build.gradle

 dependencies {
    compilefileTree (dir: 'libs', include: ['*.jar'])
    compile files ('libs/jsonic-1.3.10.jar')
    compile files ('libs/jsonic-1.3.10-sources.jar')
}

android android-studio json

2022-09-30 14:45

1 Answers

I created a blank project on Android Studio and tried using jsonic-1.3.10, but it worked without any problems.

However, there were two things that bothered me.

com.android.build.api.transform.TransformException:
com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK net/arnx/jsonic/Messages.properties 

Also, regarding the error in the questionnaire,
Can't find resource for bundle'net.arnx.jsonic.Messages_ja_JP', key'
This error occurs because the class path of the app does not contain net/arnx/jsonic/Messages_ja.properties or net/arnx/jsonic/Messages.properties.

·There are no errors in including two jar
·Can't find resource for bundle'net.arnx.jsonic.Messages_ja_JP', key' error occurred

Based on the above two points, isn't jsonic-1.3.10.jar incorrectly included in the built application?


2022-09-30 14:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.